diff --git a/src/Extensions/RatingExtension/RatingExtension.cs b/src/Extensions/RatingExtension/RatingExtension.cs index 00062f6..094467a 100644 --- a/src/Extensions/RatingExtension/RatingExtension.cs +++ b/src/Extensions/RatingExtension/RatingExtension.cs @@ -80,7 +80,7 @@ namespace RatingExtension // the assembly name must end with 'Extension'! if (int.TryParse(args[1], out int rating)) { - string path = Core.get_property_string("path"); + string path = Core.GetPropertyString("path"); if (!File.Exists(path)) return; @@ -90,7 +90,7 @@ namespace RatingExtension // the assembly name must end with 'Extension'! else { Dic[path] = rating; - Core.commandv("show-text", $"Rating: {rating}"); + Core.CommandV("show-text", $"Rating: {rating}"); } } else if (args[1] == "about") @@ -104,26 +104,26 @@ namespace RatingExtension // the assembly name must end with 'Extension'! { if (rating == 0) { - FileToDelete = Core.get_property_string("path"); + FileToDelete = Core.GetPropertyString("path"); DeleteTime = DateTime.Now; - Core.commandv("show-text", "Press 1 to delete file", "5000"); + Core.CommandV("show-text", "Press 1 to delete file", "5000"); } else { TimeSpan ts = DateTime.Now - DeleteTime; - string path = Core.get_property_string("path"); + string path = Core.GetPropertyString("path"); if (FileToDelete == path && ts.TotalSeconds < 5 && File.Exists(FileToDelete)) { - Core.command("playlist-remove current"); - int pos = Core.get_property_int("playlist-pos"); + Core.Command("playlist-remove current"); + int pos = Core.GetPropertyInt("playlist-pos"); if (pos == -1) { - int count = Core.get_property_int("playlist-count"); + int count = Core.GetPropertyInt("playlist-count"); if (count > 0) - Core.set_property_int("playlist-pos", count - 1); + Core.SetPropertyInt("playlist-pos", count - 1); } Thread.Sleep(2000); diff --git a/src/Misc/App.cs b/src/Misc/App.cs index e291917..4f1b4d5 100644 --- a/src/Misc/App.cs +++ b/src/Misc/App.cs @@ -120,7 +120,7 @@ namespace mpvnet get { return "Copyright (C) 2000-2021 mpv.net/mpv/mplayer\n" + $"mpv.net {Application.ProductVersion} ({File.GetLastWriteTime(Application.ExecutablePath).ToShortDateString()})\n" + - $"{Core.get_property_string("mpv-version")} ({File.GetLastWriteTime(Folder.Startup + "mpv-1.dll").ToShortDateString()})\nffmpeg {Core.get_property_string("ffmpeg-version")}\nMIT License"; + $"{Core.GetPropertyString("mpv-version")} ({File.GetLastWriteTime(Folder.Startup + "mpv-1.dll").ToShortDateString()})\nffmpeg {Core.GetPropertyString("ffmpeg-version")}\nMIT License"; } } @@ -157,15 +157,15 @@ namespace mpvnet { if (RememberVolume) { - Core.set_property_int("volume", Settings.Volume); - Core.set_property_string("mute", Settings.Mute); + Core.SetPropertyInt("volume", Settings.Volume); + Core.SetPropertyString("mute", Settings.Mute); } } static void Core_Shutdown() { - Settings.Volume = Core.get_property_int("volume"); - Settings.Mute = Core.get_property_string("mute"); + Settings.Volume = Core.GetPropertyInt("volume"); + Settings.Mute = Core.GetPropertyString("mute"); SettingsManager.Save(Settings); diff --git a/src/Misc/Commands.cs b/src/Misc/Commands.cs index 84ad293..6e6566e 100644 --- a/src/Misc/Commands.cs +++ b/src/Misc/Commands.cs @@ -33,7 +33,7 @@ namespace mpvnet case "scale-window": ScaleWindow(float.Parse(args[0], CultureInfo.InvariantCulture)); break; case "shell-execute": ProcessHelp.ShellExecute(args[0]); break; case "show-about": ShowDialog(typeof(AboutWindow)); break; - case "show-audio-devices": ShowTextWithEditor("audio-device-list", Core.get_property_osd_string("audio-device-list")); break; + case "show-audio-devices": ShowTextWithEditor("audio-device-list", Core.GetPropertyOsdString("audio-device-list")); break; case "show-command-palette": ShowCommandPalette(); break; case "show-commands": ShowCommands(); break; case "show-conf-editor": ShowDialog(typeof(ConfWindow)); break; @@ -42,7 +42,7 @@ namespace mpvnet case "show-history": ShowHistory(); break; case "show-info": ShowInfo(); break; case "show-input-editor": ShowDialog(typeof(InputWindow)); break; - case "show-keys": ShowTextWithEditor("input-key-list", Core.get_property_string("input-key-list").Replace(",", BR)); break; + case "show-keys": ShowTextWithEditor("input-key-list", Core.GetPropertyString("input-key-list").Replace(",", BR)); break; case "show-media-info": ShowMediaInfo(args); break; case "show-playlist": ShowPlaylist(); break; case "show-profiles": ShowTextWithEditor("profile-list", mpvHelp.GetProfiles()); break; @@ -94,17 +94,17 @@ namespace mpvnet if (dialog.ShowDialog() == DialogResult.OK) { - Core.command("stop"); + Core.Command("stop"); Thread.Sleep(500); if (Directory.Exists(dialog.SelectedPath + "\\BDMV")) { - Core.set_property_string("bluray-device", dialog.SelectedPath); + Core.SetPropertyString("bluray-device", dialog.SelectedPath); Core.LoadFiles(new[] { @"bd://" }, false, false); } else { - Core.set_property_string("dvd-device", dialog.SelectedPath); + Core.SetPropertyString("dvd-device", dialog.SelectedPath); Core.LoadFiles(new[] { @"dvd://" }, false, false); } } @@ -114,19 +114,19 @@ namespace mpvnet public static void PlaylistFirst() { - int pos = Core.get_property_int("playlist-pos"); + int pos = Core.GetPropertyInt("playlist-pos"); if (pos != 0) - Core.set_property_int("playlist-pos", 0); + Core.SetPropertyInt("playlist-pos", 0); } public static void PlaylistLast() { - int pos = Core.get_property_int("playlist-pos"); - int count = Core.get_property_int("playlist-count"); + int pos = Core.GetPropertyInt("playlist-pos"); + int count = Core.GetPropertyInt("playlist-count"); if (pos < count - 1) - Core.set_property_int("playlist-pos", count - 1); + Core.SetPropertyInt("playlist-pos", count - 1); } public static void ShowHistory() @@ -148,13 +148,13 @@ namespace mpvnet { string performer, title, album, genre, date, duration, text = ""; long fileSize = 0; - string path = Core.get_property_string("path"); + string path = Core.GetPropertyString("path"); if (path.Contains("://")) - path = Core.get_property_string("media-title"); + path = Core.GetPropertyString("media-title"); - int width = Core.get_property_int("video-params/w"); - int height = Core.get_property_int("video-params/h"); + int width = Core.GetPropertyInt("video-params/w"); + int height = Core.GetPropertyInt("video-params/h"); if (File.Exists(path)) { @@ -180,7 +180,7 @@ namespace mpvnet text += "Size: " + mediaInfo.GetInfo(MediaInfoStreamKind.General, "FileSize/String") + "\n"; text += "Type: " + path.Ext().ToUpper(); - Core.commandv("show-text", text, "5000"); + Core.CommandV("show-text", text, "5000"); return; } } @@ -194,16 +194,16 @@ namespace mpvnet "Size: " + mediaInfo.GetInfo(MediaInfoStreamKind.General, "FileSize/String") + "\n" + "Type: " + path.Ext().ToUpper(); - Core.commandv("show-text", text, "5000"); + Core.CommandV("show-text", text, "5000"); return; } } } - TimeSpan position = TimeSpan.FromSeconds(Core.get_property_number("time-pos")); - TimeSpan duration2 = TimeSpan.FromSeconds(Core.get_property_number("duration")); - string videoFormat = Core.get_property_string("video-format").ToUpper(); - string audioCodec = Core.get_property_string("audio-codec-name").ToUpper(); + TimeSpan position = TimeSpan.FromSeconds(Core.GetPropertyDouble("time-pos")); + TimeSpan duration2 = TimeSpan.FromSeconds(Core.GetPropertyDouble("duration")); + string videoFormat = Core.GetPropertyString("video-format").ToUpper(); + string audioCodec = Core.GetPropertyString("audio-codec-name").ToUpper(); text = path.FileName() + "\n" + FormatTime(position.TotalMinutes) + ":" + @@ -217,7 +217,7 @@ namespace mpvnet text += $"{videoFormat}\n{audioCodec}"; - Core.commandv("show-text", text, "5000"); + Core.CommandV("show-text", text, "5000"); string FormatTime(double value) => ((int)value).ToString("00"); } catch (Exception e) @@ -247,7 +247,7 @@ namespace mpvnet App.InvokeOnMainThread(new Action(() => { using (var d = new OpenFileDialog()) { - string path = Core.get_property_string("path"); + string path = Core.GetPropertyString("path"); if (File.Exists(path)) d.InitialDirectory = Path.GetDirectoryName(path); @@ -256,7 +256,7 @@ namespace mpvnet if (d.ShowDialog() == DialogResult.OK) foreach (string filename in d.FileNames) - Core.commandv("sub-add", filename); + Core.CommandV("sub-add", filename); } })); } @@ -266,14 +266,14 @@ namespace mpvnet App.InvokeOnMainThread(new Action(() => { using (var d = new OpenFileDialog()) { - string path = Core.get_property_string("path"); + string path = Core.GetPropertyString("path"); if (File.Exists(path)) d.InitialDirectory = Path.GetDirectoryName(path); d.Multiselect = true; if (d.ShowDialog() == DialogResult.OK) foreach (string i in d.FileNames) - Core.commandv("audio-add", i); + Core.CommandV("audio-add", i); } })); } @@ -285,21 +285,21 @@ namespace mpvnet if (len < 1) { - Core.commandv("show-text", "No audio tracks"); + Core.CommandV("show-text", "No audio tracks"); return; } - int aid = Core.get_property_int("aid"); + int aid = Core.GetPropertyInt("aid"); if (len > 1) { if (++aid > len) aid = 1; - Core.commandv("set", "aid", aid.ToString()); + Core.CommandV("set", "aid", aid.ToString()); } - Core.commandv("show-text", aid + "/" + len + ": " + audioTracks[aid - 1].Text.Substring(3), "5000"); + Core.CommandV("show-text", aid + "/" + len + ": " + audioTracks[aid - 1].Text.Substring(3), "5000"); } public static void ShowCommands() @@ -323,13 +323,13 @@ namespace mpvnet } }"; - string json = Core.get_property_string("command-list"); + string json = Core.GetPropertyString("command-list"); ShowTextWithEditor("command-list", PowerShell.InvokeAndReturnString(code, "json", json)); } public static void ShowProperties() { - var props = Core.get_property_string("property-list").Split(',').OrderBy(prop => prop); + var props = Core.GetPropertyString("property-list").Split(',').OrderBy(prop => prop); ShowTextWithEditor("property-list", string.Join(BR, props)); } @@ -351,12 +351,12 @@ namespace mpvnet return; if (duration == 0) - duration = Core.get_property_int("osd-duration"); + duration = Core.GetPropertyInt("osd-duration"); if (fontSize == 0) - fontSize = Core.get_property_int("osd-font-size"); + fontSize = Core.GetPropertyInt("osd-font-size"); - Core.command("show-text \"${osd-ass-cc/0}{\\\\fs" + fontSize + + Core.Command("show-text \"${osd-ass-cc/0}{\\\\fs" + fontSize + "}${osd-ass-cc/1}" + text + "\" " + duration); } @@ -389,8 +389,8 @@ namespace mpvnet static void ShowPlaylistInternal() { - int count = Core.get_property_int("playlist-count"); - string currentPath = Core.get_property_string("path"); + int count = Core.GetPropertyInt("playlist-count"); + string currentPath = Core.GetPropertyString("path"); CommandPaletteItem currentItem = null; if (count <= 0) @@ -401,11 +401,11 @@ namespace mpvnet for (int i = 0; i < count; i++) { int index = i; - string file = Core.get_property_string($"playlist/{i}/filename"); + string file = Core.GetPropertyString($"playlist/{i}/filename"); CommandPaletteItem item = new CommandPaletteItem() { Text = PathHelp.GetFileName(file), - Action = () => Core.set_property_int("playlist-pos", index) + Action = () => Core.SetPropertyInt("playlist-pos", index) }; items.Add(item); diff --git a/src/Misc/CorePlayer.cs b/src/Misc/CorePlayer.cs index 580cc22..efb2efa 100644 --- a/src/Misc/CorePlayer.cs +++ b/src/Misc/CorePlayer.cs @@ -104,6 +104,7 @@ namespace mpvnet public bool IsLogoVisible { set; get; } = true; public bool IsQuitNeeded { set; get; } = true; public bool KeepaspectWindow { get; set; } + public bool Paused { get; set; } public bool TaskbarProgress { get; set; } = true; public bool WasInitialSizeSet; public bool WindowMaximized { get; set; } @@ -130,16 +131,16 @@ namespace mpvnet if (App.IsStartedFromTerminal) { - set_property_string("terminal", "yes"); - set_property_string("input-terminal", "yes"); - set_property_string("msg-level", "osd/libass=fatal"); + SetPropertyString("terminal", "yes"); + SetPropertyString("input-terminal", "yes"); + SetPropertyString("msg-level", "osd/libass=fatal"); } - set_property_string("wid", MainForm.Hwnd.ToString()); - set_property_string("osc", "yes"); - set_property_string("force-window", "yes"); - set_property_string("config-dir", ConfigFolder); - set_property_string("config", "yes"); + SetPropertyString("wid", MainForm.Hwnd.ToString()); + SetPropertyString("osc", "yes"); + SetPropertyString("force-window", "yes"); + SetPropertyString("config-dir", ConfigFolder); + SetPropertyString("config", "yes"); ProcessCommandLine(true); mpv_error err = mpv_initialize(Handle); @@ -147,10 +148,10 @@ namespace mpvnet if (err < 0) throw new Exception("mpv_initialize error" + BR2 + GetError(err) + BR); - err = mpv_observe_property(Handle, 0, "video-rotate", mpv_format.MPV_FORMAT_INT64); - - if (err < 0) - throw new Exception("mpv_observe_property video-rotate error" + BR2 + GetError(err) + BR); + ObservePropertyInt("video-rotate", value => { + VideoRotate = value; + UpdateVideoSize("dwidth", "dheight"); + }); Initialized?.Invoke(); InvokeAsync(InitializedAsync); @@ -275,42 +276,42 @@ namespace mpvnet ps.Scripts.Add("Using namespace mpvnet; [Reflection.Assembly]::LoadWithPartialName('mpvnet')" + BR); string eventCode = @" - $eventJob = Register-ObjectEvent -InputObject $mp -EventName Event -Action { - foreach ($pair in $mp.EventHandlers) + $eventJob = Register-ObjectEvent -InputObject $mp -EventName Event -Action { + foreach ($pair in $mp.EventHandlers) + { + if ($pair.Key -eq $args[0]) { - if ($pair.Key -eq $args[0]) + if ($args.Length -gt 1) { - if ($args.Length -gt 1) - { - $args2 = $args[1] - } - - Invoke-Command -ScriptBlock $pair.Value -ArgumentList $args2 + $args2 = $args[1] } + + Invoke-Command -ScriptBlock $pair.Value -ArgumentList $args2 } } + } - $mp.RedirectStreams($eventJob) - "; + $mp.RedirectStreams($eventJob) + "; string propertyChangedCode = @" - $propertyChangedJob = Register-ObjectEvent -InputObject $mp -EventName PropertyChanged -Action { - foreach ($pair in $mp.PropChangedHandlers) + $propertyChangedJob = Register-ObjectEvent -InputObject $mp -EventName PropertyChanged -Action { + foreach ($pair in $mp.PropChangedHandlers) + { + if ($pair.Key -eq $args[0]) { - if ($pair.Key -eq $args[0]) + if ($args.Length -gt 1) { - if ($args.Length -gt 1) - { - $args2 = $args[1] - } - - Invoke-Command -ScriptBlock $pair.Value -ArgumentList $args2 + $args2 = $args[1] } + + Invoke-Command -ScriptBlock $pair.Value -ArgumentList $args2 } } + } - $mp.RedirectStreams($propertyChangedJob) - "; + $mp.RedirectStreams($propertyChangedJob) + "; ps.Scripts.Add(eventCode); ps.Scripts.Add(propertyChangedCode); @@ -326,7 +327,7 @@ namespace mpvnet void UpdateVideoSize(string w, string h) { - Size size = new Size(get_property_int(w), get_property_int(h)); + Size size = new Size(GetPropertyInt(w), GetPropertyInt(h)); if (VideoRotate == 90 || VideoRotate == 270) size = new Size(size.Height, size.Width); @@ -423,10 +424,10 @@ namespace mpvnet case mpv_event_id.MPV_EVENT_FILE_LOADED: { HideLogo(); - Duration = TimeSpan.FromSeconds(get_property_number("duration")); + Duration = TimeSpan.FromSeconds(GetPropertyDouble("duration")); if (App.StartSize == "video") - Core.WasInitialSizeSet = false; + WasInitialSizeSet = false; UpdateVideoSize("width", "height"); @@ -435,10 +436,10 @@ namespace mpvnet App.RunTask(new Action(() => ReadMetaData())); App.RunTask(new Action(() => { - string path = Core.get_property_string("path"); + string path = GetPropertyString("path"); if (path.Contains("://")) - path = Core.get_property_string("media-title"); + path = GetPropertyString("media-title"); WriteHistory(path); })); @@ -476,12 +477,6 @@ namespace mpvnet } else if (data.format == mpv_format.MPV_FORMAT_INT64) { - if (data.name == "video-rotate") - { - VideoRotate = Marshal.PtrToStructure(data.data); - UpdateVideoSize("dwidth", "dheight"); - } - lock (IntPropChangeActions) foreach (var pair in IntPropChangeActions) if (pair.Key == data.name) @@ -537,9 +532,11 @@ namespace mpvnet InvokeEvent(Idle, IdleAsync); 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: @@ -589,7 +586,7 @@ namespace mpvnet public void SetBluRayTitle(int id) { - Core.LoadFiles(new[] { @"bd://" + id }, false, false); + LoadFiles(new[] { @"bd://" + id }, false, false); } void InvokeEvent(Action action, Action asyncAction) @@ -636,16 +633,11 @@ namespace mpvnet void HideLogo() { - command("overlay-remove 0"); + Command("overlay-remove 0"); IsLogoVisible = false; } public void Command(string command, bool throwException = false) - { - this.command(command, throwException); - } - - public void command(string command, bool throwException = false) { mpv_error err = mpv_command_string(Handle, command); @@ -654,11 +646,6 @@ namespace mpvnet } public void CommandV(params string[] args) - { - commandv(args); - } - - public void commandv(params string[] args) { int count = args.Length + 1; IntPtr[] pointers = new IntPtr[count]; @@ -684,7 +671,7 @@ namespace mpvnet HandleError(err, true, "error executing command:", string.Join("\n", args)); } - public string expand(string value) + public string Expand(string value) { if (value == null) return ""; @@ -728,7 +715,7 @@ namespace mpvnet return ret; } - public bool get_property_bool(string name, bool throwException = false) + public bool GetPropertyBool(string name, bool throwException = false) { mpv_error err = mpv_get_property(Handle, GetUtf8Bytes(name), mpv_format.MPV_FORMAT_FLAG, out IntPtr lpBuffer); @@ -739,7 +726,7 @@ namespace mpvnet return lpBuffer.ToInt32() != 0; } - public void set_property_bool(string name, bool value, bool throwException = false) + public void SetPropertyBool(string name, bool value, bool throwException = false) { long val = value ? 1 : 0; mpv_error err = mpv_set_property(Handle, GetUtf8Bytes(name), mpv_format.MPV_FORMAT_FLAG, ref val); @@ -749,11 +736,6 @@ namespace mpvnet } public int GetPropertyInt(string name, bool throwException = false) - { - return get_property_int(name, throwException); - } - - public int get_property_int(string name, bool throwException = false) { mpv_error err = mpv_get_property(Handle, GetUtf8Bytes(name), mpv_format.MPV_FORMAT_INT64, out IntPtr lpBuffer); @@ -764,7 +746,7 @@ namespace mpvnet return lpBuffer.ToInt32(); } - public void set_property_int(string name, int value, bool throwException = false) + public void SetPropertyInt(string name, int value, bool throwException = false) { long val = value; mpv_error err = mpv_set_property(Handle, GetUtf8Bytes(name), mpv_format.MPV_FORMAT_INT64, ref val); @@ -773,7 +755,27 @@ namespace mpvnet HandleError(err, throwException, $"error setting property: {name} = {value}"); } - public double get_property_number(string name, bool throwException = false) + public long GetPropertyLong(string name, bool throwException = false) + { + mpv_error err = mpv_get_property(Handle, GetUtf8Bytes(name), + mpv_format.MPV_FORMAT_INT64, out IntPtr lpBuffer); + + if (err < 0) + HandleError(err, throwException, $"error getting property: {name}"); + + return lpBuffer.ToInt64(); + } + + public void SetPropertyLong(string name, long value, bool throwException = false) + { + long val = value; + mpv_error err = mpv_set_property(Handle, GetUtf8Bytes(name), mpv_format.MPV_FORMAT_INT64, ref val); + + if (err < 0) + HandleError(err, throwException, $"error setting property: {name} = {value}"); + } + + public double GetPropertyDouble(string name, bool throwException = false) { mpv_error err = mpv_get_property(Handle, GetUtf8Bytes(name), mpv_format.MPV_FORMAT_DOUBLE, out double value); @@ -784,12 +786,7 @@ namespace mpvnet return value; } - public void SetPropertyNumber(string name, double value, bool throwException = false) - { - set_property_number(name, value, throwException); - } - - public void set_property_number(string name, double value, bool throwException = false) + public void SetPropertyDouble(string name, double value, bool throwException = false) { double val = value; mpv_error err = mpv_set_property(Handle, GetUtf8Bytes(name), mpv_format.MPV_FORMAT_DOUBLE, ref val); @@ -799,11 +796,6 @@ namespace mpvnet } public string GetPropertyString(string name, bool throwException = false) - { - return get_property_string(name, throwException); - } - - public string get_property_string(string name, bool throwException = false) { mpv_error err = mpv_get_property(Handle, GetUtf8Bytes(name), mpv_format.MPV_FORMAT_STRING, out IntPtr lpBuffer); @@ -819,7 +811,7 @@ namespace mpvnet return ""; } - public void set_property_string(string name, string value, bool throwException = false) + public void SetPropertyString(string name, string value, bool throwException = false) { byte[] bytes = GetUtf8Bytes(value); mpv_error err = mpv_set_property(Handle, GetUtf8Bytes(name), mpv_format.MPV_FORMAT_STRING, ref bytes); @@ -828,7 +820,7 @@ namespace mpvnet HandleError(err, throwException, $"error setting property: {name} = " + value); } - public string get_property_osd_string(string name, bool throwException = false) + public string GetPropertyOsdString(string name, bool throwException = false) { mpv_error err = mpv_get_property(Handle, GetUtf8Bytes(name), mpv_format.MPV_FORMAT_OSD_STRING, out IntPtr lpBuffer); @@ -844,9 +836,9 @@ namespace mpvnet return ""; } - public string get_opt(string name, string defaultValue = "") + public string GetScriptOption(string name, string defaultValue = "") { - string value = get_property_string("script-opts"); + string value = GetPropertyString("script-opts"); if (string.IsNullOrEmpty(value)) return defaultValue; @@ -867,7 +859,7 @@ namespace mpvnet return defaultValue; } - public void observe_property_int(string name, Action action) + public void ObservePropertyInt(string name, Action action) { lock (IntPropChangeActions) { @@ -886,7 +878,7 @@ namespace mpvnet } } - public void observe_property_double(string name, Action action) + public void ObservePropertyDouble(string name, Action action) { lock (DoublePropChangeActions) { @@ -905,7 +897,7 @@ namespace mpvnet } } - public void observe_property_bool(string name, Action action) + public void ObservePropertyBool(string name, Action action) { lock (BoolPropChangeActions) { @@ -924,7 +916,7 @@ namespace mpvnet } } - public void observe_property_string(string name, Action action) + public void ObservePropertyString(string name, Action action) { lock (StringPropChangeActions) { @@ -943,7 +935,7 @@ namespace mpvnet } } - public void observe_property(string name, Action action) + public void ObserveProperty(string name, Action action) { lock (PropChangeActions) { @@ -1004,7 +996,7 @@ namespace mpvnet } else if (arg == "--audio-device=help") { - Console.WriteLine(Core.get_property_osd_string("audio-device-list")); + Console.WriteLine(GetPropertyOsdString("audio-device-list")); continue; } else if (arg == "--version") @@ -1014,12 +1006,12 @@ namespace mpvnet } else if (arg == "--input-keylist") { - Console.WriteLine(Core.get_property_string("input-key-list").Replace(",", BR)); + Console.WriteLine(GetPropertyString("input-key-list").Replace(",", BR)); continue; } else if (arg.StartsWith("--command=")) { - Core.command(arg.Substring(10)); + Command(arg.Substring(10)); continue; } } @@ -1049,18 +1041,18 @@ namespace mpvnet if (preInit && preInitProperties.Contains(left)) { - Core.ProcessProperty(left, right); + ProcessProperty(left, right); if (!App.ProcessProperty(left, right)) - set_property_string(left, right, true); + SetPropertyString(left, right, true); } else if (!preInit && !preInitProperties.Contains(left)) { - Core.ProcessProperty(left, right); + ProcessProperty(left, right); if (!App.ProcessProperty(left, right)) { - set_property_string(left, right, true); + SetPropertyString(left, right, true); if (left == "shuffle" && right == "yes") shuffle = true; @@ -1089,8 +1081,8 @@ namespace mpvnet if (shuffle) { - Core.command("playlist-shuffle"); - set_property_int("playlist-pos", 0); + Command("playlist-shuffle"); + SetPropertyInt("playlist-pos", 0); } if (files.Count == 0 || files[0].Contains("://")) @@ -1125,28 +1117,30 @@ namespace mpvnet if (file.Ext() == "iso") LoadISO(file); else if(SubtitleTypes.Contains(file.Ext())) - commandv("sub-add", file); + CommandV("sub-add", file); else if (file.Ext().Length != 3 && File.Exists(Path.Combine(file, "BDMV\\index.bdmv"))) { - Core.command("stop"); + Command("stop"); Thread.Sleep(500); - set_property_string("bluray-device", file); - commandv("loadfile", @"bd://"); + SetPropertyString("bluray-device", file); + CommandV("loadfile", @"bd://"); } else { if (i == 0 && !append) { - command("set pause no"); - commandv("loadfile", file); + CommandV("loadfile", file); + + if (Paused) + SetPropertyBool("pause", false); } else - commandv("loadfile", file, "append"); + CommandV("loadfile", file, "append"); } } - if (string.IsNullOrEmpty(get_property_string("path"))) - set_property_int("playlist-pos", 0); + if (string.IsNullOrEmpty(GetPropertyString("path"))) + SetPropertyInt("playlist-pos", 0); if (loadFolder && !append) App.RunTask(() => LoadFolder()); @@ -1164,25 +1158,25 @@ namespace mpvnet switch (result) { case DialogResult.Yes: - Core.command("stop"); + Command("stop"); Thread.Sleep(500); - Core.set_property_string("bluray-device", path); - Core.LoadFiles(new[] { @"bd://" }, false, false); + SetPropertyString("bluray-device", path); + LoadFiles(new[] { @"bd://" }, false, false); break; case DialogResult.No: - Core.command("stop"); + Command("stop"); Thread.Sleep(500); - Core.set_property_string("dvd-device", path); - Core.LoadFiles(new[] { @"dvd://" }, false, false); + SetPropertyString("dvd-device", path); + LoadFiles(new[] { @"dvd://" }, false, false); break; } } else { - Core.command("stop"); + Command("stop"); Thread.Sleep(500); - Core.set_property_string("bluray-device", path); - Core.LoadFiles(new[] { @"bd://" }, false, false); + SetPropertyString("bluray-device", path); + LoadFiles(new[] { @"bd://" }, false, false); } } @@ -1192,9 +1186,9 @@ namespace mpvnet return; Thread.Sleep(1000); - string path = get_property_string("path"); + string path = GetPropertyString("path"); - if (!File.Exists(path) || get_property_int("playlist-count") != 1) + if (!File.Exists(path) || GetPropertyInt("playlist-count") != 1) return; string dir = Environment.CurrentDirectory; @@ -1214,10 +1208,10 @@ namespace mpvnet files.Remove(path); foreach (string i in files) - commandv("loadfile", i, "append"); + CommandV("loadfile", i, "append"); if (index > 0) - commandv("playlist-move", "0", (index + 1).ToString()); + CommandV("playlist-move", "0", (index + 1).ToString()); } bool WasAviSynthLoaded; @@ -1260,7 +1254,7 @@ namespace mpvnet bool HistoryDiscard() { if (HistoryDiscardOption == null) - HistoryDiscardOption = Core.get_opt("history-discard"); + HistoryDiscardOption = GetScriptOption("history-discard"); if (string.IsNullOrEmpty(HistoryDiscardOption)) return false; @@ -1297,7 +1291,7 @@ namespace mpvnet BitmapData bd = bmp.LockBits(rect, ImageLockMode.ReadOnly, PixelFormat.Format32bppPArgb); int x = Convert.ToInt32((cr.Width - len) / (december ? 1.95 : 2)); int y = Convert.ToInt32(((cr.Height - len) / 2.0) * (december ? 0.85 : 0.9)); - commandv("overlay-add", "0", $"{x}", $"{y}", "&" + bd.Scan0.ToInt64().ToString(), "0", "bgra", bd.Width.ToString(), bd.Height.ToString(), bd.Stride.ToString()); + CommandV("overlay-add", "0", $"{x}", $"{y}", "&" + bd.Scan0.ToInt64().ToString(), "0", "bgra", bd.Width.ToString(), bd.Height.ToString(), bd.Stride.ToString()); bmp.UnlockBits(bd); IsLogoVisible = true; } @@ -1325,7 +1319,7 @@ namespace mpvnet void ReadMetaData() { - string path = get_property_string("path"); + string path = GetPropertyString("path"); if (!path.ToLowerEx().StartsWithEx("bd://")) lock (BluRayTitles) @@ -1334,32 +1328,32 @@ namespace mpvnet lock (MediaTracks) { MediaTracks.Clear(); - int trackListCount = Core.get_property_int("track-list/count"); + int trackListCount = GetPropertyInt("track-list/count"); if (path.ToLowerEx().Contains("://")) { for (int i = 0; i < trackListCount; i++) { - string type = Core.get_property_string($"track-list/{i}/type"); + string type = GetPropertyString($"track-list/{i}/type"); if (type == "audio") { MediaTrack track = new MediaTrack(); - Add(track, GetLanguage(Core.get_property_string($"track-list/{i}/lang"))); - Add(track, Core.get_property_string($"track-list/{i}/codec").ToUpperEx()); - Add(track, Core.get_property_int($"track-list/{i}/audio-channels") + " channels"); + Add(track, GetLanguage(GetPropertyString($"track-list/{i}/lang"))); + Add(track, GetPropertyString($"track-list/{i}/codec").ToUpperEx()); + Add(track, GetPropertyInt($"track-list/{i}/audio-channels") + " channels"); track.Text = "A: " + track.Text.Trim(' ', ','); track.Type = "a"; - track.ID = Core.get_property_int($"track-list/{i}/id"); + track.ID = GetPropertyInt($"track-list/{i}/id"); MediaTracks.Add(track); } else if (type == "sub") { MediaTrack track = new MediaTrack(); - Add(track, GetLanguage(Core.get_property_string($"track-list/{i}/lang"))); + Add(track, GetLanguage(GetPropertyString($"track-list/{i}/lang"))); track.Text = "S: " + track.Text.Trim(' ', ','); track.Type = "s"; - track.ID = Core.get_property_int($"track-list/{i}/id"); + track.ID = GetPropertyInt($"track-list/{i}/id"); MediaTracks.Add(track); } } @@ -1409,18 +1403,18 @@ namespace mpvnet for (int i = 0; i < trackListCount; i++) { - string type = Core.get_property_string($"track-list/{i}/type"); - string external = Core.get_property_string($"track-list/{i}/external"); + string type = GetPropertyString($"track-list/{i}/type"); + string external = GetPropertyString($"track-list/{i}/external"); if (type == "audio" && external == "yes") { MediaTrack track = new MediaTrack(); - Add(track, GetLanguage(Core.get_property_string($"track-list/{i}/lang"))); - Add(track, Core.get_property_string($"track-list/{i}/codec").ToUpperEx()); - Add(track, Core.get_property_int($"track-list/{i}/audio-channels") + " channels"); + Add(track, GetLanguage(GetPropertyString($"track-list/{i}/lang"))); + Add(track, GetPropertyString($"track-list/{i}/codec").ToUpperEx()); + Add(track, GetPropertyInt($"track-list/{i}/audio-channels") + " channels"); track.Text = "A: " + (track.Text.Trim(' ', ',') + ", External").Trim(' ', ','); track.Type = "a"; - track.ID = Core.get_property_int($"track-list/{i}/id"); + track.ID = GetPropertyInt($"track-list/{i}/id"); MediaTracks.Add(track); } } @@ -1444,26 +1438,26 @@ namespace mpvnet for (int i = 0; i < trackListCount; i++) { - string type = Core.get_property_string($"track-list/{i}/type"); - string external = Core.get_property_string($"track-list/{i}/external"); + string type = GetPropertyString($"track-list/{i}/type"); + string external = GetPropertyString($"track-list/{i}/external"); if (type == "sub" && external == "yes") { MediaTrack track = new MediaTrack(); - Add(track, GetLanguage(Core.get_property_string($"track-list/{i}/lang"))); + Add(track, GetLanguage(GetPropertyString($"track-list/{i}/lang"))); track.Text = "S: " + (track.Text.Trim(' ', ',') + ", External").Trim(' ', ','); track.Type = "s"; - track.ID = Core.get_property_int($"track-list/{i}/id"); + track.ID = GetPropertyInt($"track-list/{i}/id"); MediaTracks.Add(track); } } - int editionCount = get_property_int("edition-list/count"); + int editionCount = GetPropertyInt("edition-list/count"); for (int i = 0; i < editionCount; i++) { MediaTrack track = new MediaTrack(); - track.Text = "E: " + get_property_string($"edition-list/{i}/title"); + track.Text = "E: " + GetPropertyString($"edition-list/{i}/title"); track.Type = "e"; track.ID = i; MediaTracks.Add(track); @@ -1475,12 +1469,12 @@ namespace mpvnet lock (Chapters) { Chapters.Clear(); - int count = get_property_int("chapter-list/count"); + int count = GetPropertyInt("chapter-list/count"); for (int x = 0; x < count; x++) { - string text = get_property_string($"chapter-list/{x}/title"); - double time = get_property_number($"chapter-list/{x}/time"); + string text = GetPropertyString($"chapter-list/{x}/title"); + double time = GetPropertyDouble($"chapter-list/{x}/time"); Chapters.Add(new KeyValuePair(text, time)); } } diff --git a/src/Misc/GlobalHotkey.cs b/src/Misc/GlobalHotkey.cs index 53e0f35..e598b9b 100644 --- a/src/Misc/GlobalHotkey.cs +++ b/src/Misc/GlobalHotkey.cs @@ -86,7 +86,7 @@ namespace mpvnet public static void Execute(int id) { if (Commands.ContainsKey(id)) - Core.command(Commands[id]); + Core.Command(Commands[id]); } static int mpv_to_VK(string value) diff --git a/src/Misc/Help.cs b/src/Misc/Help.cs index ef1f6fa..2b66c64 100644 --- a/src/Misc/Help.cs +++ b/src/Misc/Help.cs @@ -127,7 +127,7 @@ namespace mpvnet '' }"; - string json = Core.get_property_string("profile-list"); + string json = Core.GetPropertyString("profile-list"); return PowerShell.InvokeAndReturnString(code, "json", json).Trim(); } @@ -139,19 +139,19 @@ namespace mpvnet $item.codec + ' - ' + $item.description }"; - string json = Core.get_property_string("decoder-list"); + string json = Core.GetPropertyString("decoder-list"); return PowerShell.InvokeAndReturnString(code, "json", json).Trim(); } public static string GetProtocols() { - string list = Core.get_property_string("protocol-list"); + string list = Core.GetPropertyString("protocol-list"); return string.Join(BR, list.Split(',').OrderBy(a => a)); } public static string GetDemuxers() { - string list = Core.get_property_string("demuxer-lavf-list"); + string list = Core.GetPropertyString("demuxer-lavf-list"); return string.Join(BR, list.Split(',').OrderBy(a => a)); } } diff --git a/src/Misc/Misc.cs b/src/Misc/Misc.cs index 97a84d8..17f796f 100644 --- a/src/Misc/Misc.cs +++ b/src/Misc/Misc.cs @@ -247,7 +247,7 @@ namespace mpvnet .Select(i => new CommandPaletteItem() { Text = i.Display, SecondaryText = i.Input, - Action = () => Core.command(i.Command) + Action = () => Core.Command(i.Command) }); } } diff --git a/src/Misc/PowerShell.cs b/src/Misc/PowerShell.cs index 4793715..e8f1589 100644 --- a/src/Misc/PowerShell.cs +++ b/src/Misc/PowerShell.cs @@ -109,46 +109,46 @@ namespace mpvnet } } - public void commandv(params string[] args) => Core.commandv(args); + public void CommandV(params string[] args) => Core.CommandV(args); - public void command(string command) => Core.command(command); + public void Command(string command) => Core.Command(command); - public bool get_property_bool(string name) => Core.get_property_bool(name); + public bool GetPropertyBool(string name) => Core.GetPropertyBool(name); - public void set_property_bool(string name, bool value) => Core.set_property_bool(name, value); + public void SetPropertyBool(string name, bool value) => Core.SetPropertyBool(name, value); - public int get_property_int(string name) => Core.get_property_int(name); + public int GetPropertyInt(string name) => Core.GetPropertyInt(name); - public void set_property_int(string name, int value) => Core.set_property_int(name, value); + public void SetPropertyInt(string name, int value) => Core.SetPropertyInt(name, value); - public double get_property_number(string name) => Core.get_property_number(name); + public double GetPropertyDouble(string name) => Core.GetPropertyDouble(name); - public void set_property_number(string name, double value) => Core.set_property_number(name, value); + public void SetPropertyDouble(string name, double value) => Core.SetPropertyDouble(name, value); - public string get_property_string(string name) => Core.get_property_string(name); + public string GetPropertyString(string name) => Core.GetPropertyString(name); - public void set_property_string(string name, string value) => Core.set_property_string(name, value); + public void SetPropertyString(string name, string value) => Core.SetPropertyString(name, value); - public void observe_property(string name, string type, ScriptBlock sb) + public void ObserveProperty(string name, string type, ScriptBlock sb) { PropChangedHandlers.Add(new KeyValuePair(name, sb)); switch (type) { case "bool": case "boolean": - Core.observe_property_bool(name, value => App.RunTask(() => PropertyChanged.Invoke(name, value))); + Core.ObservePropertyBool(name, value => App.RunTask(() => PropertyChanged.Invoke(name, value))); break; case "string": - Core.observe_property_string(name, value => App.RunTask(() => PropertyChanged.Invoke(name, value))); + Core.ObservePropertyString(name, value => App.RunTask(() => PropertyChanged.Invoke(name, value))); break; case "int": case "integer": - Core.observe_property_int(name, value => App.RunTask(() => PropertyChanged.Invoke(name, value))); + Core.ObservePropertyInt(name, value => App.RunTask(() => PropertyChanged.Invoke(name, value))); break; case "float": case "double": - Core.observe_property_double(name, value => App.RunTask(() => PropertyChanged.Invoke(name, value))); + Core.ObservePropertyDouble(name, value => App.RunTask(() => PropertyChanged.Invoke(name, value))); break; case "nil": case "none": case "native": - Core.observe_property(name, () => App.RunTask(() => PropertyChanged.Invoke(name, null))); + Core.ObserveProperty(name, () => App.RunTask(() => PropertyChanged.Invoke(name, null))); break; default: App.ShowError("Invalid Type", "Valid types are: bool or boolean, string, int or integer, float or double, nil or none or native"); @@ -156,7 +156,7 @@ namespace mpvnet } } - public void register_event(string name, ScriptBlock sb) + public void RegisterEvent(string name, ScriptBlock sb) { EventHandlers.Add(new KeyValuePair(name, sb)); diff --git a/src/Misc/UpdateCheck.cs b/src/Misc/UpdateCheck.cs index 7c2c598..939b142 100644 --- a/src/Misc/UpdateCheck.cs +++ b/src/Misc/UpdateCheck.cs @@ -68,7 +68,7 @@ namespace mpvnet proc.Start(); } - Core.command("quit"); + Core.Command("quit"); } App.Settings.UpdateCheckVersion = onlineVersion.ToString(); diff --git a/src/Scripts/C-Sharp/key-binding.cs b/src/Scripts/C-Sharp/key-binding.cs index af414ce..8ba87b1 100644 --- a/src/Scripts/C-Sharp/key-binding.cs +++ b/src/Scripts/C-Sharp/key-binding.cs @@ -12,8 +12,8 @@ class Script string content = "ctrl+w script-message my-message-1 my-argument-1"; string sectionName = Assembly.GetExecutingAssembly().GetName().Name; CorePlayer core = Global.Core; - core.commandv("define-section", sectionName, content, "force"); - core.commandv("enable-section", sectionName); + core.CommandV("define-section", sectionName, content, "force"); + core.CommandV("enable-section", sectionName); core.ClientMessage += ClientMessage; } diff --git a/src/Scripts/C-Sharp/observe-property-and-draw-text.cs b/src/Scripts/C-Sharp/observe-property-and-draw-text.cs index 8a03e73..88207a5 100644 --- a/src/Scripts/C-Sharp/observe-property-and-draw-text.cs +++ b/src/Scripts/C-Sharp/observe-property-and-draw-text.cs @@ -11,11 +11,11 @@ class Script public Script() { Core = Global.Core; - Core.observe_property_bool("fullscreen", FullscreenChange); + Core.ObservePropertyBool("fullscreen", FullscreenChange); } void FullscreenChange(bool value) { - Core.commandv("show-text", "fullscreen: " + value); + Core.CommandV("show-text", "fullscreen: " + value); } } diff --git a/src/Scripts/C-Sharp/pause-when-minimize.cs b/src/Scripts/C-Sharp/pause-when-minimize.cs index 0981dc8..c64c292 100644 --- a/src/Scripts/C-Sharp/pause-when-minimize.cs +++ b/src/Scripts/C-Sharp/pause-when-minimize.cs @@ -25,11 +25,11 @@ class Script { if (MainForm.WindowState == FormWindowState.Minimized) { - WasPlaying = !Core.get_property_bool("pause"); + WasPlaying = !Core.GetPropertyBool("pause"); if (WasPlaying) { - Core.set_property_bool("pause", true, true); + Core.SetPropertyBool("pause", true, true); WasPaused = true; } } @@ -37,7 +37,7 @@ class Script { if (WasPaused) { - Core.set_property_bool("pause", false, true); + Core.SetPropertyBool("pause", false, true); WasPaused = false; } } diff --git a/src/Scripts/C-Sharp/rate-file.cs b/src/Scripts/C-Sharp/rate-file.cs index 47ee256..0f4cfed 100644 --- a/src/Scripts/C-Sharp/rate-file.cs +++ b/src/Scripts/C-Sharp/rate-file.cs @@ -69,13 +69,13 @@ class Script if (int.TryParse(args[1], out rating)) { - string path = Core.get_property_string("path"); + string path = Core.GetPropertyString("path"); if (!File.Exists(path)) return; Dic[path] = rating; - Core.commandv("show-text", "Rating: " + rating); + Core.CommandV("show-text", "Rating: " + rating); } } } diff --git a/src/Scripts/C-Sharp/switch-profile-context-menu.cs b/src/Scripts/C-Sharp/switch-profile-context-menu.cs index 4c768e0..ffdf493 100644 --- a/src/Scripts/C-Sharp/switch-profile-context-menu.cs +++ b/src/Scripts/C-Sharp/switch-profile-context-menu.cs @@ -31,7 +31,7 @@ class Script foreach (MediaTrack track in editionTracks) { MenuItem mi = new MenuItem(track.Text); - mi.Action = () => { Core.commandv("set", "edition", track.ID.ToString()); }; + mi.Action = () => { Core.CommandV("set", "edition", track.ID.ToString()); }; mi.Checked = Core.Edition == track.ID; menuItem.DropDownItems.Add(mi); } diff --git a/src/Scripts/PowerShell/open-file-dialog.ps1 b/src/Scripts/PowerShell/open-file-dialog.ps1 index e1f804f..050bcc5 100644 --- a/src/Scripts/PowerShell/open-file-dialog.ps1 +++ b/src/Scripts/PowerShell/open-file-dialog.ps1 @@ -17,4 +17,4 @@ $code = { } } -$mp.register_event("client-message", $code) +$mp.RegisterEvent("client-message", $code) diff --git a/src/Scripts/PowerShell/pause-when-minimize.ps1 b/src/Scripts/PowerShell/pause-when-minimize.ps1 index 7b15ba1..ff035bc 100644 --- a/src/Scripts/PowerShell/pause-when-minimize.ps1 +++ b/src/Scripts/PowerShell/pause-when-minimize.ps1 @@ -1,13 +1,13 @@ $code = { $isMinimized = $args[0] - $isPaused = $mp.get_property_bool('pause') + $isPaused = $mp.GetPropertyBool('pause') if ($isMinimized) { if (-not $isPaused) { - $mp.set_property_bool('pause', $true) + $mp.SetPropertyBool('pause', $true) $script:wasPaused = $true } } @@ -15,11 +15,11 @@ $code = { { if ($script:wasPaused -and $isPaused) { - $mp.set_property_bool('pause', $false) + $mp.SetPropertyBool('pause', $false) } $script:wasPaused = $false } } -$mp.observe_property('window-minimized', 'bool', $code) +$mp.ObserveProperty('window-minimized', 'bool', $code) diff --git a/src/Scripts/PowerShell/show-in-file-explorer.ps1 b/src/Scripts/PowerShell/show-in-file-explorer.ps1 index b6853c8..526df67 100644 --- a/src/Scripts/PowerShell/show-in-file-explorer.ps1 +++ b/src/Scripts/PowerShell/show-in-file-explorer.ps1 @@ -6,9 +6,8 @@ $code = { if ($args[0] -eq 'show-in-file-explorer') { - # probably works only with shell execute for which powershell has no built-in support - [Diagnostics.Process]::Start('explorer.exe', '/n, /select, "' + $mp.get_property_string('path') + '"') + Start-Process explorer.exe '/n,','/select,',"$($mp.GetPropertyString('path'))" } } -$mp.register_event("client-message", $code) +$mp.RegisterEvent("client-message", $code) diff --git a/src/WPF/ConfWindow.xaml.cs b/src/WPF/ConfWindow.xaml.cs index a413528..8f90c66 100644 --- a/src/WPF/ConfWindow.xaml.cs +++ b/src/WPF/ConfWindow.xaml.cs @@ -90,7 +90,7 @@ namespace mpvnet try { - Core.set_property_string(item.Name, item.Value, true); + Core.SetPropertyString(item.Name, item.Value, true); } catch (Exception ex) { diff --git a/src/WinForms/MainForm.cs b/src/WinForms/MainForm.cs index fd90765..416d780 100644 --- a/src/WinForms/MainForm.cs +++ b/src/WinForms/MainForm.cs @@ -49,22 +49,22 @@ namespace mpvnet Core.Idle += Core_Idle; Core.Seek += () => UpdateProgressBar(); - Core.observe_property("window-maximized", PropChangeWindowMaximized); - Core.observe_property("window-minimized", PropChangeWindowMinimized); + Core.ObserveProperty("window-maximized", PropChangeWindowMaximized); + Core.ObserveProperty("window-minimized", PropChangeWindowMinimized); - Core.observe_property_bool("border", PropChangeBorder); - Core.observe_property_bool("fullscreen", PropChangeFullscreen); - Core.observe_property_bool("keepaspect-window", value => Core.KeepaspectWindow = value); - Core.observe_property_bool("ontop", PropChangeOnTop); - Core.observe_property_bool("pause", PropChangePause); + Core.ObservePropertyBool("border", PropChangeBorder); + Core.ObservePropertyBool("fullscreen", PropChangeFullscreen); + Core.ObservePropertyBool("keepaspect-window", value => Core.KeepaspectWindow = value); + Core.ObservePropertyBool("ontop", PropChangeOnTop); + Core.ObservePropertyBool("pause", PropChangePause); - Core.observe_property_string("sid", PropChangeSid); - Core.observe_property_string("aid", PropChangeAid); - Core.observe_property_string("vid", PropChangeVid); + Core.ObservePropertyString("sid", PropChangeSid); + Core.ObservePropertyString("aid", PropChangeAid); + Core.ObservePropertyString("vid", PropChangeVid); - Core.observe_property_string("title", PropChangeTitle); + Core.ObservePropertyString("title", PropChangeTitle); - Core.observe_property_int("edition", PropChangeEdition); + Core.ObservePropertyInt("edition", PropChangeEdition); if (Core.GPUAPI != "vulkan") Core.ProcessCommandLine(false); @@ -146,7 +146,7 @@ namespace mpvnet (int)(Core.VideoSize.Width * scale), (int)Math.Ceiling(Core.VideoSize.Height * scale), Screen.FromControl(this), false); - Core.command($"show-text \"window-scale {scale.ToString(CultureInfo.InvariantCulture)}\""); + Core.Command($"show-text \"window-scale {scale.ToString(CultureInfo.InvariantCulture)}\""); })); } @@ -199,7 +199,7 @@ namespace mpvnet foreach (MediaTrack track in vidTracks) { MenuItem mi = new MenuItem(track.Text); - mi.Action = () => Core.commandv("set", "vid", track.ID.ToString()); + mi.Action = () => Core.CommandV("set", "vid", track.ID.ToString()); mi.Checked = Core.VID == track.ID.ToString(); trackMenuItem.DropDownItems.Add(mi); } @@ -210,7 +210,7 @@ namespace mpvnet foreach (MediaTrack track in audTracks) { MenuItem mi = new MenuItem(track.Text); - mi.Action = () => Core.commandv("set", "aid", track.ID.ToString()); + mi.Action = () => Core.CommandV("set", "aid", track.ID.ToString()); mi.Checked = Core.AID == track.ID.ToString(); trackMenuItem.DropDownItems.Add(mi); } @@ -221,7 +221,7 @@ namespace mpvnet foreach (MediaTrack track in subTracks) { MenuItem mi = new MenuItem(track.Text); - mi.Action = () => Core.commandv("set", "sid", track.ID.ToString()); + mi.Action = () => Core.CommandV("set", "sid", track.ID.ToString()); mi.Checked = Core.SID == track.ID.ToString(); trackMenuItem.DropDownItems.Add(mi); } @@ -229,7 +229,7 @@ namespace mpvnet if (subTracks.Length > 0) { MenuItem mi = new MenuItem("S: No subtitles"); - mi.Action = () => Core.commandv("set", "sid", "no"); + mi.Action = () => Core.CommandV("set", "sid", "no"); mi.Checked = Core.SID == "no"; trackMenuItem.DropDownItems.Add(mi); } @@ -240,7 +240,7 @@ namespace mpvnet foreach (MediaTrack track in ediTracks) { MenuItem mi = new MenuItem(track.Text); - mi.Action = () => Core.commandv("set", "edition", track.ID.ToString()); + mi.Action = () => Core.CommandV("set", "edition", track.ID.ToString()); mi.Checked = Core.Edition == track.ID; trackMenuItem.DropDownItems.Add(mi); } @@ -259,7 +259,7 @@ namespace mpvnet { MenuItem mi = new MenuItem(pair.Key); mi.ShortcutKeyDisplayString = TimeSpan.FromSeconds(pair.Value).ToString().Substring(0, 8) + " "; - mi.Action = () => Core.commandv("seek", pair.Value.ToString(CultureInfo.InvariantCulture), "absolute"); + mi.Action = () => Core.CommandV("seek", pair.Value.ToString(CultureInfo.InvariantCulture), "absolute"); chaptersMenuItem.DropDownItems.Add(mi); } } @@ -585,7 +585,7 @@ namespace mpvnet MenuItem menuItem = ContextMenu.Add(item.Path.Replace("&", "&&"), () => { try { - Core.command(item.Command); + Core.Command(item.Command); } catch (Exception ex) { Msg.ShowException(ex); } @@ -598,10 +598,10 @@ namespace mpvnet void Core_FileLoaded() { - string path = Core.get_property_string("path"); + string path = Core.GetPropertyString("path"); BeginInvoke(new Action(() => { - Text = Core.expand(Title); + Text = Core.Expand(Title); int interval = (int)(Core.Duration.TotalMilliseconds / 100); @@ -624,7 +624,7 @@ namespace mpvnet App.Settings.RecentFiles.RemoveAt(App.RecentCount); } - void SetTitle() => BeginInvoke(new Action(() => Text = Core.expand(Title))); + void SetTitle() => BeginInvoke(new Action(() => Text = Core.Expand(Title))); public void Voodoo() { @@ -719,7 +719,7 @@ namespace mpvnet if (Environment.TickCount - LastCycleFullscreen > 500) { Point pos = PointToClient(Cursor.Position); - Core.command($"mouse {pos.X} {pos.Y}"); + Core.Command($"mouse {pos.X} {pos.Y}"); } if (CursorHelp.IsPosDifferent(LastCursorPosition)) @@ -727,12 +727,12 @@ namespace mpvnet break; case 0x2a3: // WM_MOUSELEAVE //osc won't auto hide after mouse left window in borderless mode - Core.command($"mouse {ClientSize.Width / 2} {ClientSize.Height / 3}"); + Core.Command($"mouse {ClientSize.Width / 2} {ClientSize.Height / 3}"); break; case 0x203: // WM_LBUTTONDBLCLK { Point pos = PointToClient(Cursor.Position); - Core.command($"mouse {pos.X} {pos.Y} 0 double"); + Core.Command($"mouse {pos.X} {pos.Y} 0 double"); } break; case 0x02E0: // WM_DPICHANGED @@ -786,10 +786,10 @@ namespace mpvnet break; case "queue": foreach (string file in args) - Core.commandv("loadfile", file, "append"); + Core.CommandV("loadfile", file, "append"); break; case "command": - Core.command(args[0]); + Core.Command(args[0]); break; } @@ -828,7 +828,7 @@ namespace mpvnet void UpdateProgressBar() { if (Core.TaskbarProgress && Taskbar != null) - Taskbar.SetValue(Core.get_property_number("time-pos"), Core.Duration.TotalSeconds); + Taskbar.SetValue(Core.GetPropertyDouble("time-pos"), Core.Duration.TotalSeconds); } void PropChangeOnTop(bool value) => BeginInvoke(new Action(() => TopMost = value)); @@ -850,7 +850,7 @@ namespace mpvnet BeginInvoke(new Action(() => { - Core.WindowMaximized = Core.get_property_bool("window-maximized"); + Core.WindowMaximized = Core.GetPropertyBool("window-maximized"); if (Core.WindowMaximized && WindowState != FormWindowState.Maximized) WindowState = FormWindowState.Maximized; @@ -866,7 +866,7 @@ namespace mpvnet BeginInvoke(new Action(() => { - Core.WindowMinimized = Core.get_property_bool("window-minimized"); + Core.WindowMinimized = Core.GetPropertyBool("window-minimized"); if (Core.WindowMinimized && WindowState != FormWindowState.Minimized) WindowState = FormWindowState.Minimized; @@ -923,7 +923,7 @@ namespace mpvnet base.OnShown(e); if (WindowState == FormWindowState.Maximized) - Core.set_property_bool("window-maximized", true); + Core.SetPropertyBool("window-maximized", true); if (Core.GPUAPI == "vulkan") Core.ProcessCommandLine(false); @@ -961,16 +961,16 @@ namespace mpvnet { if (WindowState == FormWindowState.Minimized) { - Core.set_property_bool("window-minimized", true); + Core.SetPropertyBool("window-minimized", true); } else if (WindowState == FormWindowState.Normal) { - Core.set_property_bool("window-maximized", false); - Core.set_property_bool("window-minimized", false); + Core.SetPropertyBool("window-maximized", false); + Core.SetPropertyBool("window-minimized", false); } else if (WindowState == FormWindowState.Maximized) { - Core.set_property_bool("window-maximized", true); + Core.SetPropertyBool("window-maximized", true); } } } @@ -980,7 +980,7 @@ namespace mpvnet base.OnFormClosing(e); if (Core.IsQuitNeeded) - Core.commandv("quit"); + Core.CommandV("quit"); if (!Core.ShutdownAutoResetEvent.WaitOne(10000)) Msg.ShowError("Shutdown thread failed to complete within 10 seconds."); @@ -999,7 +999,7 @@ namespace mpvnet } if (Width - e.Location.X < 10 && e.Location.Y < 10) - Core.commandv("quit"); + Core.CommandV("quit"); } protected override void OnMove(EventArgs e)