Move more logic down the chain

This commit is contained in:
Matt Nadareski
2021-07-12 10:41:11 -07:00
parent 6f9c39f5c1
commit 788d10ecd8
5 changed files with 282 additions and 119 deletions

View File

@@ -181,6 +181,11 @@ namespace RedBookPlayer.Common.Hardware
/// </summary> /// </summary>
private readonly OpticalDisc _opticalDisc; private readonly OpticalDisc _opticalDisc;
/// <summary>
/// Last volume for mute toggling
/// </summary>
private int? _lastVolume = null;
#endregion #endregion
/// <summary> /// <summary>
@@ -258,6 +263,17 @@ namespace RedBookPlayer.Common.Hardware
Playing = false; Playing = false;
} }
/// <summary>
/// Toggle current playback
/// </summary>
public void TogglePlayback()
{
if(Playing == true)
Pause();
else
Play();
}
/// <summary> /// <summary>
/// Stop current playback /// Stop current playback
/// </summary> /// </summary>
@@ -374,13 +390,69 @@ namespace RedBookPlayer.Common.Hardware
#endregion #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> /// <summary>
/// Set de-emphasis status /// Set de-emphasis status
/// </summary> /// </summary>
/// <param name="apply"></param> /// <param name="apply"></param>
public void SetDeEmphasis(bool apply) => _soundOutput?.SetDeEmphasis(apply); private void SetDeEmphasis(bool apply) => _soundOutput?.SetDeEmphasis(apply);
#endregion
#region Helpers
/// <summary> /// <summary>
/// Set the value for loading data tracks [CompactDisc only] /// 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> /// <param name="load">True to enable loading hidden tracks, false otherwise</param>
public void SetLoadHiddenTracks(bool load) => (_opticalDisc as CompactDisc)?.SetLoadHiddenTracks(load); 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> /// <summary>
/// Update the player from the current OpticalDisc /// Update the player from the current OpticalDisc
/// </summary> /// </summary>

View File

