MPVDemo-macOS
This is a Xamarin macOS Project to example how to Use MPV github.com/mpv-player/mpv to play video.
Basic flow
- Finding MPV dylibs
- Using DllImport to bind dylibs
- Play video
Finding MPV Dylibs
The most easiest way is grabbing it from github.com/kevinzhow/MPVDemo-macOS/tree/master/MPVDemo/libs and all these libs were modified from
IINA github.com/lhc70000/iina/tree/develop/deps/lib project.
IINA's original dylibs were using @rpath
to solve the Search Path which will causing System.DllNotFoundException
.
You can fix it by install_name_tool
thanks to brendanzagaeski brendanzagaeski.appspot.com/xamarin/0004.html.
Quick Example:
otool -L libavfilter.6.dylib
install_name_tool -change @rpath/libavutil.55.dylib @loader_path/libavutil.55.dylib libavfilter.6.dylib
DllImport
DllImport is C# way to do dlopen developer.xamarin.com/api/type/MonoTouch.ObjCRuntime.Dlfcn/
You can find the instruction from Xamarin Website developer.xamarin.com/guides/ios/advanced_topics/native_interop/#Accessing_C_Dylibs.
Quick Example:
```c#
[DllImport("libmpv.1.25.0.dylib", EntryPoint = "mpv_create")]
private static extern IntPtr MpvCreate();
<br />##Play
MPV has made a great example of how to interaction mpv with C# at mpv-exmaples github.com/mpv-player/mpv-examples/blob/master/libmpv/csharp/Form1.cs
Cocoa platform's specific can also be found at cocoa-example github.com/mpv-player/mpv-examples/tree/master/libmpv/cocoa
```c#
var windowId = VideoView.Handle.ToInt64();
MpvInitialize(_mpvHandle);
DoMpvCommand("loadfile", _mediaFilePath);
Play();