Allow loading multiple images at once

This commit is contained in:
Matt Nadareski
2021-10-05 11:17:19 -07:00
parent 2bbfd2b2a7
commit 321490bbb4
3 changed files with 108 additions and 12 deletions

View File

@@ -6,6 +6,7 @@ using RedBookPlayer.Models.Factories;
namespace RedBookPlayer.Models.Hardware
{
// TODO: Add direct index selection by number
public class Player : ReactiveObject
{
/// <summary>
@@ -404,6 +405,32 @@ namespace RedBookPlayer.Models.Hardware
Initialized = false;
}
/// <summary>
/// Select a particular disc by number
/// </summary>
public void SelectDisc(int discNumber)
{
PlayerState wasPlaying = PlayerState;
if (wasPlaying == PlayerState.Playing)
Stop();
CurrentDisc = discNumber;
if (_opticalDiscs[CurrentDisc] != null && _opticalDiscs[CurrentDisc].Initialized)
{
Initialized = true;
OpticalDiscStateChanged(this, null);
SoundOutputStateChanged(this, null);
if(wasPlaying == PlayerState.Playing)
Play();
}
else
{
PlayerState = PlayerState.NoDisc;
Initialized = false;
}
}
/// <summary>
/// Move to the next disc
/// </summary>
@@ -456,6 +483,30 @@ namespace RedBookPlayer.Models.Hardware
}
}
/// <summary>
/// Select a particular track by number
/// </summary>
public void SelectTrack(int trackNumber)
{
if(_opticalDiscs[CurrentDisc] == null || !_opticalDiscs[CurrentDisc].Initialized)
return;
PlayerState wasPlaying = PlayerState;
if(wasPlaying == PlayerState.Playing)
Pause();
if(trackNumber < (HiddenTrack ? 0 : 1) || trackNumber > TotalTracks)
_opticalDiscs[CurrentDisc].LoadFirstTrack();
else
_opticalDiscs[CurrentDisc].LoadTrack(trackNumber);
if(_opticalDiscs[CurrentDisc] is CompactDisc compactDisc)
_soundOutputs[CurrentDisc].SetDeEmphasis(compactDisc.TrackHasEmphasis);
if(wasPlaying == PlayerState.Playing)
Play();
}
/// <summary>
/// Move to the next playable track
/// </summary>