|
|
|
@ -669,62 +669,57 @@ namespace Emby.Dlna.PlayTo
|
|
|
|
|
|
|
|
|
|
private Task SendGeneralCommand(GeneralCommand command, CancellationToken cancellationToken)
|
|
|
|
|
{
|
|
|
|
|
if (Enum.TryParse(command.Name, true, out GeneralCommandType commandType))
|
|
|
|
|
{
|
|
|
|
|
switch (commandType)
|
|
|
|
|
{
|
|
|
|
|
case GeneralCommandType.VolumeDown:
|
|
|
|
|
return _device.VolumeDown(cancellationToken);
|
|
|
|
|
case GeneralCommandType.VolumeUp:
|
|
|
|
|
return _device.VolumeUp(cancellationToken);
|
|
|
|
|
case GeneralCommandType.Mute:
|
|
|
|
|
return _device.Mute(cancellationToken);
|
|
|
|
|
case GeneralCommandType.Unmute:
|
|
|
|
|
return _device.Unmute(cancellationToken);
|
|
|
|
|
case GeneralCommandType.ToggleMute:
|
|
|
|
|
return _device.ToggleMute(cancellationToken);
|
|
|
|
|
case GeneralCommandType.SetAudioStreamIndex:
|
|
|
|
|
if (command.Arguments.TryGetValue("Index", out string index))
|
|
|
|
|
switch (command.Name)
|
|
|
|
|
{
|
|
|
|
|
case GeneralCommandType.VolumeDown:
|
|
|
|
|
return _device.VolumeDown(cancellationToken);
|
|
|
|
|
case GeneralCommandType.VolumeUp:
|
|
|
|
|
return _device.VolumeUp(cancellationToken);
|
|
|
|
|
case GeneralCommandType.Mute:
|
|
|
|
|
return _device.Mute(cancellationToken);
|
|
|
|
|
case GeneralCommandType.Unmute:
|
|
|
|
|
return _device.Unmute(cancellationToken);
|
|
|
|
|
case GeneralCommandType.ToggleMute:
|
|
|
|
|
return _device.ToggleMute(cancellationToken);
|
|
|
|
|
case GeneralCommandType.SetAudioStreamIndex:
|
|
|
|
|
if (command.Arguments.TryGetValue("Index", out string index))
|
|
|
|
|
{
|
|
|
|
|
if (int.TryParse(index, NumberStyles.Integer, _usCulture, out var val))
|
|
|
|
|
{
|
|
|
|
|
if (int.TryParse(index, NumberStyles.Integer, _usCulture, out var val))
|
|
|
|
|
{
|
|
|
|
|
return SetAudioStreamIndex(val);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
throw new ArgumentException("Unsupported SetAudioStreamIndex value supplied.");
|
|
|
|
|
return SetAudioStreamIndex(val);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
throw new ArgumentException("SetAudioStreamIndex argument cannot be null");
|
|
|
|
|
case GeneralCommandType.SetSubtitleStreamIndex:
|
|
|
|
|
if (command.Arguments.TryGetValue("Index", out index))
|
|
|
|
|
{
|
|
|
|
|
if (int.TryParse(index, NumberStyles.Integer, _usCulture, out var val))
|
|
|
|
|
{
|
|
|
|
|
return SetSubtitleStreamIndex(val);
|
|
|
|
|
}
|
|
|
|
|
throw new ArgumentException("Unsupported SetAudioStreamIndex value supplied.");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
throw new ArgumentException("Unsupported SetSubtitleStreamIndex value supplied.");
|
|
|
|
|
throw new ArgumentException("SetAudioStreamIndex argument cannot be null");
|
|
|
|
|
case GeneralCommandType.SetSubtitleStreamIndex:
|
|
|
|
|
if (command.Arguments.TryGetValue("Index", out index))
|
|
|
|
|
{
|
|
|
|
|
if (int.TryParse(index, NumberStyles.Integer, _usCulture, out var val))
|
|
|
|
|
{
|
|
|
|
|
return SetSubtitleStreamIndex(val);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
throw new ArgumentException("SetSubtitleStreamIndex argument cannot be null");
|
|
|
|
|
case GeneralCommandType.SetVolume:
|
|
|
|
|
if (command.Arguments.TryGetValue("Volume", out string vol))
|
|
|
|
|
{
|
|
|
|
|
if (int.TryParse(vol, NumberStyles.Integer, _usCulture, out var volume))
|
|
|
|
|
{
|
|
|
|
|
return _device.SetVolume(volume, cancellationToken);
|
|
|
|
|
}
|
|
|
|
|
throw new ArgumentException("Unsupported SetSubtitleStreamIndex value supplied.");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
throw new ArgumentException("Unsupported volume value supplied.");
|
|
|
|
|
throw new ArgumentException("SetSubtitleStreamIndex argument cannot be null");
|
|
|
|
|
case GeneralCommandType.SetVolume:
|
|
|
|
|
if (command.Arguments.TryGetValue("Volume", out string vol))
|
|
|
|
|
{
|
|
|
|
|
if (int.TryParse(vol, NumberStyles.Integer, _usCulture, out var volume))
|
|
|
|
|
{
|
|
|
|
|
return _device.SetVolume(volume, cancellationToken);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
throw new ArgumentException("Volume argument cannot be null");
|
|
|
|
|
default:
|
|
|
|
|
return Task.CompletedTask;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
throw new ArgumentException("Unsupported volume value supplied.");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return Task.CompletedTask;
|
|
|
|
|
throw new ArgumentException("Volume argument cannot be null");
|
|
|
|
|
default:
|
|
|
|
|
return Task.CompletedTask;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private async Task SetAudioStreamIndex(int? newIndex)
|
|
|
|
|