コード例 #1
0
 public MpvWrapper(IntPtr systemHandle, MpvStatus mpvStatus)
 {
     SystemHandle = systemHandle;
     MpvStatus    = mpvStatus;
     MpvHandle    = Libmpv.mpv_create();
     Initialize();
     EventTask = new MpvEventTask(this, MpvStatus, EventTaskCancellationTokenSource).StartEventTask();
 }
コード例 #2
0
        private void DoCommand(params string[] commands)
        {
            var err = Libmpv.ExecuteCommand(MpvHandle, commands);

            if (err != Libmpv.mpv_error.MPV_ERROR_SUCCESS)
            {
                throw new LibMpvException(err);
            }
        }
コード例 #3
0
        private void Initialize()
        {
            Libmpv.set_property_string(MpvHandle, "wid", SystemHandle.ToString());
            Libmpv.set_property_string(MpvHandle, "osc", "no");
            Libmpv.set_property_string(MpvHandle, "force-window", "no");
            Libmpv.set_property_string(MpvHandle, "no-taskbar-progress", "no");
            var err = Libmpv.mpv_initialize(MpvHandle);

            if (err != Libmpv.mpv_error.MPV_ERROR_SUCCESS)
            {
                throw new LibMpvException(err);
            }
            MpvObservables.SetupObservables(MpvHandle);
        }
コード例 #4
0
        private void WaitForEvent(Libmpv.mpv_event_id eventId)
        {
            while (true)
            {
                var ptr = Libmpv.mpv_wait_event(MpvHandle, -1);

                if (Marshal.PtrToStructure(ptr, typeof(Libmpv.mpv_event)) is Libmpv.mpv_event evt)
                {
                    if (evt.event_id == eventId)
                    {
                        break;
                    }
                }
            }
        }
コード例 #5
0
        public IEnumerable <MediaTrack> GetTracks()
        {
            var count = Libmpv.get_property_int(MpvHandle, "track-list/count");

            for (var i = 0; i < count; i++)
            {
                var type = Libmpv.get_property_string(MpvHandle, $"track-list/{i}/type");

                if (type == "video")
                {
                    continue;
                }

                yield return(new MediaTrack(type == "sub" ? MediaTrackType.Subtitle : MediaTrackType.Audio,
                                            GetLanguage(Libmpv.get_property_string(MpvHandle, $"track-list/{i}/lang")),
                                            Libmpv.get_property_int(MpvHandle, $"track-list/{i}/id"),
                                            Libmpv.get_property_string(MpvHandle, $"track-list/{i}/title")));
            }
        }
コード例 #6
0
ファイル: MpvExtensions.cs プロジェクト: redbaty/AvaloniaMpv
 public static string GetMessage(this Libmpv.mpv_error err) => ConvertFromUtf8(Libmpv.mpv_error_string(err));
コード例 #7
0
 public void Close()
 {
     Libmpv.mpv_terminate_destroy(MpvHandle);
     EventTaskCancellationTokenSource?.Cancel();
     EventTask?.Dispose();
 }