@@ -5,7 +5,7 @@ using System.Xml;
using Avalonia.Controls; using Avalonia.Controls;
using Avalonia.Input; using Avalonia.Input;
using Avalonia.Markup.Xaml; using Avalonia.Markup.Xaml;
using RedBookPlayer.Common; using RedBookPlayer.GUI.ViewModels;
namespace RedBookPlayer.GUI namespace RedBookPlayer.GUI
{ {
@@ -94,7 +94,7 @@ namespace RedBookPlayer.GUI
Closing += (e, f) => Closing += (e, f) =>
{ {
((PlayerView)ContentControl.Content).StopButton_Click(this, null); ((PlayerView)ContentControl.Content).PlayerViewModel.ExecuteStop();
}; };
AddHandler(DragDrop.DropEvent, MainWindow_Drop); AddHandler(DragDrop.DropEvent, MainWindow_Drop);
@@ -138,49 +138,49 @@ namespace RedBookPlayer.GUI
// Toggle playback // Toggle playback
else if(e.Key == App.Settings.TogglePlaybackKey || e.Key == Key.MediaPlayPause) else if(e.Key == App.Settings.TogglePlaybackKey || e.Key == Key.MediaPlayPause)
{ {
playerView?.PlayPauseButton_Click(this, null); playerView?.PlayerViewModel?.ExecuteTogglePlayPause();
} }
// Stop playback // Stop playback
else if(e.Key == App.Settings.StopPlaybackKey || e.Key == Key.MediaStop) else if(e.Key == App.Settings.StopPlaybackKey || e.Key == Key.MediaStop)
{ {
playerView?.StopButton_Click(this, null); playerView?.PlayerViewModel?.ExecuteStop();
} }
// Next Track // Next Track
else if(e.Key == App.Settings.NextTrackKey || e.Key == Key.MediaNextTrack) else if(e.Key == App.Settings.NextTrackKey || e.Key == Key.MediaNextTrack)
{ {
playerView?.NextTrackButton_Click(this, null); playerView?.PlayerViewModel?.ExecuteNextTrack();
} }
// Previous Track // Previous Track
else if(e.Key == App.Settings.PreviousTrackKey || e.Key == Key.MediaPreviousTrack) else if(e.Key == App.Settings.PreviousTrackKey || e.Key == Key.MediaPreviousTrack)
{ {
playerView?.PreviousTrackButton_Click(this, null); playerView?.PlayerViewModel?.ExecutePreviousTrack();
} }
// Next Index // Next Index
else if(e.Key == App.Settings.NextIndexKey) else if(e.Key == App.Settings.NextIndexKey)
{ {
playerView?.NextIndexButton_Click(this, null); playerView?.PlayerViewModel?.ExecuteNextIndex();
} }
// Previous Index // Previous Index
else if(e.Key == App.Settings.PreviousIndexKey) else if(e.Key == App.Settings.PreviousIndexKey)
{ {
playerView?.PreviousIndexButton_Click(this, null); playerView?.PlayerViewModel?.ExecutePreviousIndex();
} }
// Fast Foward // Fast Foward
else if(e.Key == App.Settings.FastForwardPlaybackKey) else if(e.Key == App.Settings.FastForwardPlaybackKey)
{ {
playerView?.FastForwardButton_Click(this, null); playerView?.PlayerViewModel?.ExecuteFastForward();
} }
// Rewind // Rewind
else if(e.Key == App.Settings.RewindPlaybackKey) else if(e.Key == App.Settings.RewindPlaybackKey)
{ {
playerView?.RewindButton_Click(this, null); playerView?.PlayerViewModel?.ExecuteRewind();
} }
// Volume Up // Volume Up
@@ -193,7 +193,7 @@ namespace RedBookPlayer.GUI
increment *= 5; increment *= 5;
if(playerView?.PlayerViewModel?.Volume != null) if(playerView?.PlayerViewModel?.Volume != null)
playerView.PlayerViewModel.SetVolume(playerView.PlayerViewModel.Volume + increment); playerView.PlayerViewModel.ExecuteSetVolume(playerView.PlayerViewModel.Volume + increment);
} }
// Volume Down // Volume Down
@@ -206,19 +206,19 @@ namespace RedBookPlayer.GUI
decrement *= 5; decrement *= 5;
if (playerView?.PlayerViewModel?.Volume != null) if (playerView?.PlayerViewModel?.Volume != null)
playerView.PlayerViewModel.SetVolume(playerView.PlayerViewModel.Volume - decrement); playerView.PlayerViewModel.ExecuteSetVolume(playerView.PlayerViewModel.Volume - decrement);
} }
// Mute Toggle // Mute Toggle
else if(e.Key == App.Settings.ToggleMuteKey || e.Key == Key.VolumeMute) else if(e.Key == App.Settings.ToggleMuteKey || e.Key == Key.VolumeMute)
{ {
playerView?.MuteToggleButton_Click(this, null); playerView?.PlayerViewModel?.ExecuteToggleMute();
} }
// Emphasis Toggle // Emphasis Toggle
else if(e.Key == App.Settings.ToggleDeEmphasisKey) else if(e.Key == App.Settings.ToggleDeEmphasisKey)
{ {
playerView?.EnableDisableDeEmphasisButton_Click(this, null); playerView?.PlayerViewModel?.ExecuteToggleDeEmphasis();
} }
} }

View File

