Use properties in CompactDisc

This commit is contained in:
Matt Nadareski
2021-07-12 10:57:52 -07:00
parent 29205c953b
commit bc810034d0
2 changed files with 26 additions and 30 deletions

View File

@@ -26,7 +26,7 @@ namespace RedBookPlayer.Common.Discs
return; return;
// Data tracks only and flag disabled means we can't do anything // Data tracks only and flag disabled means we can't do anything
if(_image.Tracks.All(t => t.TrackType != TrackType.Audio) && !_loadDataTracks) if(_image.Tracks.All(t => t.TrackType != TrackType.Audio) && !LoadDataTracks)
return; return;
// Cache the value and the current track number // Cache the value and the current track number
@@ -42,12 +42,12 @@ namespace RedBookPlayer.Common.Discs
if(cachedValue > _image.Tracks.Max(t => t.TrackSequence)) if(cachedValue > _image.Tracks.Max(t => t.TrackSequence))
{ {
cachedValue = (int)_image.Tracks.Min(t => t.TrackSequence); cachedValue = (int)_image.Tracks.Min(t => t.TrackSequence);
if(cachedValue == 0 && !_loadHiddenTracks) if(cachedValue == 0 && !LoadHiddenTracks)
cachedValue++; cachedValue++;
} }
// If we're under the first track and we're not loading hidden tracks, wrap around // If we're under the first track and we're not loading hidden tracks, wrap around
else if(cachedValue < 1 && !_loadHiddenTracks) else if(cachedValue < 1 && !LoadHiddenTracks)
{ {
cachedValue = (int)_image.Tracks.Max(t => t.TrackSequence); cachedValue = (int)_image.Tracks.Max(t => t.TrackSequence);
} }
@@ -69,7 +69,7 @@ namespace RedBookPlayer.Common.Discs
SetTrackFlags(track); SetTrackFlags(track);
// If the track is playable, just return // If the track is playable, just return
if(TrackType == TrackType.Audio || _loadDataTracks) if(TrackType == TrackType.Audio || LoadDataTracks)
break; break;
// If we're not playing the track, skip // If we're not playing the track, skip
@@ -215,6 +215,16 @@ namespace RedBookPlayer.Common.Discs
private set => this.RaiseAndSetIfChanged(ref _trackHasEmphasis, value); private set => this.RaiseAndSetIfChanged(ref _trackHasEmphasis, value);
} }
/// <summary>
/// Indicate if data tracks should be loaded
/// </summary>
public bool LoadDataTracks { get; set; } = false;
/// <summary>
/// Indicate if hidden tracks should be loaded
/// </summary>
public bool LoadHiddenTracks { get; set; } = false;
private bool _quadChannel; private bool _quadChannel;
private bool _isDataTrack; private bool _isDataTrack;
private bool _copyAllowed; private bool _copyAllowed;
@@ -244,16 +254,6 @@ namespace RedBookPlayer.Common.Discs
/// </summary> /// </summary>
private readonly bool _generateMissingToc = false; private readonly bool _generateMissingToc = false;
/// <summary>
/// Indicate if data tracks should be loaded
/// </summary>
private bool _loadDataTracks = false;
/// <summary>
/// Indicate if hidden tracks should be loaded
/// </summary>
private bool _loadHiddenTracks = false;
/// <summary> /// <summary>
/// Current disc table of contents /// Current disc table of contents
/// </summary> /// </summary>
@@ -270,8 +270,8 @@ namespace RedBookPlayer.Common.Discs
public CompactDisc(bool generateMissingToc, bool loadHiddenTracks, bool loadDataTracks) public CompactDisc(bool generateMissingToc, bool loadHiddenTracks, bool loadDataTracks)
{ {
_generateMissingToc = generateMissingToc; _generateMissingToc = generateMissingToc;
_loadHiddenTracks = loadHiddenTracks; LoadHiddenTracks = loadHiddenTracks;
_loadDataTracks = loadDataTracks; LoadDataTracks = loadDataTracks;
} }
/// <inheritdoc/> /// <inheritdoc/>
@@ -422,18 +422,6 @@ namespace RedBookPlayer.Common.Discs
LoadTrack(CurrentTrackNumber); LoadTrack(CurrentTrackNumber);
} }
/// <summary>
/// Set the value for loading data tracks
/// </summary>
/// <param name="load">True to enable loading data tracks, false otherwise</param>
public void SetLoadDataTracks(bool load) => _loadDataTracks = load;
/// <summary>
/// Set the value for loading hidden tracks
/// </summary>
/// <param name="load">True to enable loading hidden tracks, false otherwise</param>
public void SetLoadHiddenTracks(bool load) => _loadHiddenTracks = load;
/// <inheritdoc/> /// <inheritdoc/>
public override void SetTotalIndexes() public override void SetTotalIndexes()
{ {

View File

@@ -459,13 +459,21 @@ namespace RedBookPlayer.Common.Hardware
/// Set the value for loading data tracks [CompactDisc only] /// Set the value for loading data tracks [CompactDisc only]
/// </summary> /// </summary>
/// <param name="load">True to enable loading data tracks, false otherwise</param> /// <param name="load">True to enable loading data tracks, false otherwise</param>
public void SetLoadDataTracks(bool load) => (_opticalDisc as CompactDisc)?.SetLoadDataTracks(load); public void SetLoadDataTracks(bool load)
{
if(_opticalDisc is CompactDisc compactDisc)
compactDisc.LoadDataTracks = load;
}
/// <summary> /// <summary>
/// Set the value for loading hidden tracks [CompactDisc only] /// Set the value for loading hidden tracks [CompactDisc only]
/// </summary> /// </summary>
/// <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)
{
if(_opticalDisc is CompactDisc compactDisc)
compactDisc.LoadHiddenTracks = load;
}
/// <summary> /// <summary>
/// Update the player from the current OpticalDisc /// Update the player from the current OpticalDisc