From 8f7aa7db2d75d8554ddcad1c9ea9f16798aec479 Mon Sep 17 00:00:00 2001 From: Frank Skare Date: Wed, 24 Apr 2019 23:59:34 +0200 Subject: [PATCH] - --- README.md | 11 +++++++---- mpv.net/MainForm.cs | 4 ++-- mpv.net/Misc.cs | 17 +++++++++++++++++ mpv.net/Windows/InputWindow.xaml.cs | 8 -------- mpv.net/mp.cs | 9 +++++---- 5 files changed, 31 insertions(+), 18 deletions(-) diff --git a/README.md b/README.md index 5b34171..f963835 100644 --- a/README.md +++ b/README.md @@ -97,12 +97,15 @@ Examples: ### 3.2 (2019-0?-??) -- mpvInputEdit and mpvConfEdit were discontinued and merged into mpvnet -- portable mode: in case no config folder exists mpvnet will ask where the config folder - should be created (portable or appdata) +- mpvInputEdit and mpvConfEdit were discontinued and merged into + mpvnet because separate apps were to difficult to work with +- portable mode: in case no config folder exists and the + startup folder has write access mpvnet will ask where + the config folder should be created (portable or appdata) - there was an issue causing keys not working after a modal window was shown - there was a crash when no script folder existed in the conf folder -- MediaInfo and libmpv were updated +- MediaInfo, youtube-dl and libmpv were updated +- a new JavaScript example script was added. [OSC always on for audio files](https://github.com/stax76/mpv.net/wiki/Scripting#osc-always-on-for-audio-files). ### 3.1 (2019-04-23) diff --git a/mpv.net/MainForm.cs b/mpv.net/MainForm.cs index c70efbe..8183462 100644 --- a/mpv.net/MainForm.cs +++ b/mpv.net/MainForm.cs @@ -536,7 +536,7 @@ namespace mpvnet protected override void OnShown(EventArgs e) { base.OnShown(e); - if ((MpvNetDarkMode == "system" && Misc.IsDarkTheme) || MpvNetDarkMode == "always") + if ((MpvNetDarkMode == "system" && Sys.IsDarkTheme) || MpvNetDarkMode == "always") ToolStripRendererEx.ColorTheme = Color.Black; ContextMenu = new ContextMenuStripEx(components); ContextMenu.Opened += ContextMenu_Opened; @@ -574,7 +574,7 @@ namespace mpvnet { RegistryHelp.SetValue("HKCU\\Software\\" + Application.ProductName, "LastYouTubeURL", clipboard); - if (Msg.ShowQuestion("Play YouTube URL?") == MsgResult.OK) + if (Msg.ShowQuestion("Play YouTube URL?", clipboard) == MsgResult.OK) mp.LoadURL(clipboard); } } diff --git a/mpv.net/Misc.cs b/mpv.net/Misc.cs index 3a2e550..d8bc03c 100644 --- a/mpv.net/Misc.cs +++ b/mpv.net/Misc.cs @@ -20,7 +20,10 @@ namespace mpvnet public static string GetFilter(IEnumerable values) => "*." + String.Join(";*.", values) + "|*." + String.Join(";*.", values) + "|All Files|*.*"; + } + public class Sys + { public static bool IsDarkTheme { get { object value = Registry.GetValue(@"HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Themes\Personalize", "AppsUseLightTheme", 1); @@ -28,6 +31,20 @@ namespace mpvnet return (int)value == 0; } } + + public static bool IsDirectoryWritable(string dirPath) + { + try + { + using (FileStream fs = File.Create(Path.Combine(dirPath, + Path.GetRandomFileName()), 1, FileOptions.DeleteOnClose)) + { } + return true; + } + catch + { } + return false; + } } public class StringLogicalComparer : IComparer, IComparer diff --git a/mpv.net/Windows/InputWindow.xaml.cs b/mpv.net/Windows/InputWindow.xaml.cs index dd4285c..a1cc7e8 100644 --- a/mpv.net/Windows/InputWindow.xaml.cs +++ b/mpv.net/Windows/InputWindow.xaml.cs @@ -83,14 +83,6 @@ namespace mpvnet private void Window_Closed(object sender, EventArgs e) { - string backupDir = Path.GetDirectoryName(mp.InputConfPath) + "\\backup\\"; - - if (!Directory.Exists(backupDir)) - Directory.CreateDirectory(backupDir); - - if (File.Exists(mp.InputConfPath)) - File.Copy(mp.InputConfPath, backupDir + "input conf " + DateTime.Now.ToString("yyyy-MM-dd HH-mm") + ".conf", true); - string text = Properties.Resources.inputConfHeader + "\r\n"; foreach (InputItem item in InputItem.InputItems) diff --git a/mpv.net/mp.cs b/mpv.net/mp.cs index e0171d8..3611be6 100644 --- a/mpv.net/mp.cs +++ b/mpv.net/mp.cs @@ -78,7 +78,8 @@ namespace mpvnet string portableFolder = Application.StartupPath + "\\portable_config\\"; string appdataFolder = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\mpv\\"; - if (!Directory.Exists(portableFolder) && !Directory.Exists(appdataFolder)) + if (!Directory.Exists(appdataFolder) && !Directory.Exists(portableFolder) && + Sys.IsDirectoryWritable(Application.StartupPath)) { using (TaskDialog td = new TaskDialog()) { @@ -312,11 +313,11 @@ namespace mpvnet break; case mpv_event_id.MPV_EVENT_PLAYBACK_RESTART: PlaybackRestart?.Invoke(); - Size s = new Size(get_property_int("dwidth"), get_property_int("dheight")); + Size vidSize = new Size(get_property_int("dwidth"), get_property_int("dheight")); - if (VideoSize != s && s != Size.Empty) + if (VideoSize != vidSize && vidSize != Size.Empty) { - VideoSize = s; + VideoSize = vidSize; VideoSizeChanged?.Invoke(); }