@@ -5,17 +5,17 @@
<StackPanel Margin="16" VerticalAlignment="Center"> <StackPanel Margin="16" VerticalAlignment="Center">
<Button Click="LoadButton_Click" Margin="32,0,32,16">Load</Button> <Button Click="LoadButton_Click" Margin="32,0,32,16">Load</Button>
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center" Margin="0,0,0,16"> <StackPanel Orientation="Horizontal" HorizontalAlignment="Center" Margin="0,0,0,16">
<Button Click="PlayButton_Click" Width="100" Margin="0,0,16,0">Play</Button> <Button Command="{Binding PlayCommand}" Width="100" Margin="0,0,16,0">Play</Button>
<Button Click="PauseButton_Click" Width="100" Margin="0,0,16,0">Pause</Button> <Button Command="{Binding PauseCommand}" 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 StopCommand}" Width="100" Margin="0,0,16,0">Stop</Button>
</StackPanel> </StackPanel>
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center" Margin="0,0,0,16"> <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 Command="{Binding PreviousTrackCommand}" 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 Command="{Binding NextTrackCommand}" 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 Command="{Binding PreviousIndexCommand}" Width="100" Margin="0,0,16,0">Previous Index</Button>
<Button Click="NextIndexButton_Click" Width="100" Margin="0,0,16,0">Next Index</Button> <Button Command="{Binding NextIndexCommand}" Width="100" Margin="0,0,16,0">Next Index</Button>
<RepeatButton Click="RewindButton_Click" Width="100" Margin="0,0,16,0">Rewind</RepeatButton> <RepeatButton Command="{Binding RewindCommand}" Width="100" Margin="0,0,16,0">Rewind</RepeatButton>
<RepeatButton Click="FastForwardButton_Click" Width="100">Fast Forward</RepeatButton> <RepeatButton Command="{Binding FastForwardCommand}" Width="100">Fast Forward</RepeatButton>
</StackPanel> </StackPanel>
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center" Margin="0,0,0,16"> <StackPanel Orientation="Horizontal" HorizontalAlignment="Center" Margin="0,0,0,16">
<StackPanel Margin="0,0,32,0"> <StackPanel Margin="0,0,32,0">
@@ -76,11 +76,11 @@
</StackPanel> </StackPanel>
</StackPanel> </StackPanel>
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center" Margin="0,0,0,16"> <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"> Margin="0,0,16,0">
Enable De-Emphasis Enable De-Emphasis
</Button> </Button>
<Button Click="DisableDeEmphasisButton_Click" IsVisible="{Binding ApplyDeEmphasis}" Width="200" <Button Command="{Binding DisableDeEmphasisCommand}" IsVisible="{Binding ApplyDeEmphasis}" Width="200"
Margin="0,0,16,0"> Margin="0,0,16,0">
Disable De-Emphasis Disable De-Emphasis
</Button> </Button>

View File

@@ -11,7 +11,7 @@ using Avalonia.Markup.Xaml;
using Avalonia.Media.Imaging; using Avalonia.Media.Imaging;
using Avalonia.Platform; using Avalonia.Platform;
using Avalonia.Threading; using Avalonia.Threading;
using RedBookPlayer.Common; using RedBookPlayer.GUI.ViewModels;
namespace RedBookPlayer.GUI namespace RedBookPlayer.GUI
{ {
@@ -267,44 +267,6 @@ namespace RedBookPlayer.GUI
await LoadImage(path); 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 #endregion
} }
} }

View File

