From f0546485cfc7146f0bc54b3b60b2738e56b212b8 Mon Sep 17 00:00:00 2001 From: Frank Skare Date: Thu, 8 Aug 2019 18:45:34 +0200 Subject: [PATCH] Open > Open DVD/Blu-ray Drive/Folder --- Changelog.md | 4 +++ Manual.md | 8 +++-- extensions/RatingExtension/RatingExtension.cs | 2 +- mpv.net/Misc/Command.cs | 30 +++++++++++++++++-- mpv.net/Resources/inputConf.txt | 21 ++++++------- mpv.net/Resources/mpvConfToml.txt | 4 +-- mpv.net/WinForms/MainForm.cs | 4 ++- 7 files changed, 55 insertions(+), 18 deletions(-) diff --git a/Changelog.md b/Changelog.md index 348736f..7936738 100644 --- a/Changelog.md +++ b/Changelog.md @@ -1,3 +1,7 @@ +### + +- added new feature: Open > Open DVD/Blu-ray Drive/Folder... + ### 5.2.1.3 - in the config dialog the description for keep-open was corrected diff --git a/Manual.md b/Manual.md index f6d6497..ae42b01 100644 --- a/Manual.md +++ b/Manual.md @@ -149,9 +149,11 @@ The Open Files menu entry is one way to open files in mpv.net, it supports multi Another way to open files is the command line, it is used by the Windows File Explorer if file associations exist. +When mpv.net is started from a terminal such as PowerShell, mpv.net attaches to the terminal and outputs status and debug messages. + A third way is to drag and drop files on the main window. -Whenever the control key is pressed when files are opened, the playlist is not cleared but the files are appended to the playlist. +Whenever the control key is pressed when files or URLs are opened, the playlist is not cleared but the files or URLs are appended to the playlist. This works in all mpv.net features that open files or URLs. ### Open > Open URL @@ -159,7 +161,9 @@ The Open URL menu entry can be used to open URLs for example from YouTube. mpv.net monitors the Windows clipboard and ask if URLs should be played in case it finds a URL in the clipboard. This feature uses a keyword whitelist that can be configured in the config editor. -Whenever the control key is pressed when URLs are opened, the playlist is not cleared but the URLs are appended to the playlist. +When mpv.net is started from a terminal such as PowerShell, mpv.net attaches to the terminal and outputs status and debug messages. + +Whenever the control key is pressed when files or URLs are opened, the playlist is not cleared but the files or URLs are appended to the playlist. This works in all mpv.net features that open files or URLs. ### Open > Show media search diff --git a/extensions/RatingExtension/RatingExtension.cs b/extensions/RatingExtension/RatingExtension.cs index a51dd5c..ddcd32e 100644 --- a/extensions/RatingExtension/RatingExtension.cs +++ b/extensions/RatingExtension/RatingExtension.cs @@ -30,7 +30,7 @@ namespace RatingExtension // the assembly name must end with 'Extension' { string filepath = i.Key; int rating = i.Value; - if (String.IsNullOrEmpty(filepath) || ! File.Exists(filepath)) + if (String.IsNullOrEmpty(filepath) || !File.Exists(filepath)) return; string basename = Path.GetFileNameWithoutExtension(filepath); diff --git a/mpv.net/Misc/Command.cs b/mpv.net/Misc/Command.cs index c803813..2cb68e3 100644 --- a/mpv.net/Misc/Command.cs +++ b/mpv.net/Misc/Command.cs @@ -16,11 +16,13 @@ namespace mpvnet { switch (id) { + case "open-files": OpenFiles(args); break; + case "open-url": OpenURL(); break; + case "open-optical-media": Open_DVD_Or_BD_Folder(); break; case "manage-file-associations": ManageFileAssociations(); break; // deprecated 2019 case "cycle-audio": CycleAudio(); break; case "load-audio": LoadAudio(); break; case "load-sub": LoadSubtitle(); break; - case "open-url": OpenURL(); break; case "execute-mpv-command": ExecuteMpvCommand(); break; case "show-history": ShowHistory(); break; case "show-media-search": ShowDialog(typeof(EverythingWindow)); break; @@ -30,7 +32,6 @@ namespace mpvnet case "show-input-editor": ShowDialog(typeof(InputWindow)); break; case "show-setup-dialog": ShowDialog(typeof(SetupWindow)); break; case "open-conf-folder": Process.Start(mp.ConfigFolder); break; - case "open-files": OpenFiles(args); break; case "shell-execute": Process.Start(args[0]); break; case "show-info": ShowInfo(); break; case "add-files-to-playlist": OpenFiles("append"); break; // deprecated 2019 @@ -67,6 +68,31 @@ namespace mpvnet })); } + public static void Open_DVD_Or_BD_Folder(params string[] args) + { + InvokeOnMainThread(new Action(() => { + using (var d = new FolderBrowserDialog()) + { + d.Description = "Select a DVD or Blu-ray folder."; + d.ShowNewFolderButton = false; + + if (d.ShowDialog() == DialogResult.OK) + { + if (Directory.Exists(d.SelectedPath + "\\BDMV")) + { + mp.set_property_string("bluray-device", d.SelectedPath); + mp.Load(new[] { @"bd://" }, false, false); + } + else + { + mp.set_property_string("dvd-device", d.SelectedPath); + mp.Load(new[] { @"dvd://" }, false, false); + } + } + } + })); + } + public static void ShowHistory() { var fp = mp.ConfigFolder + "history.txt"; diff --git a/mpv.net/Resources/inputConf.txt b/mpv.net/Resources/inputConf.txt index ff3444c..36312df 100644 --- a/mpv.net/Resources/inputConf.txt +++ b/mpv.net/Resources/inputConf.txt @@ -20,16 +20,17 @@ # run mpv.net in input test mode with: mpvnet --input-test - o script-message mpv.net open-files #menu: Open > Open Files... - u script-message mpv.net open-url #menu: Open > Open URL or file path from clipboard - _ ignore #menu: Open > - - Alt+a script-message mpv.net load-audio #menu: Open > Load external audio files... - Alt+s script-message mpv.net load-sub #menu: Open > Load external subtitle files... - _ ignore #menu: Open > - - _ script-message mpv.net open-files append #menu: Open > Add files to playlist... - F3 script-message mpv.net show-media-search #menu: Open > Show media search... - _ ignore #menu: Open > - - _ ignore #menu: Open > Recent + o script-message mpv.net open-files #menu: Open > Open Files... + u script-message mpv.net open-url #menu: Open > Open URL or file path from clipboard + _ script-message mpv.net open-optical-media #menu: Open > Open DVD/Blu-ray Drive/Folder... + _ ignore #menu: Open > - + Alt+a script-message mpv.net load-audio #menu: Open > Load external audio files... + Alt+s script-message mpv.net load-sub #menu: Open > Load external subtitle files... + _ ignore #menu: Open > - + _ script-message mpv.net open-files append #menu: Open > Add files to playlist... + F3 script-message mpv.net show-media-search #menu: Open > Show media search... + _ ignore #menu: Open > - + _ ignore #menu: Open > Recent _ ignore #menu: - Space cycle pause #menu: Play/Pause diff --git a/mpv.net/Resources/mpvConfToml.txt b/mpv.net/Resources/mpvConfToml.txt index ab19755..d5a9659 100644 --- a/mpv.net/Resources/mpvConfToml.txt +++ b/mpv.net/Resources/mpvConfToml.txt @@ -23,10 +23,10 @@ options = [{ name = "no", help = "always use software decoding" }, name = "gpu-api" default = "auto" filter = "Video" -help = "Controls which type of graphics APIs will be accepted. Auto uses d3d11, it should only be changed in case of problems." +help = "Controls which type of graphics APIs will be accepted. Auto uses d3d11, it should only be changed in case of problems, Vulkan is not recommended." options = [{ name = "auto", help = "Use any available API" }, { name = "opengl", help = "Allow only OpenGL (requires OpenGL 2.1+ or GLES 2.0+)" }, - { name = "vulkan", help = "Allow only Vulkan (requires a working spirv-compiler). " }, + { name = "vulkan", help = "Allow only Vulkan (not recommended). " }, { name = "d3d11", help = "Allow only gpu-context=d3d11" }] [[settings]] diff --git a/mpv.net/WinForms/MainForm.cs b/mpv.net/WinForms/MainForm.cs index 5d34ca4..fba46bd 100644 --- a/mpv.net/WinForms/MainForm.cs +++ b/mpv.net/WinForms/MainForm.cs @@ -368,7 +368,9 @@ namespace mpvnet { string path = mp.get_property_string("path"); BeginInvoke(new Action(() => { - if (File.Exists(path) || path.Contains("://")) + if (path.Contains("://")) + Text = path + " - mpv.net " + Application.ProductVersion; + else if (File.Exists(path)) Text = path.FileName() + " - mpv.net " + Application.ProductVersion; else Text = "mpv.net " + Application.ProductVersion;