diff --git a/docs/Changelog.md b/docs/Changelog.md index 1e58347..79c49eb 100644 --- a/docs/Changelog.md +++ b/docs/Changelog.md @@ -13,6 +13,7 @@ position instead of remembering the window center position. - High DPI multi monitor fix. - `start-size` option has new options, see in config editor and manual. +- Improved `cycle-audio` OSD info. 5.4.8.8 Beta (2021-05-09) diff --git a/src/Misc/Commands.cs b/src/Misc/Commands.cs index b854970..ba4d649 100644 --- a/src/Misc/Commands.cs +++ b/src/Misc/Commands.cs @@ -298,18 +298,26 @@ namespace mpvnet public static void CycleAudio() { - MediaTrack[] tracks = core.MediaTracks.Where(track => track.Type == "a").ToArray(); + MediaTrack[] audioTracks = core.MediaTracks.Where(track => track.Type == "a").ToArray(); + int len = audioTracks.Length; - if (tracks.Length < 2) + if (len < 1) + { + core.commandv("show-text", "No audio tracks"); return; + } int aid = core.get_property_int("aid"); - if (++aid > tracks.Length) - aid = 1; + if (len > 1) + { + if (++aid > len) + aid = 1; - core.commandv("set", "aid", aid.ToString()); - core.commandv("show-text", aid + ": " + tracks[aid - 1].Text.Substring(3), "5000"); + core.commandv("set", "aid", aid.ToString()); + } + + core.commandv("show-text", aid + "/" + len + ": " + audioTracks[aid - 1].Text.Substring(3), "5000"); } public static void ShowCommands()