From 5f4eca21e5bf2d58ca8573cedeb60727efed687a Mon Sep 17 00:00:00 2001 From: Frank Skare Date: Sun, 26 Jul 2020 03:19:35 +0200 Subject: [PATCH] BluRay folder path auto detection --- Changelog.md | 4 +++- mpv.net/Misc/Commands.cs | 18 +++++++++++------- mpv.net/mpv/Core.cs | 9 ++++++++- 3 files changed, 22 insertions(+), 9 deletions(-) diff --git a/Changelog.md b/Changelog.md index ddc067e..f375c6f 100644 --- a/Changelog.md +++ b/Changelog.md @@ -3,7 +3,9 @@ ============ - BluRays with dozens of titles showed all titles in the menu - which was difficult to choose and also extremely slow. + which was difficult to choose and extremely slow. +- BluRay folder paths are auto detected when received + from drag & drop and command line. 5.4.8.3 Beta diff --git a/mpv.net/Misc/Commands.cs b/mpv.net/Misc/Commands.cs index 3749880..b168eb9 100644 --- a/mpv.net/Misc/Commands.cs +++ b/mpv.net/Misc/Commands.cs @@ -11,6 +11,7 @@ using VB = Microsoft.VisualBasic; using static NewLine; using static mpvnet.Core; +using System.Threading; namespace mpvnet { @@ -82,21 +83,24 @@ namespace mpvnet public static void Open_DVD_Or_BD_Folder() { InvokeOnMainThread(new Action(() => { - using (var d = new FolderBrowserDialog()) + using (var dialog = new FolderBrowserDialog()) { - d.Description = "Select a DVD or Blu-ray folder."; - d.ShowNewFolderButton = false; + dialog.Description = "Select a DVD or Blu-ray folder."; + dialog.ShowNewFolderButton = false; - if (d.ShowDialog() == DialogResult.OK) + if (dialog.ShowDialog() == DialogResult.OK) { - if (Directory.Exists(d.SelectedPath + "\\BDMV")) + core.command("stop"); + Thread.Sleep(500); + + if (Directory.Exists(dialog.SelectedPath + "\\BDMV")) { - core.set_property_string("bluray-device", d.SelectedPath); + core.set_property_string("bluray-device", dialog.SelectedPath); core.LoadFiles(new[] { @"bd://" }, false, false); } else { - core.set_property_string("dvd-device", d.SelectedPath); + core.set_property_string("dvd-device", dialog.SelectedPath); core.LoadFiles(new[] { @"dvd://" }, false, false); } } diff --git a/mpv.net/mpv/Core.cs b/mpv.net/mpv/Core.cs index 5478597..ec75423 100644 --- a/mpv.net/mpv/Core.cs +++ b/mpv.net/mpv/Core.cs @@ -1020,6 +1020,13 @@ namespace mpvnet LoadISO(file); else if(App.SubtitleTypes.Contains(file.Ext())) commandv("sub-add", file); + else if (file.Ext().Length != 3 && File.Exists(Path.Combine(file, "BDMV\\index.bdmv"))) + { + core.command("stop"); + Thread.Sleep(500); + set_property_string("bluray-device", file); + commandv("loadfile", @"bd://"); + } else if (i == 0 && !append) commandv("loadfile", file); @@ -1141,7 +1148,7 @@ namespace mpvnet string GetLanguage(string id) { - foreach (var ci in CultureInfo.GetCultures(CultureTypes.NeutralCultures)) + foreach (CultureInfo ci in CultureInfo.GetCultures(CultureTypes.NeutralCultures)) if (ci.ThreeLetterISOLanguageName == id) return ci.EnglishName;