improved audio device support
This commit is contained in:
@@ -27,6 +27,7 @@ public class AppClass
|
||||
public bool IsTerminalAttached { get; } = Environment.GetEnvironmentVariable("_started_from_console") == "yes";
|
||||
public bool MediaInfo { get; set; } = true;
|
||||
public bool Queue { get; set; }
|
||||
public bool RememberAudioDevice { get; set; } = true;
|
||||
public bool RememberVolume { get; set; } = true;
|
||||
public bool RememberWindowPosition { get; set; }
|
||||
|
||||
@@ -98,6 +99,9 @@ public class AppClass
|
||||
Player.SetPropertyInt("volume", Settings.Volume);
|
||||
Player.SetPropertyString("mute", Settings.Mute);
|
||||
}
|
||||
|
||||
if (RememberAudioDevice && Settings.AudioDevice != "")
|
||||
Player.SetPropertyString("audio-device", Settings.AudioDevice);
|
||||
}
|
||||
|
||||
void Player_Shutdown()
|
||||
@@ -150,6 +154,7 @@ public class AppClass
|
||||
case "process-instance": ProcessInstance = value; return true;
|
||||
case "queue": Queue = value == "yes"; return true;
|
||||
case "recent-count": RecentCount = value.ToInt(15); return true;
|
||||
case "remember-audio-device": RememberAudioDevice = value == "yes"; return true;
|
||||
case "remember-volume": RememberVolume = value == "yes"; return true;
|
||||
case "remember-window-position": RememberWindowPosition = value == "yes"; return true;
|
||||
case "start-size": StartSize = value; return true;
|
||||
|
||||
@@ -82,6 +82,7 @@ public static class InputHelp
|
||||
new (_("Video"), _("Change Aspect Ratio"), "cycle-values video-aspect-override 16:9 4:3 2.35:1 -1", "a"),
|
||||
new (_("Video"), _("Rotate Video"), "cycle-values video-rotate 90 180 270 0", "Ctrl+r"),
|
||||
|
||||
new (_("Audio"), _("Audio Device")),
|
||||
new (_("Audio"), _("Next Track"), "script-message-to mpvnet cycle-audio", "KP7"),
|
||||
new (_("Audio"), "-"),
|
||||
new (_("Audio"), _("Delay +0.1"), "add audio-delay 0.1", "Ctrl+d"),
|
||||
@@ -213,8 +214,6 @@ public static class InputHelp
|
||||
new ("", "", "no-osd sub-seek 1", "Ctrl+Shift+Right", _("Seek to next subtitle")),
|
||||
new ("", "", "no-osd seek 5", "Ctrl+Wheel_Up", _("Seek Forward")),
|
||||
new ("", "", "no-osd seek -5", "Ctrl+Wheel_Down", _("Seek Backward")),
|
||||
new ("", "", "quit 4", "Esc", _("Quit encoding")),
|
||||
new ("", "", "quit 4", "q", _("Quit encoding")),
|
||||
new ("", "", "quit", "Power", _("Exit")),
|
||||
|
||||
//new (_("Command Palette"), _("Commands"), "script-message-to mpvnet show-command-palette", "F1"),
|
||||
@@ -488,7 +487,7 @@ public static class InputHelp
|
||||
|
||||
Binding binding = it.Value;
|
||||
|
||||
if (!keys.Contains(binding.Input) && (charCount + binding.Input.Length) < 15 && keys.Count < 2)
|
||||
if (!keys.Contains(binding.Input) && (charCount + binding.Input.Length) < 15)
|
||||
{
|
||||
keys.Add(binding.Input);
|
||||
charCount += binding.Input.Length;
|
||||
|
||||
@@ -59,6 +59,8 @@ public class MainPlayer : MpvClient
|
||||
public TimeSpan Duration;
|
||||
public List<MpvClient> Clients { get; } = new List<MpvClient>();
|
||||
|
||||
List<StringPair>? _audioDevices;
|
||||
|
||||
public event Action? Initialized;
|
||||
public event Action? Pause;
|
||||
public event Action<int>? PlaylistPosChanged;
|
||||
@@ -690,6 +692,26 @@ public class MainPlayer : MpvClient
|
||||
}
|
||||
}
|
||||
|
||||
public List<StringPair> AudioDevices {
|
||||
get {
|
||||
if (_audioDevices != null)
|
||||
return _audioDevices;
|
||||
|
||||
_audioDevices = new();
|
||||
string json = GetPropertyString("audio-device-list");
|
||||
var enumerator = JsonDocument.Parse(json).RootElement.EnumerateArray();
|
||||
|
||||
foreach (var element in enumerator)
|
||||
{
|
||||
string name = element.GetProperty("name").GetString()!;
|
||||
string description = element.GetProperty("description").GetString()!;
|
||||
_audioDevices.Add(new StringPair(name, description));
|
||||
}
|
||||
|
||||
return _audioDevices;
|
||||
}
|
||||
}
|
||||
|
||||
public List<Chapter> GetChapters() {
|
||||
List<Chapter> chapters = new List<Chapter>();
|
||||
int count = GetPropertyInt("chapter-list/count");
|
||||
|
||||
@@ -17,6 +17,7 @@ public class AppSettings
|
||||
public Point WindowLocation;
|
||||
public Point WindowPosition;
|
||||
public Size WindowSize;
|
||||
public string AudioDevice = "";
|
||||
public string ConfigEditorSearch = "Video:";
|
||||
public string Mute = "no";
|
||||
public string StartupFolder = "";
|
||||
|
||||
Reference in New Issue
Block a user