mirror of
https://github.com/aaru-dps/RedBookPlayer.git
synced 2025-12-16 19:24:41 +00:00
Add playing status and times to view model
This commit is contained in:
@@ -4,6 +4,37 @@ namespace RedBookPlayer.GUI
|
|||||||
{
|
{
|
||||||
public class PlayerViewModel : ReactiveObject
|
public class PlayerViewModel : ReactiveObject
|
||||||
{
|
{
|
||||||
|
#region Player Status
|
||||||
|
|
||||||
|
private bool _playing;
|
||||||
|
public bool Playing
|
||||||
|
{
|
||||||
|
get => _playing;
|
||||||
|
set => this.RaiseAndSetIfChanged(ref _playing, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
private ulong _currentSector;
|
||||||
|
public ulong CurrentSector
|
||||||
|
{
|
||||||
|
get => _currentSector;
|
||||||
|
set => this.RaiseAndSetIfChanged(ref _currentSector, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int CurrentFrame => (int)(_currentSector / (75 * 60));
|
||||||
|
public int CurrentSecond => (int)(_currentSector / 75 % 60);
|
||||||
|
public int CurrentMinute => (int)(_currentSector % 75);
|
||||||
|
|
||||||
|
private ulong _totalSectors;
|
||||||
|
public ulong TotalSectors
|
||||||
|
{
|
||||||
|
get => _totalSectors;
|
||||||
|
set => this.RaiseAndSetIfChanged(ref _totalSectors, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int TotalFrames => (int)(_totalSectors / (75 * 60));
|
||||||
|
public int TotalSeconds => (int)(_totalSectors / 75 % 60);
|
||||||
|
public int TotalMinutes => (int)(_totalSectors % 75);
|
||||||
|
|
||||||
private int _volume;
|
private int _volume;
|
||||||
public int Volume
|
public int Volume
|
||||||
{
|
{
|
||||||
@@ -11,6 +42,10 @@ namespace RedBookPlayer.GUI
|
|||||||
set => this.RaiseAndSetIfChanged(ref _volume, value);
|
set => this.RaiseAndSetIfChanged(ref _volume, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Disc Flags
|
||||||
|
|
||||||
private bool _applyDeEmphasis;
|
private bool _applyDeEmphasis;
|
||||||
public bool ApplyDeEmphasis
|
public bool ApplyDeEmphasis
|
||||||
{
|
{
|
||||||
@@ -52,5 +87,7 @@ namespace RedBookPlayer.GUI
|
|||||||
get => _hiddenTrack;
|
get => _hiddenTrack;
|
||||||
set => this.RaiseAndSetIfChanged(ref _hiddenTrack, value);
|
set => this.RaiseAndSetIfChanged(ref _hiddenTrack, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -233,11 +233,7 @@ namespace RedBookPlayer.Hardware
|
|||||||
return string.Empty.PadLeft(20, '-');
|
return string.Empty.PadLeft(20, '-');
|
||||||
|
|
||||||
// Otherwise, take the current time into account
|
// Otherwise, take the current time into account
|
||||||
ulong sectorTime = _opticalDisc.CurrentSector;
|
ulong sectorTime = GetCurrentSectorTime();
|
||||||
if(_opticalDisc.SectionStartSector != 0)
|
|
||||||
sectorTime -= _opticalDisc.SectionStartSector;
|
|
||||||
else
|
|
||||||
sectorTime += _opticalDisc.TimeOffset;
|
|
||||||
|
|
||||||
int[] numbers = new int[]
|
int[] numbers = new int[]
|
||||||
{
|
{
|
||||||
@@ -274,7 +270,11 @@ namespace RedBookPlayer.Hardware
|
|||||||
if(!Initialized || dataContext == null)
|
if(!Initialized || dataContext == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
dataContext.Playing = Playing;
|
||||||
|
dataContext.CurrentSector = GetCurrentSectorTime();
|
||||||
|
dataContext.TotalSectors = _opticalDisc.TotalTime;
|
||||||
dataContext.Volume = App.Settings.Volume;
|
dataContext.Volume = App.Settings.Volume;
|
||||||
|
|
||||||
dataContext.ApplyDeEmphasis = _soundOutput.ApplyDeEmphasis;
|
dataContext.ApplyDeEmphasis = _soundOutput.ApplyDeEmphasis;
|
||||||
dataContext.HiddenTrack = _opticalDisc.TimeOffset > 150;
|
dataContext.HiddenTrack = _opticalDisc.TimeOffset > 150;
|
||||||
|
|
||||||
@@ -294,6 +294,21 @@ namespace RedBookPlayer.Hardware
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Get current sector time, accounting for offsets
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>ulong representing the current sector time</returns>
|
||||||
|
private ulong GetCurrentSectorTime()
|
||||||
|
{
|
||||||
|
ulong sectorTime = _opticalDisc.CurrentSector;
|
||||||
|
if(_opticalDisc.SectionStartSector != 0)
|
||||||
|
sectorTime -= _opticalDisc.SectionStartSector;
|
||||||
|
else
|
||||||
|
sectorTime += _opticalDisc.TimeOffset;
|
||||||
|
|
||||||
|
return sectorTime;
|
||||||
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user