Full-featured player with mpv.dll, replacing VLC, MPC, PotPlayer.
This is a complex subject, but I achieved this in about a thousand lines of code, thus getting rid of MPC and PotPlayer, which I had used for years. it was surprisingly simple, because it was almost indistinguishable from loading a jpg image, with mpvdll taking care of the underlying operations of decoding and drawing, and AutoHotkey taking care of scheduling and interaction. The whole process requires less than 10 mpv-api, and all these functions are just input and output strings, with no complex structure definition and no read/write errors.
Code: Select all
mpv_com_st(mhd, st) => DllCall("libmpv-2.dll\mpv_command_string", "ptr", mhd, "ptr", strbuf(st), "Cdecl int")
mpv_set_opt_st(mhd, opt, st) => DllCall("libmpv-2.dll\mpv_set_option_string", "ptr", mhd, "astr", opt, "ptr", strbuf(st), "Cdecl int")
mpv_set_pro_st(mhd, name, st) => DllCall("libmpv-2.dll\mpv_set_property_string", "ptr", mhd, "astr", name, "ptr", strbuf(st), "Cdecl int")
mpv_get_pro_st(mhd, name, sz := 10240) => (h := DllCall("libmpv-2.dll\mpv_get_property_string", "ptr", mhd, "astr", name, "ptr", t := Buffer(sz), "Cdecl int")) ? StrGet(h, "utf-8") : ''
mpv_set_pro(mhd, name, flag, t, ty := "int64P") => DllCall("libmpv-2.dll\mpv_set_property", "ptr", mhd, "astr", name, "int64", flag, ty, &t, "Cdecl int")
mpv_get_pro(mhd, name, flag, ty := "int64P") => (DllCall("libmpv-2.dll\mpv_get_property", "ptr", mhd, "astr", name, "int64", flag, ty, &t := 0, "Cdecl int"), t)
Setting the volume
mpv_set_pro_st(mhd, "volume", 22)
fast forward
mpv_com_st(mhd, 'osd-bar seek 5')
Get a list of data tracks
mpv_get_pro_st(mhd, "track-list")
The only difficulty to overcome is the need for a separate thread to receive the event callbacks, which requires the creation of a sub-thread using AutoHotkey-H.
If you are unhappy with the player you are using, or if there are any features you cannot implement, I recommend trying to package a player that is entirely yours with mpv.dll.