Fix libmpv API changes
This commit is contained in:
@@ -5,7 +5,7 @@ not yet released
|
||||
- Custom conf folder location feature removed.
|
||||
- Inno Setup replaced with Microsoft Store setup.
|
||||
- Fix script-opts files being ingnored.
|
||||
- libmpv shinchiro 2021-11-14
|
||||
- libmpv shinchiro 2021-12-19
|
||||
|
||||
|
||||
5.5.0.4 Beta (2021-11-05)
|
||||
|
||||
@@ -31,18 +31,10 @@ namespace mpvnet
|
||||
public event Action CommandReplyAsync; // command-reply MPV_EVENT_COMMAND_REPLY
|
||||
public event Action StartFileAsync; // start-file MPV_EVENT_START_FILE
|
||||
public event Action FileLoadedAsync; // file-loaded MPV_EVENT_FILE_LOADED
|
||||
public event Action TracksChangedAsync; // MPV_EVENT_TRACKS_CHANGED
|
||||
public event Action TrackSwitchedAsync; // MPV_EVENT_TRACK_SWITCHED
|
||||
public event Action IdleAsync; // idle MPV_EVENT_IDLE
|
||||
public event Action PauseAsync; // MPV_EVENT_PAUSE
|
||||
public event Action UnpauseAsync; // MPV_EVENT_UNPAUSE
|
||||
public event Action ScriptInputDispatchAsync; // MPV_EVENT_SCRIPT_INPUT_DISPATCH
|
||||
public event Action VideoReconfigAsync; // video-reconfig MPV_EVENT_VIDEO_RECONFIG
|
||||
public event Action AudioReconfigAsync; // audio-reconfig MPV_EVENT_AUDIO_RECONFIG
|
||||
public event Action MetadataUpdateAsync; // MPV_EVENT_METADATA_UPDATE
|
||||
public event Action SeekAsync; // seek MPV_EVENT_SEEK
|
||||
public event Action PlaybackRestartAsync; // playback-restart MPV_EVENT_PLAYBACK_RESTART
|
||||
public event Action ChapterChangeAsync; // MPV_EVENT_CHAPTER_CHANGE
|
||||
|
||||
public event Action<mpv_log_level, string>LogMessage; // log-message MPV_EVENT_LOG_MESSAGE
|
||||
public event Action<mpv_end_file_reason> EndFile; // end-file MPV_EVENT_END_FILE
|
||||
@@ -53,25 +45,19 @@ namespace mpvnet
|
||||
public event Action CommandReply; // command-reply MPV_EVENT_COMMAND_REPLY
|
||||
public event Action StartFile; // start-file MPV_EVENT_START_FILE
|
||||
public event Action FileLoaded; // file-loaded MPV_EVENT_FILE_LOADED
|
||||
public event Action TracksChanged; // MPV_EVENT_TRACKS_CHANGED
|
||||
public event Action TrackSwitched; // MPV_EVENT_TRACK_SWITCHED
|
||||
public event Action Idle; // idle MPV_EVENT_IDLE
|
||||
public event Action Pause; // MPV_EVENT_PAUSE
|
||||
public event Action Unpause; // MPV_EVENT_UNPAUSE
|
||||
public event Action ScriptInputDispatch; // MPV_EVENT_SCRIPT_INPUT_DISPATCH
|
||||
public event Action VideoReconfig; // video-reconfig MPV_EVENT_VIDEO_RECONFIG
|
||||
public event Action AudioReconfig; // audio-reconfig MPV_EVENT_AUDIO_RECONFIG
|
||||
public event Action MetadataUpdate; // MPV_EVENT_METADATA_UPDATE
|
||||
public event Action Seek; // seek MPV_EVENT_SEEK
|
||||
public event Action PlaybackRestart; // playback-restart MPV_EVENT_PLAYBACK_RESTART
|
||||
public event Action ChapterChange; // MPV_EVENT_CHAPTER_CHANGE
|
||||
|
||||
public event Action Initialized;
|
||||
public event Action InitializedAsync;
|
||||
public event Action VideoSizeChanged;
|
||||
public event Action VideoSizeChangedAsync;
|
||||
public event Action<float> ScaleWindow;
|
||||
public event Action<float> WindowScale;
|
||||
public event Action<int> PlaylistPosChanged;
|
||||
public event Action<int> PlaylistPosChangedAsync;
|
||||
public event Action<Size> VideoSizeChanged;
|
||||
public event Action<Size> VideoSizeChangedAsync;
|
||||
|
||||
public Dictionary<string, List<Action>> PropChangeActions { get; set; } = new Dictionary<string, List<Action>>();
|
||||
public Dictionary<string, List<Action<int>>> IntPropChangeActions { get; set; } = new Dictionary<string, List<Action<int>>>();
|
||||
@@ -171,6 +157,18 @@ namespace mpvnet
|
||||
UpdateVideoSize("dwidth", "dheight");
|
||||
});
|
||||
|
||||
ObservePropertyInt("playlist-pos", value => {
|
||||
InvokeEvent(PlaylistPosChanged, PlaylistPosChangedAsync, value);
|
||||
|
||||
if (FileEnded && value == -1)
|
||||
{
|
||||
ShowLogo();
|
||||
|
||||
if (GetPropertyString("keep-open") == "no")
|
||||
Core.CommandV("quit");
|
||||
}
|
||||
});
|
||||
|
||||
Initialized?.Invoke();
|
||||
InvokeAsync(InitializedAsync);
|
||||
}
|
||||
@@ -350,7 +348,7 @@ namespace mpvnet
|
||||
if (VideoSize != size)
|
||||
{
|
||||
VideoSize = size;
|
||||
InvokeEvent(VideoSizeChanged, VideoSizeChangedAsync);
|
||||
InvokeEvent(VideoSizeChanged, VideoSizeChangedAsync, size);
|
||||
VideoSizeAutoResetEvent.Set();
|
||||
}
|
||||
}
|
||||
@@ -537,49 +535,15 @@ namespace mpvnet
|
||||
case mpv_event_id.MPV_EVENT_START_FILE:
|
||||
InvokeEvent(StartFile, StartFileAsync);
|
||||
break;
|
||||
case mpv_event_id.MPV_EVENT_TRACKS_CHANGED:
|
||||
InvokeEvent(TracksChanged, TracksChangedAsync);
|
||||
break;
|
||||
case mpv_event_id.MPV_EVENT_TRACK_SWITCHED:
|
||||
InvokeEvent(TrackSwitched, TrackSwitchedAsync);
|
||||
break;
|
||||
case mpv_event_id.MPV_EVENT_IDLE:
|
||||
InvokeEvent(Idle, IdleAsync);
|
||||
|
||||
if (FileEnded)
|
||||
{
|
||||
ShowLogo();
|
||||
|
||||
if (GetPropertyString("keep-open") == "no")
|
||||
Core.CommandV("quit");
|
||||
}
|
||||
break;
|
||||
case mpv_event_id.MPV_EVENT_PAUSE:
|
||||
Paused = true;
|
||||
InvokeEvent(Pause, PauseAsync);
|
||||
break;
|
||||
case mpv_event_id.MPV_EVENT_UNPAUSE:
|
||||
Paused = false;
|
||||
InvokeEvent(Unpause, UnpauseAsync);
|
||||
break;
|
||||
case mpv_event_id.MPV_EVENT_SCRIPT_INPUT_DISPATCH:
|
||||
InvokeEvent(ScriptInputDispatch, ScriptInputDispatchAsync);
|
||||
break;
|
||||
case mpv_event_id.MPV_EVENT_AUDIO_RECONFIG:
|
||||
InvokeEvent(AudioReconfig, AudioReconfigAsync);
|
||||
break;
|
||||
case mpv_event_id.MPV_EVENT_METADATA_UPDATE:
|
||||
InvokeEvent(MetadataUpdate, MetadataUpdateAsync);
|
||||
break;
|
||||
case mpv_event_id.MPV_EVENT_SEEK:
|
||||
InvokeEvent(Seek, SeekAsync);
|
||||
break;
|
||||
case mpv_event_id.MPV_EVENT_PLAYBACK_RESTART:
|
||||
InvokeEvent(PlaybackRestart, PlaybackRestartAsync);
|
||||
break;
|
||||
case mpv_event_id.MPV_EVENT_CHAPTER_CHANGE:
|
||||
InvokeEvent(ChapterChange, ChapterChangeAsync);
|
||||
break;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
@@ -618,6 +582,12 @@ namespace mpvnet
|
||||
action?.Invoke();
|
||||
}
|
||||
|
||||
void InvokeEvent<T>(Action<T> action, Action<T> asyncAction, T t)
|
||||
{
|
||||
InvokeAsync(asyncAction, t);
|
||||
action?.Invoke(t);
|
||||
}
|
||||
|
||||
void InvokeAsync(Action action)
|
||||
{
|
||||
if (action != null)
|
||||
@@ -1109,7 +1079,7 @@ namespace mpvnet
|
||||
|
||||
if (files.Count == 0 || files[0].Contains("://"))
|
||||
{
|
||||
VideoSizeChanged?.Invoke();
|
||||
VideoSizeChanged?.Invoke(VideoSize);
|
||||
VideoSizeAutoResetEvent.Set();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -52,8 +52,8 @@ namespace mpvnet
|
||||
Core.ScaleWindow += Core_ScaleWindow;
|
||||
Core.WindowScale += Core_WindowScale;
|
||||
Core.FileLoaded += Core_FileLoaded;
|
||||
Core.Idle += Core_Idle;
|
||||
Core.Seek += () => UpdateProgressBar();
|
||||
Core.PlaylistPosChanged += (value) => SetTitle();
|
||||
|
||||
Core.ObserveProperty("window-maximized", PropChangeWindowMaximized);
|
||||
Core.ObserveProperty("window-minimized", PropChangeWindowMinimized);
|
||||
@@ -180,11 +180,9 @@ namespace mpvnet
|
||||
|
||||
void Core_Shutdown() => BeginInvoke(new Action(() => Close()));
|
||||
|
||||
void Core_Idle() => SetTitle();
|
||||
|
||||
void CM_Popup(object sender, EventArgs e) => CursorHelp.Show();
|
||||
|
||||
void Core_VideoSizeChanged() => BeginInvoke(new Action(() =>
|
||||
void Core_VideoSizeChanged(Size value) => BeginInvoke(new Action(() =>
|
||||
{
|
||||
if (!KeepSize())
|
||||
SetFormPosAndSize();
|
||||
@@ -956,7 +954,7 @@ namespace mpvnet
|
||||
void PropChangeTitle(string value) { Title = value; SetTitle(); }
|
||||
|
||||
void PropChangeEdition(int value) => Core.Edition = value;
|
||||
|
||||
|
||||
void PropChangeWindowMaximized()
|
||||
{
|
||||
if (!WasShown)
|
||||
|
||||
@@ -203,10 +203,6 @@ namespace mpvnet
|
||||
Core.FileLoadedAsync += () => Event.Invoke("file-loaded", null);
|
||||
break;
|
||||
|
||||
case "idle":
|
||||
Core.IdleAsync += () => Event.Invoke("idle", null);
|
||||
break;
|
||||
|
||||
case "video-reconfig":
|
||||
Core.VideoReconfigAsync += () => Event.Invoke("video-reconfig", null);
|
||||
break;
|
||||
|
||||
@@ -101,21 +101,15 @@ public class libmpv
|
||||
MPV_EVENT_START_FILE = 6,
|
||||
MPV_EVENT_END_FILE = 7,
|
||||
MPV_EVENT_FILE_LOADED = 8,
|
||||
MPV_EVENT_TRACKS_CHANGED = 9,
|
||||
MPV_EVENT_TRACK_SWITCHED = 10,
|
||||
MPV_EVENT_IDLE = 11,
|
||||
MPV_EVENT_PAUSE = 12,
|
||||
MPV_EVENT_UNPAUSE = 13,
|
||||
MPV_EVENT_IDLE = 11, //deprecated in mpv
|
||||
MPV_EVENT_TICK = 14,
|
||||
MPV_EVENT_SCRIPT_INPUT_DISPATCH = 15,
|
||||
MPV_EVENT_CLIENT_MESSAGE = 16,
|
||||
MPV_EVENT_VIDEO_RECONFIG = 17,
|
||||
MPV_EVENT_AUDIO_RECONFIG = 18,
|
||||
MPV_EVENT_METADATA_UPDATE = 19,
|
||||
MPV_EVENT_SEEK = 20,
|
||||
MPV_EVENT_PLAYBACK_RESTART = 21,
|
||||
MPV_EVENT_PROPERTY_CHANGE = 22,
|
||||
MPV_EVENT_CHAPTER_CHANGE = 23,
|
||||
MPV_EVENT_QUEUE_OVERFLOW = 24,
|
||||
MPV_EVENT_HOOK = 25
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user