This is a Xamarin macOS Project to example how to Use MPV to play video.
- Finding MPV dylibs
- Using DllImport to bind dylibs
- Play video
The most easiest way is grabbing it from Here and all these libs were modified from IINA project.
IINA's original dylibs were using @rpath
to solve the Search Path which will cause System.DllNotFoundException
.
You can fix it by install_name_tool
thanks to brendanzagaeski.
Quick Example:
otool -L libavfilter.6.dylib
install_name_tool -change @rpath/libavutil.55.dylib @loader_path/libavutil.55.dylib libavfilter.6.dylib
DllImport is C# way to do dlopen.
You can find the instruction from Xamarin Website.
Quick Example:
[DllImport("libmpv.1.25.0.dylib", EntryPoint = "mpv_create")]
private static extern IntPtr MpvCreate();
MPV has made a great example of how to interaction mpv with C# at mpv-exmaples and mpvnet.
Cocoa platform's specific can also be found at cocoa-example
var windowId = VideoView.Handle.ToInt64();
MpvInitialize(_mpvHandle);
DoMpvCommand("loadfile", _mediaFilePath);
Play();