Remove needless method calls

This commit is contained in:
Matt Nadareski
2021-07-05 13:00:20 -07:00
parent c43317f001
commit 761afb9344

View File

@@ -216,7 +216,9 @@ namespace RedBookPlayer.Hardware
// Mark the player as ready // Mark the player as ready
Initialized = true; Initialized = true;
SetDiscInformation();
// Force a refresh of the disc information
OpticalDiscStateChanged(this, null);
} }
#region Playback #region Playback
@@ -286,8 +288,6 @@ namespace RedBookPlayer.Hardware
if(_opticalDisc is CompactDisc compactDisc) if(_opticalDisc is CompactDisc compactDisc)
_soundOutput.SetDeEmphasis(compactDisc.TrackHasEmphasis); _soundOutput.SetDeEmphasis(compactDisc.TrackHasEmphasis);
SetDiscInformation();
if(wasPlaying == true) Play(); if(wasPlaying == true) Play();
} }
@@ -307,8 +307,6 @@ namespace RedBookPlayer.Hardware
if(_opticalDisc is CompactDisc compactDisc) if(_opticalDisc is CompactDisc compactDisc)
_soundOutput.SetDeEmphasis(compactDisc.TrackHasEmphasis); _soundOutput.SetDeEmphasis(compactDisc.TrackHasEmphasis);
SetDiscInformation();
if(wasPlaying == true) Play(); if(wasPlaying == true) Play();
} }
@@ -328,8 +326,6 @@ namespace RedBookPlayer.Hardware
if(_opticalDisc is CompactDisc compactDisc) if(_opticalDisc is CompactDisc compactDisc)
_soundOutput.SetDeEmphasis(compactDisc.TrackHasEmphasis); _soundOutput.SetDeEmphasis(compactDisc.TrackHasEmphasis);
SetDiscInformation();
if(wasPlaying == true) Play(); if(wasPlaying == true) Play();
} }
@@ -350,8 +346,6 @@ namespace RedBookPlayer.Hardware
if(_opticalDisc is CompactDisc compactDisc) if(_opticalDisc is CompactDisc compactDisc)
_soundOutput.SetDeEmphasis(compactDisc.TrackHasEmphasis); _soundOutput.SetDeEmphasis(compactDisc.TrackHasEmphasis);
SetDiscInformation();
if(wasPlaying == true) Play(); if(wasPlaying == true) Play();
} }
@@ -364,7 +358,6 @@ namespace RedBookPlayer.Hardware
return; return;
_opticalDisc.CurrentSector = Math.Min(_opticalDisc.TotalSectors, _opticalDisc.CurrentSector + 75); _opticalDisc.CurrentSector = Math.Min(_opticalDisc.TotalSectors, _opticalDisc.CurrentSector + 75);
SetDiscInformation();
} }
/// <summary> /// <summary>
@@ -377,8 +370,6 @@ namespace RedBookPlayer.Hardware
if(_opticalDisc.CurrentSector >= 75) if(_opticalDisc.CurrentSector >= 75)
_opticalDisc.CurrentSector -= 75; _opticalDisc.CurrentSector -= 75;
SetDiscInformation();
} }
#endregion #endregion
@@ -400,22 +391,7 @@ namespace RedBookPlayer.Hardware
/// <summary> /// <summary>
/// Update the player from the current OpticalDisc /// Update the player from the current OpticalDisc
/// </summary> /// </summary>
private void OpticalDiscStateChanged(object sender, PropertyChangedEventArgs e) => SetDiscInformation(); private void OpticalDiscStateChanged(object sender, PropertyChangedEventArgs e)
/// <summary>
/// Update the player from the current SoundOutput
/// </summary>
private void SoundOutputStateChanged(object sender, PropertyChangedEventArgs e)
{
Playing = _soundOutput.Playing;
ApplyDeEmphasis = _soundOutput.ApplyDeEmphasis;
//Volume = _soundOutput.Volume;
}
/// <summary>
/// Set all current disc information
/// </summary>
private void SetDiscInformation()
{ {
CurrentTrackNumber = _opticalDisc.CurrentTrackNumber; CurrentTrackNumber = _opticalDisc.CurrentTrackNumber;
CurrentTrackIndex = _opticalDisc.CurrentTrackIndex; CurrentTrackIndex = _opticalDisc.CurrentTrackIndex;
@@ -440,6 +416,16 @@ namespace RedBookPlayer.Hardware
} }
} }
/// <summary>
/// Update the player from the current SoundOutput
/// </summary>
private void SoundOutputStateChanged(object sender, PropertyChangedEventArgs e)
{
Playing = _soundOutput.Playing;
ApplyDeEmphasis = _soundOutput.ApplyDeEmphasis;
Volume = _soundOutput.Volume;
}
#endregion #endregion
} }
} }