mirror of
https://github.com/aaru-dps/RedBookPlayer.git
synced 2025-12-16 19:24:41 +00:00
Separate out disc handling
This commit is contained in:
@@ -656,6 +656,7 @@ namespace RedBookPlayer.GUI.ViewModels
|
|||||||
PlayerOptions playerOptions = new PlayerOptions
|
PlayerOptions playerOptions = new PlayerOptions
|
||||||
{
|
{
|
||||||
DataPlayback = App.Settings.DataPlayback,
|
DataPlayback = App.Settings.DataPlayback,
|
||||||
|
DiscHandling = App.Settings.DiscHandling,
|
||||||
LoadHiddenTracks = App.Settings.PlayHiddenTracks,
|
LoadHiddenTracks = App.Settings.PlayHiddenTracks,
|
||||||
RepeatMode = App.Settings.RepeatMode,
|
RepeatMode = App.Settings.RepeatMode,
|
||||||
SessionHandling = App.Settings.SessionHandling,
|
SessionHandling = App.Settings.SessionHandling,
|
||||||
@@ -684,6 +685,7 @@ namespace RedBookPlayer.GUI.ViewModels
|
|||||||
public void RefreshFromSettings()
|
public void RefreshFromSettings()
|
||||||
{
|
{
|
||||||
SetDataPlayback(App.Settings.DataPlayback);
|
SetDataPlayback(App.Settings.DataPlayback);
|
||||||
|
SetDiscHandling(App.Settings.DiscHandling);
|
||||||
SetLoadHiddenTracks(App.Settings.PlayHiddenTracks);
|
SetLoadHiddenTracks(App.Settings.PlayHiddenTracks);
|
||||||
SetRepeatMode(App.Settings.RepeatMode);
|
SetRepeatMode(App.Settings.RepeatMode);
|
||||||
SetSessionHandling(App.Settings.SessionHandling);
|
SetSessionHandling(App.Settings.SessionHandling);
|
||||||
@@ -727,6 +729,12 @@ namespace RedBookPlayer.GUI.ViewModels
|
|||||||
/// <param name="dataPlayback">New playback value</param>
|
/// <param name="dataPlayback">New playback value</param>
|
||||||
public void SetDataPlayback(DataPlayback dataPlayback) => _player?.SetDataPlayback(dataPlayback);
|
public void SetDataPlayback(DataPlayback dataPlayback) => _player?.SetDataPlayback(dataPlayback);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Set disc handling method
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="discHandling">New playback value</param>
|
||||||
|
public void SetDiscHandling(DiscHandling discHandling) => _player?.SetDiscHandling(discHandling);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Set the value for loading hidden tracks [CompactDisc only]
|
/// Set the value for loading hidden tracks [CompactDisc only]
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -21,6 +21,12 @@ namespace RedBookPlayer.GUI.ViewModels
|
|||||||
[JsonIgnore]
|
[JsonIgnore]
|
||||||
public List<DataPlayback> DataPlaybackValues => GenerateDataPlaybackList();
|
public List<DataPlayback> DataPlaybackValues => GenerateDataPlaybackList();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// List of all disc handling values
|
||||||
|
/// </summary>
|
||||||
|
[JsonIgnore]
|
||||||
|
public List<DiscHandling> DiscHandlingValues => GenerateDiscHandlingList();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// List of all repeat mode values
|
/// List of all repeat mode values
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -49,6 +55,11 @@ namespace RedBookPlayer.GUI.ViewModels
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public int NumberOfDiscs { get; set; } = 1;
|
public int NumberOfDiscs { get; set; } = 1;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Indicates how to deal with multiple discs
|
||||||
|
/// </summary>
|
||||||
|
public DiscHandling DiscHandling { get; set; } = DiscHandling.SingleDisc;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Indicates if an index change can trigger a track change
|
/// Indicates if an index change can trigger a track change
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -77,7 +88,7 @@ namespace RedBookPlayer.GUI.ViewModels
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Indicates how to repeat tracks
|
/// Indicates how to repeat tracks
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public RepeatMode RepeatMode { get; set; } = RepeatMode.AllSingleDisc;
|
public RepeatMode RepeatMode { get; set; } = RepeatMode.All;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Indicates how to handle tracks on different sessions
|
/// Indicates how to handle tracks on different sessions
|
||||||
@@ -290,6 +301,11 @@ namespace RedBookPlayer.GUI.ViewModels
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
private List<DataPlayback> GenerateDataPlaybackList() => Enum.GetValues(typeof(DataPlayback)).Cast<DataPlayback>().ToList();
|
private List<DataPlayback> GenerateDataPlaybackList() => Enum.GetValues(typeof(DataPlayback)).Cast<DataPlayback>().ToList();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Generate the list of DiscHandling values
|
||||||
|
/// </summary>
|
||||||
|
private List<DiscHandling> GenerateDiscHandlingList() => Enum.GetValues(typeof(DiscHandling)).Cast<DiscHandling>().ToList();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Generate the list of Key values
|
/// Generate the list of Key values
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -45,6 +45,11 @@
|
|||||||
<NumericUpDown Name="NumberOfDiscs" Margin="8,0,0,0" Width="120"
|
<NumericUpDown Name="NumberOfDiscs" Margin="8,0,0,0" Width="120"
|
||||||
Value="{Binding NumberOfDiscs, Mode=TwoWay}" Minimum="1" Maximum="100" />
|
Value="{Binding NumberOfDiscs, Mode=TwoWay}" Minimum="1" Maximum="100" />
|
||||||
</WrapPanel>
|
</WrapPanel>
|
||||||
|
<WrapPanel Margin="0,0,0,16">
|
||||||
|
<TextBlock Width="120">Disc Handling</TextBlock>
|
||||||
|
<ComboBox Name="DiscHandling" Margin="8,0,0,0" Width="120"
|
||||||
|
Items="{Binding DiscHandlingValues}" SelectedItem="{Binding DiscHandling, Mode=TwoWay}" />
|
||||||
|
</WrapPanel>
|
||||||
<WrapPanel Margin="0,0,0,16">
|
<WrapPanel Margin="0,0,0,16">
|
||||||
<CheckBox IsChecked="{Binding GenerateMissingTOC}" Margin="0,0,8,0"/>
|
<CheckBox IsChecked="{Binding GenerateMissingTOC}" Margin="0,0,8,0"/>
|
||||||
<TextBlock VerticalAlignment="Center">Generate a TOC if the disc is missing one</TextBlock>
|
<TextBlock VerticalAlignment="Center">Generate a TOC if the disc is missing one</TextBlock>
|
||||||
|
|||||||
@@ -21,6 +21,23 @@ namespace RedBookPlayer.Models
|
|||||||
Play = 2,
|
Play = 2,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Determine how to handle multiple discs
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>Used with both repeat and shuffle</remarks>
|
||||||
|
public enum DiscHandling
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Only deal with tracks on the current disc
|
||||||
|
/// </summary>
|
||||||
|
SingleDisc = 0,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Deal with tracks on all loaded discs
|
||||||
|
/// </summary>
|
||||||
|
MultiDisc = 1,
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Current player state
|
/// Current player state
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -63,14 +80,9 @@ namespace RedBookPlayer.Models
|
|||||||
Single,
|
Single,
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Repeat all tracks on a single disc
|
/// Repeat all tracks
|
||||||
/// </summary>
|
/// </summary>
|
||||||
AllSingleDisc,
|
All,
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Repeat all tracks on a multiple discs
|
|
||||||
/// </summary>
|
|
||||||
AllMultiDisc,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@@ -22,6 +22,8 @@ namespace RedBookPlayer.Models.Hardware
|
|||||||
private set => this.RaiseAndSetIfChanged(ref _initialized, value);
|
private set => this.RaiseAndSetIfChanged(ref _initialized, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#region Playback Passthrough
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Currently selected disc
|
/// Currently selected disc
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -40,6 +42,60 @@ namespace RedBookPlayer.Models.Hardware
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Indicates how to deal with multiple discs
|
||||||
|
/// </summary>
|
||||||
|
public DiscHandling DiscHandling
|
||||||
|
{
|
||||||
|
get => _discHandling;
|
||||||
|
private set => this.RaiseAndSetIfChanged(ref _discHandling, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Indicates how to handle playback of data tracks
|
||||||
|
/// </summary>
|
||||||
|
public DataPlayback DataPlayback
|
||||||
|
{
|
||||||
|
get => _dataPlayback;
|
||||||
|
private set => this.RaiseAndSetIfChanged(ref _dataPlayback, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Indicate if hidden tracks should be loaded
|
||||||
|
/// </summary>
|
||||||
|
public bool LoadHiddenTracks
|
||||||
|
{
|
||||||
|
get => _loadHiddenTracks;
|
||||||
|
private set => this.RaiseAndSetIfChanged(ref _loadHiddenTracks, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Indicates the repeat mode
|
||||||
|
/// </summary>
|
||||||
|
public RepeatMode RepeatMode
|
||||||
|
{
|
||||||
|
get => _repeatMode;
|
||||||
|
private set => this.RaiseAndSetIfChanged(ref _repeatMode, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Indicates how tracks on different session should be handled
|
||||||
|
/// </summary>
|
||||||
|
public SessionHandling SessionHandling
|
||||||
|
{
|
||||||
|
get => _sessionHandling;
|
||||||
|
private set => this.RaiseAndSetIfChanged(ref _sessionHandling, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Indicates if de-emphasis should be applied
|
||||||
|
/// </summary>
|
||||||
|
public bool ApplyDeEmphasis
|
||||||
|
{
|
||||||
|
get => _applyDeEmphasis;
|
||||||
|
private set => this.RaiseAndSetIfChanged(ref _applyDeEmphasis, value);
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Should invoke playback mode changes
|
/// Should invoke playback mode changes
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -52,8 +108,16 @@ namespace RedBookPlayer.Models.Hardware
|
|||||||
private bool _initialized;
|
private bool _initialized;
|
||||||
private int _numberOfDiscs;
|
private int _numberOfDiscs;
|
||||||
private int _currentDisc;
|
private int _currentDisc;
|
||||||
|
private DiscHandling _discHandling;
|
||||||
|
private bool _loadHiddenTracks;
|
||||||
|
private DataPlayback _dataPlayback;
|
||||||
|
private RepeatMode _repeatMode;
|
||||||
|
private SessionHandling _sessionHandling;
|
||||||
|
private bool _applyDeEmphasis;
|
||||||
private bool _shouldInvokePlaybackModes;
|
private bool _shouldInvokePlaybackModes;
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
#region OpticalDisc Passthrough
|
#region OpticalDisc Passthrough
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -206,51 +270,6 @@ namespace RedBookPlayer.Models.Hardware
|
|||||||
private set => this.RaiseAndSetIfChanged(ref _playerState, value);
|
private set => this.RaiseAndSetIfChanged(ref _playerState, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Indicates how to handle playback of data tracks
|
|
||||||
/// </summary>
|
|
||||||
public DataPlayback DataPlayback
|
|
||||||
{
|
|
||||||
get => _dataPlayback;
|
|
||||||
private set => this.RaiseAndSetIfChanged(ref _dataPlayback, value);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Indicate if hidden tracks should be loaded
|
|
||||||
/// </summary>
|
|
||||||
public bool LoadHiddenTracks
|
|
||||||
{
|
|
||||||
get => _loadHiddenTracks;
|
|
||||||
private set => this.RaiseAndSetIfChanged(ref _loadHiddenTracks, value);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Indicates the repeat mode
|
|
||||||
/// </summary>
|
|
||||||
public RepeatMode RepeatMode
|
|
||||||
{
|
|
||||||
get => _repeatMode;
|
|
||||||
private set => this.RaiseAndSetIfChanged(ref _repeatMode, value);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Indicates how tracks on different session should be handled
|
|
||||||
/// </summary>
|
|
||||||
public SessionHandling SessionHandling
|
|
||||||
{
|
|
||||||
get => _sessionHandling;
|
|
||||||
private set => this.RaiseAndSetIfChanged(ref _sessionHandling, value);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Indicates if de-emphasis should be applied
|
|
||||||
/// </summary>
|
|
||||||
public bool ApplyDeEmphasis
|
|
||||||
{
|
|
||||||
get => _applyDeEmphasis;
|
|
||||||
private set => this.RaiseAndSetIfChanged(ref _applyDeEmphasis, value);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Current playback volume
|
/// Current playback volume
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -261,11 +280,6 @@ namespace RedBookPlayer.Models.Hardware
|
|||||||
}
|
}
|
||||||
|
|
||||||
private PlayerState _playerState;
|
private PlayerState _playerState;
|
||||||
private DataPlayback _dataPlayback;
|
|
||||||
private bool _loadHiddenTracks;
|
|
||||||
private RepeatMode _repeatMode;
|
|
||||||
private SessionHandling _sessionHandling;
|
|
||||||
private bool _applyDeEmphasis;
|
|
||||||
private int _volume;
|
private int _volume;
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
@@ -340,6 +354,7 @@ namespace RedBookPlayer.Models.Hardware
|
|||||||
|
|
||||||
// Set player options
|
// Set player options
|
||||||
DataPlayback = playerOptions.DataPlayback;
|
DataPlayback = playerOptions.DataPlayback;
|
||||||
|
DiscHandling = playerOptions.DiscHandling;
|
||||||
LoadHiddenTracks = playerOptions.LoadHiddenTracks;
|
LoadHiddenTracks = playerOptions.LoadHiddenTracks;
|
||||||
RepeatMode = playerOptions.RepeatMode;
|
RepeatMode = playerOptions.RepeatMode;
|
||||||
SessionHandling = playerOptions.SessionHandling;
|
SessionHandling = playerOptions.SessionHandling;
|
||||||
@@ -710,7 +725,7 @@ namespace RedBookPlayer.Models.Hardware
|
|||||||
int cachedTrackNumber;
|
int cachedTrackNumber;
|
||||||
|
|
||||||
// Take care of disc switching first
|
// Take care of disc switching first
|
||||||
if(RepeatMode == RepeatMode.AllMultiDisc)
|
if(DiscHandling == DiscHandling.MultiDisc)
|
||||||
{
|
{
|
||||||
if(trackNumber > (int)compactDisc.Tracks.Max(t => t.TrackSequence))
|
if(trackNumber > (int)compactDisc.Tracks.Max(t => t.TrackSequence))
|
||||||
{
|
{
|
||||||
@@ -800,7 +815,7 @@ namespace RedBookPlayer.Models.Hardware
|
|||||||
{
|
{
|
||||||
if(trackNumber >= _opticalDiscs[CurrentDisc].TotalTracks)
|
if(trackNumber >= _opticalDiscs[CurrentDisc].TotalTracks)
|
||||||
{
|
{
|
||||||
if(RepeatMode == RepeatMode.AllMultiDisc)
|
if(DiscHandling == DiscHandling.MultiDisc)
|
||||||
{
|
{
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
@@ -813,7 +828,7 @@ namespace RedBookPlayer.Models.Hardware
|
|||||||
}
|
}
|
||||||
else if(trackNumber < 1)
|
else if(trackNumber < 1)
|
||||||
{
|
{
|
||||||
if(RepeatMode == RepeatMode.AllMultiDisc)
|
if(DiscHandling == DiscHandling.MultiDisc)
|
||||||
{
|
{
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
@@ -1043,6 +1058,12 @@ namespace RedBookPlayer.Models.Hardware
|
|||||||
/// <param name="dataPlayback">New playback value</param>
|
/// <param name="dataPlayback">New playback value</param>
|
||||||
public void SetDataPlayback(DataPlayback dataPlayback) => DataPlayback = dataPlayback;
|
public void SetDataPlayback(DataPlayback dataPlayback) => DataPlayback = dataPlayback;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Set disc handling method
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="discHandling">New playback value</param>
|
||||||
|
public void SetDiscHandling(DiscHandling discHandling) => DiscHandling = discHandling;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Set the value for loading hidden tracks [CompactDisc only]
|
/// Set the value for loading hidden tracks [CompactDisc only]
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -1085,10 +1106,10 @@ namespace RedBookPlayer.Models.Hardware
|
|||||||
case RepeatMode.Single:
|
case RepeatMode.Single:
|
||||||
_opticalDiscs[CurrentDisc].LoadTrack(CurrentTrackNumber);
|
_opticalDiscs[CurrentDisc].LoadTrack(CurrentTrackNumber);
|
||||||
break;
|
break;
|
||||||
case RepeatMode.AllSingleDisc:
|
case RepeatMode.All when DiscHandling == DiscHandling.SingleDisc:
|
||||||
SelectTrack(1);
|
SelectTrack(1);
|
||||||
break;
|
break;
|
||||||
case RepeatMode.AllMultiDisc:
|
case RepeatMode.All when DiscHandling == DiscHandling.MultiDisc:
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
NextDisc();
|
NextDisc();
|
||||||
|
|||||||
@@ -7,6 +7,11 @@ namespace RedBookPlayer.Models.Discs
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public DataPlayback DataPlayback { get; set; } = DataPlayback.Skip;
|
public DataPlayback DataPlayback { get; set; } = DataPlayback.Skip;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Indicates how to deal with multiple discs
|
||||||
|
/// </summary>
|
||||||
|
public DiscHandling DiscHandling { get; set; } = DiscHandling.SingleDisc;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Indicate if hidden tracks should be loaded
|
/// Indicate if hidden tracks should be loaded
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
Reference in New Issue
Block a user