mirror of
https://github.com/aaru-dps/RedBookPlayer.git
synced 2025-12-16 19:24:41 +00:00
Add new logic to settings; fix Player
This commit is contained in:
@@ -364,7 +364,7 @@ namespace RedBookPlayer.GUI.ViewModels
|
|||||||
ToggleDeEmphasisCommand = ReactiveCommand.Create(ExecuteToggleDeEmphasis);
|
ToggleDeEmphasisCommand = ReactiveCommand.Create(ExecuteToggleDeEmphasis);
|
||||||
|
|
||||||
// Initialize Player
|
// Initialize Player
|
||||||
_player = new Player(App.Settings.Volume);
|
_player = new Player(App.Settings.NumberOfDiscs, App.Settings.Volume);
|
||||||
PlayerState = PlayerState.NoDisc;
|
PlayerState = PlayerState.NoDisc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -44,6 +44,11 @@ namespace RedBookPlayer.GUI.ViewModels
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public bool AutoPlay { get; set; } = false;
|
public bool AutoPlay { get; set; } = false;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Indicates the number of discs to allow loading and changing
|
||||||
|
/// </summary>
|
||||||
|
public int NumberOfDiscs { get; set; } = 1;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Indicates if an index change can trigger a track change
|
/// Indicates if an index change can trigger a track change
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -144,6 +149,16 @@ namespace RedBookPlayer.GUI.ViewModels
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public Key EjectKey { get; set; } = Key.OemTilde;
|
public Key EjectKey { get; set; } = Key.OemTilde;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Key assigned to move to the next disc
|
||||||
|
/// </summary>
|
||||||
|
public Key NextDiscKey { get; set; } = Key.PageUp;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Key assigned to move to the previous disc
|
||||||
|
/// </summary>
|
||||||
|
public Key PreviousDiscKey { get; set; } = Key.PageDown;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Key assigned to move to the next track
|
/// Key assigned to move to the next track
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -26,9 +26,9 @@ namespace RedBookPlayer.Models.Hardware
|
|||||||
private set
|
private set
|
||||||
{
|
{
|
||||||
int temp = value;
|
int temp = value;
|
||||||
if (temp < 4)
|
if (temp < 0)
|
||||||
temp = 0;
|
temp = _numberOfDiscs - 1;
|
||||||
else if (temp >= 5)
|
else if (temp >= _numberOfDiscs)
|
||||||
temp = 0;
|
temp = 0;
|
||||||
|
|
||||||
this.RaiseAndSetIfChanged(ref _currentDisc, temp);
|
this.RaiseAndSetIfChanged(ref _currentDisc, temp);
|
||||||
@@ -36,6 +36,7 @@ namespace RedBookPlayer.Models.Hardware
|
|||||||
}
|
}
|
||||||
|
|
||||||
private bool _initialized;
|
private bool _initialized;
|
||||||
|
private int _numberOfDiscs;
|
||||||
private int _currentDisc;
|
private int _currentDisc;
|
||||||
|
|
||||||
#region OpticalDisc Passthrough
|
#region OpticalDisc Passthrough
|
||||||
@@ -229,14 +230,12 @@ namespace RedBookPlayer.Models.Hardware
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Sound output handling class
|
/// Sound output handling class
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <remarks>TODO: Link sound outputs to discs in a 1:1 configuration</remarks>
|
private readonly SoundOutput[] _soundOutputs;
|
||||||
private readonly SoundOutput[] _soundOutputs = new SoundOutput[5];
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// OpticalDisc object
|
/// OpticalDisc object
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <remarks>TODO: Make the number of discs in the changer configurable</remarks>
|
private OpticalDiscBase[] _opticalDiscs;
|
||||||
private OpticalDiscBase[] _opticalDiscs = new OpticalDiscBase[5];
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Last volume for mute toggling
|
/// Last volume for mute toggling
|
||||||
@@ -248,12 +247,21 @@ namespace RedBookPlayer.Models.Hardware
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Constructor
|
/// Constructor
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
/// <param name="numberOfDiscs">Number of discs to allow loading</param>
|
||||||
/// <param name="defaultVolume">Default volume between 0 and 100 to use when starting playback</param>
|
/// <param name="defaultVolume">Default volume between 0 and 100 to use when starting playback</param>
|
||||||
public Player(int defaultVolume)
|
public Player(int numberOfDiscs, int defaultVolume)
|
||||||
{
|
{
|
||||||
Initialized = false;
|
Initialized = false;
|
||||||
|
|
||||||
|
if (numberOfDiscs <= 0)
|
||||||
|
numberOfDiscs = 1;
|
||||||
|
|
||||||
|
_numberOfDiscs = numberOfDiscs;
|
||||||
|
_soundOutputs = new SoundOutput[_numberOfDiscs];
|
||||||
|
_opticalDiscs = new OpticalDiscBase[numberOfDiscs];
|
||||||
|
|
||||||
_currentDisc = 0;
|
_currentDisc = 0;
|
||||||
for (int i = 0; i < 5; i++)
|
for (int i = 0; i < _numberOfDiscs; i++)
|
||||||
{
|
{
|
||||||
_soundOutputs[i] = new SoundOutput(defaultVolume);
|
_soundOutputs[i] = new SoundOutput(defaultVolume);
|
||||||
_soundOutputs[i].SetDeEmphasis(false);
|
_soundOutputs[i].SetDeEmphasis(false);
|
||||||
@@ -387,7 +395,7 @@ namespace RedBookPlayer.Models.Hardware
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Move to the next loaded disc
|
/// Move to the next disc
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public void NextDisc()
|
public void NextDisc()
|
||||||
{
|
{
|
||||||
@@ -395,24 +403,25 @@ namespace RedBookPlayer.Models.Hardware
|
|||||||
if (wasPlaying == PlayerState.Playing)
|
if (wasPlaying == PlayerState.Playing)
|
||||||
Stop();
|
Stop();
|
||||||
|
|
||||||
int lastdisc = CurrentDisc++;
|
CurrentDisc++;
|
||||||
while (CurrentDisc != lastdisc)
|
if (_opticalDiscs[CurrentDisc] != null && _opticalDiscs[CurrentDisc].Initialized)
|
||||||
{
|
{
|
||||||
if (_opticalDiscs[CurrentDisc] != null && _opticalDiscs[CurrentDisc].Initialized)
|
Initialized = true;
|
||||||
break;
|
OpticalDiscStateChanged(this, null);
|
||||||
|
SoundOutputStateChanged(this, null);
|
||||||
|
|
||||||
CurrentDisc++;
|
if(wasPlaying == PlayerState.Playing)
|
||||||
|
Play();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
PlayerState = PlayerState.NoDisc;
|
||||||
|
Initialized = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
OpticalDiscStateChanged(this, null);
|
|
||||||
SoundOutputStateChanged(this, null);
|
|
||||||
|
|
||||||
if(wasPlaying == PlayerState.Playing)
|
|
||||||
Play();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Move to the previous loaded disc
|
/// Move to the previous disc
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public void PreviousDisc()
|
public void PreviousDisc()
|
||||||
{
|
{
|
||||||
@@ -420,20 +429,21 @@ namespace RedBookPlayer.Models.Hardware
|
|||||||
if (wasPlaying == PlayerState.Playing)
|
if (wasPlaying == PlayerState.Playing)
|
||||||
Stop();
|
Stop();
|
||||||
|
|
||||||
int lastdisc = CurrentDisc--;
|
CurrentDisc--;
|
||||||
while (CurrentDisc != lastdisc)
|
if (_opticalDiscs[CurrentDisc] != null && _opticalDiscs[CurrentDisc].Initialized)
|
||||||
{
|
{
|
||||||
if (_opticalDiscs[CurrentDisc] != null && _opticalDiscs[CurrentDisc].Initialized)
|
Initialized = true;
|
||||||
break;
|
OpticalDiscStateChanged(this, null);
|
||||||
|
SoundOutputStateChanged(this, null);
|
||||||
|
|
||||||
CurrentDisc--;
|
if(wasPlaying == PlayerState.Playing)
|
||||||
|
Play();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
PlayerState = PlayerState.NoDisc;
|
||||||
|
Initialized = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
OpticalDiscStateChanged(this, null);
|
|
||||||
SoundOutputStateChanged(this, null);
|
|
||||||
|
|
||||||
if(wasPlaying == PlayerState.Playing)
|
|
||||||
Play();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
Reference in New Issue
Block a user