@@ -1,8 +1,9 @@
using System.ComponentModel; using System.ComponentModel;
using System.Reactive;
using ReactiveUI; using ReactiveUI;
using RedBookPlayer.Common.Hardware; using RedBookPlayer.Common.Hardware;
namespace RedBookPlayer.Common namespace RedBookPlayer.GUI.ViewModels
{ {
public class PlayerViewModel : ReactiveObject public class PlayerViewModel : ReactiveObject
{ {
@@ -11,11 +12,6 @@ namespace RedBookPlayer.Common
/// </summary> /// </summary>
private Player _player; private Player _player;
/// <summary>
/// Last volume for mute toggling
/// </summary>
private int? _lastVolume = null;
#region Player Passthrough #region Player Passthrough
#region OpticalDisc Passthrough #region OpticalDisc Passthrough
@@ -181,6 +177,127 @@ namespace RedBookPlayer.Common
#endregion #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> /// <summary>
/// Initialize the view model with a given image path /// Initialize the view model with a given image path
/// </summary> /// </summary>
@@ -193,7 +310,7 @@ namespace RedBookPlayer.Common
public void Init(string path, bool generateMissingToc, bool loadHiddenTracks, bool loadDataTracks, bool autoPlay, int defaultVolume) public void Init(string path, bool generateMissingToc, bool loadHiddenTracks, bool loadDataTracks, bool autoPlay, int defaultVolume)
{ {
// Stop current playback, if necessary // Stop current playback, if necessary
if(Playing != null) Stop(); if(Playing != null) ExecuteStop();
// Create and attempt to initialize new Player // Create and attempt to initialize new Player
_player = new Player(path, generateMissingToc, loadHiddenTracks, loadDataTracks, autoPlay, defaultVolume); _player = new Player(path, generateMissingToc, loadHiddenTracks, loadDataTracks, autoPlay, defaultVolume);
@@ -209,60 +326,101 @@ namespace RedBookPlayer.Common
/// <summary> /// <summary>
/// Begin playback /// Begin playback
/// </summary> /// </summary>
public void Play() => _player?.Play(); public void ExecutePlay() => _player?.Play();
/// <summary> /// <summary>
/// Pause current playback /// Pause current playback
/// </summary> /// </summary>
public void Pause() => _player?.Pause(); public void ExecutePause() => _player?.Pause();
/// <summary>
/// Toggle playback
/// </summary>
public void ExecuteTogglePlayPause() => _player?.TogglePlayback();
/// <summary> /// <summary>
/// Stop current playback /// Stop current playback
/// </summary> /// </summary>
public void Stop() => _player?.Stop(); public void ExecuteStop() => _player?.Stop();
/// <summary> /// <summary>
/// Move to the next playable track /// Move to the next playable track
/// </summary> /// </summary>
public void NextTrack() => _player?.NextTrack(); public void ExecuteNextTrack() => _player?.NextTrack();
/// <summary> /// <summary>
/// Move to the previous playable track /// Move to the previous playable track
/// </summary> /// </summary>
public void PreviousTrack() => _player?.PreviousTrack(); public void ExecutePreviousTrack() => _player?.PreviousTrack();
/// <summary> /// <summary>
/// Move to the next index /// Move to the next index
/// </summary> /// </summary>
/// <param name="changeTrack">True if index changes can trigger a track change, false otherwise</param> public void ExecuteNextIndex() => _player?.NextIndex(App.Settings.IndexButtonChangeTrack);
public void NextIndex(bool changeTrack) => _player?.NextIndex(changeTrack);
/// <summary> /// <summary>
/// Move to the previous index /// Move to the previous index
/// </summary> /// </summary>
/// <param name="changeTrack">True if index changes can trigger a track change, false otherwise</param> public void ExecutePreviousIndex() => _player?.PreviousIndex(App.Settings.IndexButtonChangeTrack);
public void PreviousIndex(bool changeTrack) => _player?.PreviousIndex(changeTrack);
/// <summary> /// <summary>
/// Fast-forward playback by 75 sectors, if possible /// Fast-forward playback by 75 sectors, if possible
/// </summary> /// </summary>
public void FastForward() => _player?.FastForward(); public void ExecuteFastForward() => _player?.FastForward();
/// <summary> /// <summary>
/// Rewind playback by 75 sectors, if possible /// Rewind playback by 75 sectors, if possible
/// </summary> /// </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 #endregion
#region Helpers #region Helpers
/// <summary>
/// Set de-emphasis status
/// </summary>
/// <param name="apply"></param>
public void SetDeEmphasis(bool apply) => _player?.SetDeEmphasis(apply);
/// <summary> /// <summary>
/// Set the value for loading data tracks [CompactDisc only] /// Set the value for loading data tracks [CompactDisc only]
/// </summary> /// </summary>
@@ -275,29 +433,6 @@ namespace RedBookPlayer.Common
/// <param name="load">True to enable loading hidden tracks, false otherwise</param> /// <param name="load">True to enable loading hidden tracks, false otherwise</param>
public void SetLoadHiddenTracks(bool load) => _player?.SetLoadHiddenTracks(load); 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> /// <summary>
/// Update the view-model from the Player /// Update the view-model from the Player
/// </summary> /// </summary>