mirror of
https://github.com/aaru-dps/RedBookPlayer.git
synced 2025-12-16 19:24:41 +00:00
Move more logic down the chain
This commit is contained in:
@@ -181,6 +181,11 @@ namespace RedBookPlayer.Common.Hardware
|
||||
/// </summary>
|
||||
private readonly OpticalDisc _opticalDisc;
|
||||
|
||||
/// <summary>
|
||||
/// Last volume for mute toggling
|
||||
/// </summary>
|
||||
private int? _lastVolume = null;
|
||||
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
@@ -258,6 +263,17 @@ namespace RedBookPlayer.Common.Hardware
|
||||
Playing = false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Toggle current playback
|
||||
/// </summary>
|
||||
public void TogglePlayback()
|
||||
{
|
||||
if(Playing == true)
|
||||
Pause();
|
||||
else
|
||||
Play();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Stop current playback
|
||||
/// </summary>
|
||||
@@ -374,13 +390,69 @@ namespace RedBookPlayer.Common.Hardware
|
||||
|
||||
#endregion
|
||||
|
||||
#region Helpers
|
||||
#region Volume
|
||||
|
||||
/// <summary>
|
||||
/// Increment the volume value
|
||||
/// </summary>
|
||||
public void VolumeUp() => SetVolume(Volume + 1);
|
||||
|
||||
/// <summary>
|
||||
/// Decrement the volume value
|
||||
/// </summary>
|
||||
public void VolumeDown() => SetVolume(Volume + 1);
|
||||
|
||||
/// <summary>
|
||||
/// Set the value for the volume
|
||||
/// </summary>
|
||||
/// <param name="volume">New volume value</param>
|
||||
public void SetVolume(int volume) => _soundOutput?.SetVolume(volume);
|
||||
|
||||
/// <summary>
|
||||
/// Temporarily mute playback
|
||||
/// </summary>
|
||||
public void ToggleMute()
|
||||
{
|
||||
if(_lastVolume == null)
|
||||
{
|
||||
_lastVolume = Volume;
|
||||
SetVolume(0);
|
||||
}
|
||||
else
|
||||
{
|
||||
SetVolume(_lastVolume.Value);
|
||||
_lastVolume = null;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Emphasis
|
||||
|
||||
/// <summary>
|
||||
/// Enable de-emphasis
|
||||
/// </summary>
|
||||
public void EnableDeEmphasis() => SetDeEmphasis(true);
|
||||
|
||||
/// <summary>
|
||||
/// Disable de-emphasis
|
||||
/// </summary>
|
||||
public void DisableDeEmphasis() => SetDeEmphasis(false);
|
||||
|
||||
/// <summary>
|
||||
/// Toggle de-emphasis
|
||||
/// </summary>
|
||||
public void ToggleDeEmphasis() => SetDeEmphasis(!ApplyDeEmphasis);
|
||||
|
||||
/// <summary>
|
||||
/// Set de-emphasis status
|
||||
/// </summary>
|
||||
/// <param name="apply"></param>
|
||||
public void SetDeEmphasis(bool apply) => _soundOutput?.SetDeEmphasis(apply);
|
||||
private void SetDeEmphasis(bool apply) => _soundOutput?.SetDeEmphasis(apply);
|
||||
|
||||
#endregion
|
||||
|
||||
#region Helpers
|
||||
|
||||
/// <summary>
|
||||
/// Set the value for loading data tracks [CompactDisc only]
|
||||
@@ -394,12 +466,6 @@ namespace RedBookPlayer.Common.Hardware
|
||||
/// <param name="load">True to enable loading hidden tracks, false otherwise</param>
|
||||
public void SetLoadHiddenTracks(bool load) => (_opticalDisc as CompactDisc)?.SetLoadHiddenTracks(load);
|
||||
|
||||
/// <summary>
|
||||
/// Set the value for the volume
|
||||
/// </summary>
|
||||
/// <param name="volume">New volume value</param>
|
||||
public void SetVolume(int volume) => _soundOutput?.SetVolume(volume);
|
||||
|
||||
/// <summary>
|
||||
/// Update the player from the current OpticalDisc
|
||||
/// </summary>
|
||||
|
||||
@@ -5,7 +5,7 @@ using System.Xml;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Input;
|
||||
using Avalonia.Markup.Xaml;
|
||||
using RedBookPlayer.Common;
|
||||
using RedBookPlayer.GUI.ViewModels;
|
||||
|
||||
namespace RedBookPlayer.GUI
|
||||
{
|
||||
@@ -94,7 +94,7 @@ namespace RedBookPlayer.GUI
|
||||
|
||||
Closing += (e, f) =>
|
||||
{
|
||||
((PlayerView)ContentControl.Content).StopButton_Click(this, null);
|
||||
((PlayerView)ContentControl.Content).PlayerViewModel.ExecuteStop();
|
||||
};
|
||||
|
||||
AddHandler(DragDrop.DropEvent, MainWindow_Drop);
|
||||
@@ -138,49 +138,49 @@ namespace RedBookPlayer.GUI
|
||||
// Toggle playback
|
||||
else if(e.Key == App.Settings.TogglePlaybackKey || e.Key == Key.MediaPlayPause)
|
||||
{
|
||||
playerView?.PlayPauseButton_Click(this, null);
|
||||
playerView?.PlayerViewModel?.ExecuteTogglePlayPause();
|
||||
}
|
||||
|
||||
// Stop playback
|
||||
else if(e.Key == App.Settings.StopPlaybackKey || e.Key == Key.MediaStop)
|
||||
{
|
||||
playerView?.StopButton_Click(this, null);
|
||||
playerView?.PlayerViewModel?.ExecuteStop();
|
||||
}
|
||||
|
||||
// Next Track
|
||||
else if(e.Key == App.Settings.NextTrackKey || e.Key == Key.MediaNextTrack)
|
||||
{
|
||||
playerView?.NextTrackButton_Click(this, null);
|
||||
playerView?.PlayerViewModel?.ExecuteNextTrack();
|
||||
}
|
||||
|
||||
// Previous Track
|
||||
else if(e.Key == App.Settings.PreviousTrackKey || e.Key == Key.MediaPreviousTrack)
|
||||
{
|
||||
playerView?.PreviousTrackButton_Click(this, null);
|
||||
playerView?.PlayerViewModel?.ExecutePreviousTrack();
|
||||
}
|
||||
|
||||
// Next Index
|
||||
else if(e.Key == App.Settings.NextIndexKey)
|
||||
{
|
||||
playerView?.NextIndexButton_Click(this, null);
|
||||
playerView?.PlayerViewModel?.ExecuteNextIndex();
|
||||
}
|
||||
|
||||
// Previous Index
|
||||
else if(e.Key == App.Settings.PreviousIndexKey)
|
||||
{
|
||||
playerView?.PreviousIndexButton_Click(this, null);
|
||||
playerView?.PlayerViewModel?.ExecutePreviousIndex();
|
||||
}
|
||||
|
||||
// Fast Foward
|
||||
else if(e.Key == App.Settings.FastForwardPlaybackKey)
|
||||
{
|
||||
playerView?.FastForwardButton_Click(this, null);
|
||||
playerView?.PlayerViewModel?.ExecuteFastForward();
|
||||
}
|
||||
|
||||
// Rewind
|
||||
else if(e.Key == App.Settings.RewindPlaybackKey)
|
||||
{
|
||||
playerView?.RewindButton_Click(this, null);
|
||||
playerView?.PlayerViewModel?.ExecuteRewind();
|
||||
}
|
||||
|
||||
// Volume Up
|
||||
@@ -193,7 +193,7 @@ namespace RedBookPlayer.GUI
|
||||
increment *= 5;
|
||||
|
||||
if(playerView?.PlayerViewModel?.Volume != null)
|
||||
playerView.PlayerViewModel.SetVolume(playerView.PlayerViewModel.Volume + increment);
|
||||
playerView.PlayerViewModel.ExecuteSetVolume(playerView.PlayerViewModel.Volume + increment);
|
||||
}
|
||||
|
||||
// Volume Down
|
||||
@@ -206,19 +206,19 @@ namespace RedBookPlayer.GUI
|
||||
decrement *= 5;
|
||||
|
||||
if (playerView?.PlayerViewModel?.Volume != null)
|
||||
playerView.PlayerViewModel.SetVolume(playerView.PlayerViewModel.Volume - decrement);
|
||||
playerView.PlayerViewModel.ExecuteSetVolume(playerView.PlayerViewModel.Volume - decrement);
|
||||
}
|
||||
|
||||
// Mute Toggle
|
||||
else if(e.Key == App.Settings.ToggleMuteKey || e.Key == Key.VolumeMute)
|
||||
{
|
||||
playerView?.MuteToggleButton_Click(this, null);
|
||||
playerView?.PlayerViewModel?.ExecuteToggleMute();
|
||||
}
|
||||
|
||||
// Emphasis Toggle
|
||||
else if(e.Key == App.Settings.ToggleDeEmphasisKey)
|
||||
{
|
||||
playerView?.EnableDisableDeEmphasisButton_Click(this, null);
|
||||
playerView?.PlayerViewModel?.ExecuteToggleDeEmphasis();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -5,17 +5,17 @@
|
||||
<StackPanel Margin="16" VerticalAlignment="Center">
|
||||
<Button Click="LoadButton_Click" Margin="32,0,32,16">Load</Button>
|
||||
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center" Margin="0,0,0,16">
|
||||
<Button Click="PlayButton_Click" Width="100" Margin="0,0,16,0">Play</Button>
|
||||
<Button Click="PauseButton_Click" Width="100" Margin="0,0,16,0">Pause</Button>
|
||||
<Button Click="StopButton_Click" Width="100" Margin="0,0,16,0">Stop</Button>
|
||||
<Button Command="{Binding PlayCommand}" Width="100" Margin="0,0,16,0">Play</Button>
|
||||
<Button Command="{Binding PauseCommand}" Width="100" Margin="0,0,16,0">Pause</Button>
|
||||
<Button Command="{Binding StopCommand}" Width="100" Margin="0,0,16,0">Stop</Button>
|
||||
</StackPanel>
|
||||
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center" Margin="0,0,0,16">
|
||||
<Button Click="PreviousTrackButton_Click" Width="100" Margin="0,0,16,0">Previous Track</Button>
|
||||
<Button Click="NextTrackButton_Click" Width="100" Margin="0,0,16,0">Next Track</Button>
|
||||
<Button Click="PreviousIndexButton_Click" Width="100" Margin="0,0,16,0">Previous Index</Button>
|
||||
<Button Click="NextIndexButton_Click" Width="100" Margin="0,0,16,0">Next Index</Button>
|
||||
<RepeatButton Click="RewindButton_Click" Width="100" Margin="0,0,16,0">Rewind</RepeatButton>
|
||||
<RepeatButton Click="FastForwardButton_Click" Width="100">Fast Forward</RepeatButton>
|
||||
<Button Command="{Binding PreviousTrackCommand}" Width="100" Margin="0,0,16,0">Previous Track</Button>
|
||||
<Button Command="{Binding NextTrackCommand}" Width="100" Margin="0,0,16,0">Next Track</Button>
|
||||
<Button Command="{Binding PreviousIndexCommand}" Width="100" Margin="0,0,16,0">Previous Index</Button>
|
||||
<Button Command="{Binding NextIndexCommand}" Width="100" Margin="0,0,16,0">Next Index</Button>
|
||||
<RepeatButton Command="{Binding RewindCommand}" Width="100" Margin="0,0,16,0">Rewind</RepeatButton>
|
||||
<RepeatButton Command="{Binding FastForwardCommand}" Width="100">Fast Forward</RepeatButton>
|
||||
</StackPanel>
|
||||
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center" Margin="0,0,0,16">
|
||||
<StackPanel Margin="0,0,32,0">
|
||||
@@ -76,11 +76,11 @@
|
||||
</StackPanel>
|
||||
</StackPanel>
|
||||
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center" Margin="0,0,0,16">
|
||||
<Button Click="EnableDeEmphasisButton_Click" IsVisible="{Binding !ApplyDeEmphasis}" Width="200"
|
||||
<Button Command="{Binding EnableDeEmphasisCommand}" IsVisible="{Binding !ApplyDeEmphasis}" Width="200"
|
||||
Margin="0,0,16,0">
|
||||
Enable De-Emphasis
|
||||
</Button>
|
||||
<Button Click="DisableDeEmphasisButton_Click" IsVisible="{Binding ApplyDeEmphasis}" Width="200"
|
||||
<Button Command="{Binding DisableDeEmphasisCommand}" IsVisible="{Binding ApplyDeEmphasis}" Width="200"
|
||||
Margin="0,0,16,0">
|
||||
Disable De-Emphasis
|
||||
</Button>
|
||||
|
||||
@@ -11,7 +11,7 @@ using Avalonia.Markup.Xaml;
|
||||
using Avalonia.Media.Imaging;
|
||||
using Avalonia.Platform;
|
||||
using Avalonia.Threading;
|
||||
using RedBookPlayer.Common;
|
||||
using RedBookPlayer.GUI.ViewModels;
|
||||
|
||||
namespace RedBookPlayer.GUI
|
||||
{
|
||||
@@ -267,44 +267,6 @@ namespace RedBookPlayer.GUI
|
||||
await LoadImage(path);
|
||||
}
|
||||
|
||||
public void PlayButton_Click(object sender, RoutedEventArgs e) => PlayerViewModel.Play();
|
||||
|
||||
public void PauseButton_Click(object sender, RoutedEventArgs e) => PlayerViewModel.Pause();
|
||||
|
||||
public void PlayPauseButton_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if(PlayerViewModel.Playing == true)
|
||||
PlayerViewModel.Pause();
|
||||
else
|
||||
PlayerViewModel.Play();
|
||||
}
|
||||
|
||||
public void StopButton_Click(object sender, RoutedEventArgs e) => PlayerViewModel.Stop();
|
||||
|
||||
public void NextTrackButton_Click(object sender, RoutedEventArgs e) => PlayerViewModel.NextTrack();
|
||||
|
||||
public void PreviousTrackButton_Click(object sender, RoutedEventArgs e) => PlayerViewModel.PreviousTrack();
|
||||
|
||||
public void NextIndexButton_Click(object sender, RoutedEventArgs e) => PlayerViewModel.NextIndex(App.Settings.IndexButtonChangeTrack);
|
||||
|
||||
public void PreviousIndexButton_Click(object sender, RoutedEventArgs e) => PlayerViewModel.PreviousIndex(App.Settings.IndexButtonChangeTrack);
|
||||
|
||||
public void FastForwardButton_Click(object sender, RoutedEventArgs e) => PlayerViewModel.FastForward();
|
||||
|
||||
public void RewindButton_Click(object sender, RoutedEventArgs e) => PlayerViewModel.Rewind();
|
||||
|
||||
public void VolumeUpButton_Click(object sender, RoutedEventArgs e) => PlayerViewModel.SetVolume(PlayerViewModel.Volume + 1);
|
||||
|
||||
public void VolumeDownButton_Click(object sender, RoutedEventArgs e) => PlayerViewModel.SetVolume(PlayerViewModel.Volume - 1);
|
||||
|
||||
public void MuteToggleButton_Click(object sender, RoutedEventArgs e) => PlayerViewModel.ToggleMute();
|
||||
|
||||
public void EnableDeEmphasisButton_Click(object sender, RoutedEventArgs e) => PlayerViewModel.SetDeEmphasis(true);
|
||||
|
||||
public void DisableDeEmphasisButton_Click(object sender, RoutedEventArgs e) => PlayerViewModel.SetDeEmphasis(false);
|
||||
|
||||
public void EnableDisableDeEmphasisButton_Click(object sender, RoutedEventArgs e) => PlayerViewModel.SetDeEmphasis(!PlayerViewModel.ApplyDeEmphasis);
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -1,8 +1,9 @@
|
||||
using System.ComponentModel;
|
||||
using System.Reactive;
|
||||
using ReactiveUI;
|
||||
using RedBookPlayer.Common.Hardware;
|
||||
|
||||
namespace RedBookPlayer.Common
|
||||
namespace RedBookPlayer.GUI.ViewModels
|
||||
{
|
||||
public class PlayerViewModel : ReactiveObject
|
||||
{
|
||||
@@ -11,11 +12,6 @@ namespace RedBookPlayer.Common
|
||||
/// </summary>
|
||||
private Player _player;
|
||||
|
||||
/// <summary>
|
||||
/// Last volume for mute toggling
|
||||
/// </summary>
|
||||
private int? _lastVolume = null;
|
||||
|
||||
#region Player Passthrough
|
||||
|
||||
#region OpticalDisc Passthrough
|
||||
@@ -181,6 +177,127 @@ namespace RedBookPlayer.Common
|
||||
|
||||
#endregion
|
||||
|
||||
#region Commands
|
||||
|
||||
#region Playback
|
||||
|
||||
/// <summary>
|
||||
/// Command for beginning playback
|
||||
/// </summary>
|
||||
public ReactiveCommand<Unit, Unit> PlayCommand { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Command for pausing playback
|
||||
/// </summary>
|
||||
public ReactiveCommand<Unit, Unit> PauseCommand { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Command for pausing playback
|
||||
/// </summary>
|
||||
public ReactiveCommand<Unit, Unit> TogglePlayPauseCommand { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Command for stopping playback
|
||||
/// </summary>
|
||||
public ReactiveCommand<Unit, Unit> StopCommand { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Command for moving to the next track
|
||||
/// </summary>
|
||||
public ReactiveCommand<Unit, Unit> NextTrackCommand { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Command for moving to the previous track
|
||||
/// </summary>
|
||||
public ReactiveCommand<Unit, Unit> PreviousTrackCommand { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Command for moving to the next index
|
||||
/// </summary>
|
||||
public ReactiveCommand<Unit, Unit> NextIndexCommand { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Command for moving to the previous index
|
||||
/// </summary>
|
||||
public ReactiveCommand<Unit, Unit> PreviousIndexCommand { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Command for fast forwarding
|
||||
/// </summary>
|
||||
public ReactiveCommand<Unit, Unit> FastForwardCommand { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Command for rewinding
|
||||
/// </summary>
|
||||
public ReactiveCommand<Unit, Unit> RewindCommand { get; }
|
||||
|
||||
#endregion
|
||||
|
||||
#region Volume
|
||||
|
||||
/// <summary>
|
||||
/// Command for incrementing volume
|
||||
/// </summary>
|
||||
public ReactiveCommand<Unit, Unit> VolumeUpCommand { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Command for decrementing volume
|
||||
/// </summary>
|
||||
public ReactiveCommand<Unit, Unit> VolumeDownCommand { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Command for toggling mute
|
||||
/// </summary>
|
||||
public ReactiveCommand<Unit, Unit> ToggleMuteCommand { get; }
|
||||
|
||||
#endregion
|
||||
|
||||
#region Emphasis
|
||||
|
||||
/// <summary>
|
||||
/// Command for enabling de-emphasis
|
||||
/// </summary>
|
||||
public ReactiveCommand<Unit, Unit> EnableDeEmphasisCommand { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Command for disabling de-emphasis
|
||||
/// </summary>
|
||||
public ReactiveCommand<Unit, Unit> DisableDeEmphasisCommand { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Command for toggling de-emphasis
|
||||
/// </summary>
|
||||
public ReactiveCommand<Unit, Unit> ToggleDeEmphasisCommand { get; }
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// Constructor
|
||||
/// </summary>
|
||||
public PlayerViewModel()
|
||||
{
|
||||
PlayCommand = ReactiveCommand.Create(ExecutePlay);
|
||||
PauseCommand = ReactiveCommand.Create(ExecutePause);
|
||||
TogglePlayPauseCommand = ReactiveCommand.Create(ExecuteTogglePlayPause);
|
||||
StopCommand = ReactiveCommand.Create(ExecuteStop);
|
||||
NextTrackCommand = ReactiveCommand.Create(ExecuteNextTrack);
|
||||
PreviousTrackCommand = ReactiveCommand.Create(ExecutePreviousTrack);
|
||||
NextIndexCommand = ReactiveCommand.Create(ExecuteNextIndex);
|
||||
PreviousIndexCommand = ReactiveCommand.Create(ExecutePreviousIndex);
|
||||
FastForwardCommand = ReactiveCommand.Create(ExecuteFastForward);
|
||||
RewindCommand = ReactiveCommand.Create(ExecuteRewind);
|
||||
|
||||
VolumeUpCommand = ReactiveCommand.Create(ExecuteVolumeUp);
|
||||
VolumeDownCommand = ReactiveCommand.Create(ExecuteVolumeDown);
|
||||
ToggleMuteCommand = ReactiveCommand.Create(ExecuteToggleMute);
|
||||
|
||||
EnableDeEmphasisCommand = ReactiveCommand.Create(ExecuteEnableDeEmphasis);
|
||||
DisableDeEmphasisCommand = ReactiveCommand.Create(ExecuteDisableDeEmphasis);
|
||||
ToggleDeEmphasisCommand = ReactiveCommand.Create(ExecuteToggleDeEmphasis);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initialize the view model with a given image path
|
||||
/// </summary>
|
||||
@@ -193,7 +310,7 @@ namespace RedBookPlayer.Common
|
||||
public void Init(string path, bool generateMissingToc, bool loadHiddenTracks, bool loadDataTracks, bool autoPlay, int defaultVolume)
|
||||
{
|
||||
// Stop current playback, if necessary
|
||||
if(Playing != null) Stop();
|
||||
if(Playing != null) ExecuteStop();
|
||||
|
||||
// Create and attempt to initialize new Player
|
||||
_player = new Player(path, generateMissingToc, loadHiddenTracks, loadDataTracks, autoPlay, defaultVolume);
|
||||
@@ -209,60 +326,101 @@ namespace RedBookPlayer.Common
|
||||
/// <summary>
|
||||
/// Begin playback
|
||||
/// </summary>
|
||||
public void Play() => _player?.Play();
|
||||
public void ExecutePlay() => _player?.Play();
|
||||
|
||||
/// <summary>
|
||||
/// Pause current playback
|
||||
/// </summary>
|
||||
public void Pause() => _player?.Pause();
|
||||
public void ExecutePause() => _player?.Pause();
|
||||
|
||||
/// <summary>
|
||||
/// Toggle playback
|
||||
/// </summary>
|
||||
public void ExecuteTogglePlayPause() => _player?.TogglePlayback();
|
||||
|
||||
/// <summary>
|
||||
/// Stop current playback
|
||||
/// </summary>
|
||||
public void Stop() => _player?.Stop();
|
||||
public void ExecuteStop() => _player?.Stop();
|
||||
|
||||
/// <summary>
|
||||
/// Move to the next playable track
|
||||
/// </summary>
|
||||
public void NextTrack() => _player?.NextTrack();
|
||||
public void ExecuteNextTrack() => _player?.NextTrack();
|
||||
|
||||
/// <summary>
|
||||
/// Move to the previous playable track
|
||||
/// </summary>
|
||||
public void PreviousTrack() => _player?.PreviousTrack();
|
||||
public void ExecutePreviousTrack() => _player?.PreviousTrack();
|
||||
|
||||
/// <summary>
|
||||
/// Move to the next index
|
||||
/// </summary>
|
||||
/// <param name="changeTrack">True if index changes can trigger a track change, false otherwise</param>
|
||||
public void NextIndex(bool changeTrack) => _player?.NextIndex(changeTrack);
|
||||
public void ExecuteNextIndex() => _player?.NextIndex(App.Settings.IndexButtonChangeTrack);
|
||||
|
||||
/// <summary>
|
||||
/// Move to the previous index
|
||||
/// </summary>
|
||||
/// <param name="changeTrack">True if index changes can trigger a track change, false otherwise</param>
|
||||
public void PreviousIndex(bool changeTrack) => _player?.PreviousIndex(changeTrack);
|
||||
public void ExecutePreviousIndex() => _player?.PreviousIndex(App.Settings.IndexButtonChangeTrack);
|
||||
|
||||
/// <summary>
|
||||
/// Fast-forward playback by 75 sectors, if possible
|
||||
/// </summary>
|
||||
public void FastForward() => _player?.FastForward();
|
||||
public void ExecuteFastForward() => _player?.FastForward();
|
||||
|
||||
/// <summary>
|
||||
/// Rewind playback by 75 sectors, if possible
|
||||
/// </summary>
|
||||
public void Rewind() => _player?.Rewind();
|
||||
public void ExecuteRewind() => _player?.Rewind();
|
||||
|
||||
#endregion
|
||||
|
||||
#region Volume
|
||||
|
||||
/// <summary>
|
||||
/// Increment the volume value
|
||||
/// </summary>
|
||||
public void ExecuteVolumeUp() => _player?.VolumeUp();
|
||||
|
||||
/// <summary>
|
||||
/// Decrement the volume value
|
||||
/// </summary>
|
||||
public void ExecuteVolumeDown() => _player?.VolumeDown();
|
||||
|
||||
/// <summary>
|
||||
/// Set the value for the volume
|
||||
/// </summary>
|
||||
/// <param name="volume">New volume value</param>
|
||||
public void ExecuteSetVolume(int volume) => _player?.SetVolume(volume);
|
||||
|
||||
/// <summary>
|
||||
/// Temporarily mute playback
|
||||
/// </summary>
|
||||
public void ExecuteToggleMute() => _player?.ToggleMute();
|
||||
|
||||
#endregion
|
||||
|
||||
#region Emphasis
|
||||
|
||||
/// <summary>
|
||||
/// Enable de-emphasis
|
||||
/// </summary>
|
||||
public void ExecuteEnableDeEmphasis() => _player?.EnableDeEmphasis();
|
||||
|
||||
/// <summary>
|
||||
/// Disable de-emphasis
|
||||
/// </summary>
|
||||
public void ExecuteDisableDeEmphasis() => _player?.DisableDeEmphasis();
|
||||
|
||||
/// <summary>
|
||||
/// Toggle de-emphasis
|
||||
/// </summary>
|
||||
public void ExecuteToggleDeEmphasis() => _player?.ToggleDeEmphasis();
|
||||
|
||||
#endregion
|
||||
|
||||
#region Helpers
|
||||
|
||||
/// <summary>
|
||||
/// Set de-emphasis status
|
||||
/// </summary>
|
||||
/// <param name="apply"></param>
|
||||
public void SetDeEmphasis(bool apply) => _player?.SetDeEmphasis(apply);
|
||||
|
||||
/// <summary>
|
||||
/// Set the value for loading data tracks [CompactDisc only]
|
||||
/// </summary>
|
||||
@@ -275,29 +433,6 @@ namespace RedBookPlayer.Common
|
||||
/// <param name="load">True to enable loading hidden tracks, false otherwise</param>
|
||||
public void SetLoadHiddenTracks(bool load) => _player?.SetLoadHiddenTracks(load);
|
||||
|
||||
/// <summary>
|
||||
/// Set the value for the volume
|
||||
/// </summary>
|
||||
/// <param name="volume">New volume value</param>
|
||||
public void SetVolume(int volume) => _player?.SetVolume(volume);
|
||||
|
||||
/// <summary>
|
||||
/// Temporarily mute playback
|
||||
/// </summary>
|
||||
public void ToggleMute()
|
||||
{
|
||||
if(_lastVolume == null)
|
||||
{
|
||||
_lastVolume = Volume;
|
||||
_player?.SetVolume(0);
|
||||
}
|
||||
else
|
||||
{
|
||||
_player?.SetVolume(_lastVolume.Value);
|
||||
_lastVolume = null;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Update the view-model from the Player
|
||||
/// </summary>
|
||||
Reference in New Issue
Block a user