mpv.dll perfect picture/video control
Posted: 22 Mar 2023, 06:54
Use mpv as a gif control. It performs better and saves memory compared to ActiveX controls, or using timers and GDIP.
Code: Select all
ui := Gui()
pic := ui.Add("Picture", "w300 h200")
mpv := gif(pic.hwnd, 'loadfile "D:\test.gif" replace loop-file=inf')
ui.show()
return
gif(hwnd, path) { ;https://github.com/shinchiro/mpv-winbuild-cmake/releases
static _ := DllCall("LoadLibrary", "str", A_AhkDir "\libmpv-2.dll", "Cdecl UPtr")
mpvhd := DllCall("libmpv-2.dll\mpv_create", "Cdecl UPtr")
DllCall("libmpv-2.dll\mpv_set_option", "ptr", mpvhd, "astr", "wid", "int64", 4, "ptr*", hwnd, "Cdecl int")
DllCall("libmpv-2.dll\mpv_initialize", "ptr", mpvhd, "Cdecl int")
DllCall("libmpv-2.dll\mpv_command_string", "ptr", mpvhd, "ptr", strbuf(StrReplace(path, "\", "\\")), "Cdecl int")
return { ptr: mpvhd, __Delete: t => DllCall("libmpv-2.dll\mpv_destroy", "ptr", t) }
}