diff --git a/docs/Changelog.md b/docs/Changelog.md index f317938..fde9378 100644 --- a/docs/Changelog.md +++ b/docs/Changelog.md @@ -2,6 +2,7 @@ 5.4.9.2 Beta (2021-??-??) - Manual translated to simplified Chinese (hooke007) +- Showing the playlist selects the currently played file/stream in the playlist. 5.4.9.1 Beta (2021-06-23) diff --git a/src/Misc/Commands.cs b/src/Misc/Commands.cs index 2d44343..84ad293 100644 --- a/src/Misc/Commands.cs +++ b/src/Misc/Commands.cs @@ -382,6 +382,7 @@ namespace mpvnet { CommandPalette.Instance.SetItems(CommandPalette.GetItems()); MainForm.Instance.ShowCommandPalette(); + CommandPalette.Instance.SelectFirst(); } public static void ShowPlaylist() => App.InvokeOnMainThread(ShowPlaylistInternal); @@ -389,6 +390,8 @@ namespace mpvnet static void ShowPlaylistInternal() { int count = Core.get_property_int("playlist-count"); + string currentPath = Core.get_property_string("path"); + CommandPaletteItem currentItem = null; if (count <= 0) return; @@ -399,14 +402,27 @@ namespace mpvnet { int index = i; string file = Core.get_property_string($"playlist/{i}/filename"); + CommandPaletteItem item = new CommandPaletteItem() { Text = PathHelp.GetFileName(file), Action = () => Core.set_property_int("playlist-pos", index) }; + items.Add(item); + + if (currentPath.ToLowerEx() == file.ToLowerEx()) + currentItem = item; } CommandPalette.Instance.SetItems(items); + + if (currentItem != null) + { + CommandPalette.Instance.MainListView.SelectedItem = currentItem; + CommandPalette.Instance.MainListView.ScrollIntoView( + CommandPalette.Instance.MainListView.SelectedItem); + } + MainForm.Instance.ShowCommandPalette(); } } diff --git a/src/WinForms/MainForm.cs b/src/WinForms/MainForm.cs index b202f01..b95a175 100644 --- a/src/WinForms/MainForm.cs +++ b/src/WinForms/MainForm.cs @@ -1063,7 +1063,6 @@ namespace mpvnet AdjustCommandPaletteLeftAndWidth(); CommandPaletteHost.Child = CommandPalette.Instance; CommandPalette.Instance.AdjustHeight(); - CommandPalette.Instance.SelectFirst(); Controls.Add(CommandPaletteHost); } }