2021-03-19 17:07:27 -03:00
|
|
|
using System;
|
2021-07-04 23:17:30 -07:00
|
|
|
using System.ComponentModel;
|
|
|
|
|
using Aaru.CommonTypes.Enums;
|
|
|
|
|
using ReactiveUI;
|
2021-07-12 15:40:56 -07:00
|
|
|
using RedBookPlayer.Models.Discs;
|
|
|
|
|
using RedBookPlayer.Models.Factories;
|
2021-03-19 17:07:27 -03:00
|
|
|
|
2021-07-12 15:40:56 -07:00
|
|
|
namespace RedBookPlayer.Models.Hardware
|
2021-03-19 17:07:27 -03:00
|
|
|
{
|
2021-07-04 23:17:30 -07:00
|
|
|
public class Player : ReactiveObject
|
2021-03-19 17:07:27 -03:00
|
|
|
{
|
2021-06-06 21:43:47 -07:00
|
|
|
/// <summary>
|
|
|
|
|
/// Indicate if the player is ready to be used
|
|
|
|
|
/// </summary>
|
|
|
|
|
public bool Initialized { get; private set; } = false;
|
2021-06-06 20:28:36 +01:00
|
|
|
|
2021-07-04 23:17:30 -07:00
|
|
|
#region OpticalDisc Passthrough
|
|
|
|
|
|
2021-07-03 15:37:56 -07:00
|
|
|
/// <summary>
|
2021-07-04 23:17:30 -07:00
|
|
|
/// Current track number
|
2021-07-03 15:37:56 -07:00
|
|
|
/// </summary>
|
2021-07-04 23:17:30 -07:00
|
|
|
public int CurrentTrackNumber
|
|
|
|
|
{
|
|
|
|
|
get => _currentTrackNumber;
|
|
|
|
|
private set => this.RaiseAndSetIfChanged(ref _currentTrackNumber, value);
|
|
|
|
|
}
|
2021-07-03 15:37:56 -07:00
|
|
|
|
2021-06-28 23:11:16 -07:00
|
|
|
/// <summary>
|
2021-07-04 23:17:30 -07:00
|
|
|
/// Current track index
|
2021-06-28 23:11:16 -07:00
|
|
|
/// </summary>
|
2021-07-04 23:17:30 -07:00
|
|
|
public ushort CurrentTrackIndex
|
2021-07-03 16:04:18 -07:00
|
|
|
{
|
2021-07-04 23:17:30 -07:00
|
|
|
get => _currentTrackIndex;
|
|
|
|
|
private set => this.RaiseAndSetIfChanged(ref _currentTrackIndex, value);
|
|
|
|
|
}
|
2021-07-03 16:04:18 -07:00
|
|
|
|
2021-07-04 23:17:30 -07:00
|
|
|
/// <summary>
|
|
|
|
|
/// Current sector number
|
|
|
|
|
/// </summary>
|
|
|
|
|
public ulong CurrentSector
|
|
|
|
|
{
|
|
|
|
|
get => _currentSector;
|
|
|
|
|
private set => this.RaiseAndSetIfChanged(ref _currentSector, value);
|
|
|
|
|
}
|
2021-07-03 16:04:18 -07:00
|
|
|
|
2021-07-05 00:48:14 -07:00
|
|
|
/// <summary>
|
|
|
|
|
/// Represents the sector starting the section
|
|
|
|
|
/// </summary>
|
|
|
|
|
public ulong SectionStartSector
|
|
|
|
|
{
|
|
|
|
|
get => _sectionStartSector;
|
|
|
|
|
protected set => this.RaiseAndSetIfChanged(ref _sectionStartSector, value);
|
|
|
|
|
}
|
|
|
|
|
|
2021-07-04 23:17:30 -07:00
|
|
|
/// <summary>
|
|
|
|
|
/// Represents if the disc has a hidden track
|
|
|
|
|
/// </summary>
|
|
|
|
|
public bool HiddenTrack
|
|
|
|
|
{
|
|
|
|
|
get => _hasHiddenTrack;
|
|
|
|
|
private set => this.RaiseAndSetIfChanged(ref _hasHiddenTrack, value);
|
2021-07-03 16:04:18 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2021-07-04 23:17:30 -07:00
|
|
|
/// Represents the 4CH flag [CompactDisc only]
|
2021-07-03 16:04:18 -07:00
|
|
|
/// </summary>
|
2021-07-04 23:17:30 -07:00
|
|
|
public bool QuadChannel
|
2021-07-03 16:04:18 -07:00
|
|
|
{
|
2021-07-04 23:17:30 -07:00
|
|
|
get => _quadChannel;
|
|
|
|
|
private set => this.RaiseAndSetIfChanged(ref _quadChannel, value);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Represents the DATA flag [CompactDisc only]
|
|
|
|
|
/// </summary>
|
|
|
|
|
public bool IsDataTrack
|
|
|
|
|
{
|
|
|
|
|
get => _isDataTrack;
|
|
|
|
|
private set => this.RaiseAndSetIfChanged(ref _isDataTrack, value);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Represents the DCP flag [CompactDisc only]
|
|
|
|
|
/// </summary>
|
|
|
|
|
public bool CopyAllowed
|
|
|
|
|
{
|
|
|
|
|
get => _copyAllowed;
|
|
|
|
|
private set => this.RaiseAndSetIfChanged(ref _copyAllowed, value);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Represents the PRE flag [CompactDisc only]
|
|
|
|
|
/// </summary>
|
|
|
|
|
public bool TrackHasEmphasis
|
|
|
|
|
{
|
|
|
|
|
get => _trackHasEmphasis;
|
|
|
|
|
private set => this.RaiseAndSetIfChanged(ref _trackHasEmphasis, value);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Represents the total tracks on the disc
|
|
|
|
|
/// </summary>
|
|
|
|
|
public int TotalTracks => _opticalDisc.TotalTracks;
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Represents the total indices on the disc
|
|
|
|
|
/// </summary>
|
|
|
|
|
public int TotalIndexes => _opticalDisc.TotalIndexes;
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Total sectors in the image
|
|
|
|
|
/// </summary>
|
|
|
|
|
public ulong TotalSectors => _opticalDisc.TotalSectors;
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Represents the time adjustment offset for the disc
|
|
|
|
|
/// </summary>
|
|
|
|
|
public ulong TimeOffset => _opticalDisc.TimeOffset;
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Represents the total playing time for the disc
|
|
|
|
|
/// </summary>
|
|
|
|
|
public ulong TotalTime => _opticalDisc.TotalTime;
|
|
|
|
|
|
|
|
|
|
private int _currentTrackNumber;
|
|
|
|
|
private ushort _currentTrackIndex;
|
|
|
|
|
private ulong _currentSector;
|
2021-07-05 00:48:14 -07:00
|
|
|
private ulong _sectionStartSector;
|
2021-07-04 23:17:30 -07:00
|
|
|
|
|
|
|
|
private bool _hasHiddenTrack;
|
|
|
|
|
private bool _quadChannel;
|
|
|
|
|
private bool _isDataTrack;
|
|
|
|
|
private bool _copyAllowed;
|
|
|
|
|
private bool _trackHasEmphasis;
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region SoundOutput Passthrough
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Indicate if the output is playing
|
|
|
|
|
/// </summary>
|
|
|
|
|
public bool? Playing
|
|
|
|
|
{
|
|
|
|
|
get => _playing;
|
|
|
|
|
private set => this.RaiseAndSetIfChanged(ref _playing, value);
|
2021-07-03 16:04:18 -07:00
|
|
|
}
|
2021-06-28 23:11:16 -07:00
|
|
|
|
2021-06-30 13:56:42 -07:00
|
|
|
/// <summary>
|
|
|
|
|
/// Indicates if de-emphasis should be applied
|
|
|
|
|
/// </summary>
|
2021-07-03 16:04:18 -07:00
|
|
|
public bool ApplyDeEmphasis
|
|
|
|
|
{
|
2021-07-04 23:17:30 -07:00
|
|
|
get => _applyDeEmphasis;
|
|
|
|
|
private set => this.RaiseAndSetIfChanged(ref _applyDeEmphasis, value);
|
2021-07-03 16:04:18 -07:00
|
|
|
}
|
2021-06-30 13:56:42 -07:00
|
|
|
|
2021-07-04 23:17:30 -07:00
|
|
|
/// <summary>
|
|
|
|
|
/// Current playback volume
|
|
|
|
|
/// </summary>
|
|
|
|
|
public int Volume
|
|
|
|
|
{
|
|
|
|
|
get => _volume;
|
2021-07-05 16:23:50 -07:00
|
|
|
private set => this.RaiseAndSetIfChanged(ref _volume, value);
|
2021-07-04 23:17:30 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private bool? _playing;
|
|
|
|
|
private bool _applyDeEmphasis;
|
|
|
|
|
private int _volume;
|
|
|
|
|
|
2021-06-06 21:43:47 -07:00
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region Private State Variables
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2021-06-29 15:45:13 -07:00
|
|
|
/// Sound output handling class
|
2021-06-06 21:43:47 -07:00
|
|
|
/// </summary>
|
2021-07-04 23:17:30 -07:00
|
|
|
private readonly SoundOutput _soundOutput;
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// OpticalDisc object
|
|
|
|
|
/// </summary>
|
2021-07-12 10:52:50 -07:00
|
|
|
private readonly OpticalDiscBase _opticalDisc;
|
2021-06-06 21:43:47 -07:00
|
|
|
|
2021-07-12 10:41:11 -07:00
|
|
|
/// <summary>
|
|
|
|
|
/// Last volume for mute toggling
|
|
|
|
|
/// </summary>
|
|
|
|
|
private int? _lastVolume = null;
|
|
|
|
|
|
2021-06-06 21:43:47 -07:00
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2021-07-03 16:04:18 -07:00
|
|
|
/// Create a new Player from a given image path
|
2021-06-06 21:43:47 -07:00
|
|
|
/// </summary>
|
2021-06-29 12:08:08 -07:00
|
|
|
/// <param name="path">Path to the disc image</param>
|
2021-07-05 11:55:36 -07:00
|
|
|
/// <param name="generateMissingToc">Generate a TOC if the disc is missing one [CompactDisc only]</param>
|
2021-07-05 22:13:00 -07:00
|
|
|
/// <param name="loadHiddenTracks">Load hidden tracks for playback [CompactDisc only]</param>
|
2021-07-05 11:55:36 -07:00
|
|
|
/// <param name="loadDataTracks">Load data tracks for playback [CompactDisc only]</param>
|
2021-06-06 21:43:47 -07:00
|
|
|
/// <param name="autoPlay">True if playback should begin immediately, false otherwise</param>
|
2021-07-03 16:04:18 -07:00
|
|
|
/// <param name="defaultVolume">Default volume between 0 and 100 to use when starting playback</param>
|
2021-07-05 22:13:00 -07:00
|
|
|
public Player(string path, bool generateMissingToc, bool loadHiddenTracks, bool loadDataTracks, bool autoPlay, int defaultVolume)
|
2021-03-19 17:07:27 -03:00
|
|
|
{
|
2021-07-03 16:04:18 -07:00
|
|
|
// Set the internal state for initialization
|
2021-06-29 12:08:08 -07:00
|
|
|
Initialized = false;
|
2021-06-29 15:45:13 -07:00
|
|
|
_soundOutput = new SoundOutput();
|
2021-07-04 23:17:30 -07:00
|
|
|
_soundOutput.SetDeEmphasis(false);
|
2021-07-05 00:31:19 -07:00
|
|
|
|
|
|
|
|
// Initalize the disc
|
2021-07-05 22:13:00 -07:00
|
|
|
_opticalDisc = OpticalDiscFactory.GenerateFromPath(path, generateMissingToc, loadHiddenTracks, loadDataTracks, autoPlay);
|
2021-07-05 00:31:19 -07:00
|
|
|
if(_opticalDisc == null || !_opticalDisc.Initialized)
|
2021-03-19 17:07:27 -03:00
|
|
|
return;
|
|
|
|
|
|
2021-07-04 23:43:55 -07:00
|
|
|
// Add event handling for the optical disc
|
2021-07-05 00:31:19 -07:00
|
|
|
_opticalDisc.PropertyChanged += OpticalDiscStateChanged;
|
2021-07-04 23:43:55 -07:00
|
|
|
|
2021-06-29 15:45:13 -07:00
|
|
|
// Initialize the sound output
|
2021-07-04 23:17:30 -07:00
|
|
|
_soundOutput.Init(_opticalDisc, autoPlay, defaultVolume);
|
2021-06-29 15:45:13 -07:00
|
|
|
if(_soundOutput == null || !_soundOutput.Initialized)
|
2021-06-29 12:08:08 -07:00
|
|
|
return;
|
2021-04-08 21:41:31 -03:00
|
|
|
|
2021-07-04 23:17:30 -07:00
|
|
|
// Add event handling for the sound output
|
|
|
|
|
_soundOutput.PropertyChanged += SoundOutputStateChanged;
|
|
|
|
|
|
2021-06-06 21:43:47 -07:00
|
|
|
// Mark the player as ready
|
2021-03-19 17:07:27 -03:00
|
|
|
Initialized = true;
|
2021-07-05 13:00:20 -07:00
|
|
|
|
2021-07-05 13:04:48 -07:00
|
|
|
// Force a refresh of the state information
|
2021-07-05 13:00:20 -07:00
|
|
|
OpticalDiscStateChanged(this, null);
|
2021-07-05 13:04:48 -07:00
|
|
|
SoundOutputStateChanged(this, null);
|
2021-03-19 17:07:27 -03:00
|
|
|
}
|
|
|
|
|
|
2021-06-21 21:35:09 -07:00
|
|
|
#region Playback
|
2021-03-19 17:07:27 -03:00
|
|
|
|
2021-07-04 23:17:30 -07:00
|
|
|
/// <summary>
|
|
|
|
|
/// Begin playback
|
|
|
|
|
/// </summary>
|
|
|
|
|
public void Play()
|
|
|
|
|
{
|
|
|
|
|
if(_opticalDisc == null || !_opticalDisc.Initialized)
|
|
|
|
|
return;
|
|
|
|
|
else if(_soundOutput == null)
|
|
|
|
|
return;
|
|
|
|
|
else if(_soundOutput.Playing)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
_soundOutput.Play();
|
|
|
|
|
_opticalDisc.SetTotalIndexes();
|
|
|
|
|
Playing = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Pause current playback
|
|
|
|
|
/// </summary>
|
|
|
|
|
public void Pause()
|
|
|
|
|
{
|
|
|
|
|
if(_opticalDisc == null || !_opticalDisc.Initialized)
|
|
|
|
|
return;
|
|
|
|
|
else if(_soundOutput == null)
|
|
|
|
|
return;
|
|
|
|
|
else if(!_soundOutput.Playing)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
_soundOutput?.Stop();
|
|
|
|
|
Playing = false;
|
|
|
|
|
}
|
|
|
|
|
|
2021-07-12 10:41:11 -07:00
|
|
|
/// <summary>
|
|
|
|
|
/// Toggle current playback
|
|
|
|
|
/// </summary>
|
|
|
|
|
public void TogglePlayback()
|
|
|
|
|
{
|
|
|
|
|
if(Playing == true)
|
|
|
|
|
Pause();
|
|
|
|
|
else
|
|
|
|
|
Play();
|
|
|
|
|
}
|
|
|
|
|
|
2021-07-04 23:17:30 -07:00
|
|
|
/// <summary>
|
|
|
|
|
/// Stop current playback
|
|
|
|
|
/// </summary>
|
|
|
|
|
public void Stop()
|
|
|
|
|
{
|
|
|
|
|
if(_opticalDisc == null || !_opticalDisc.Initialized)
|
|
|
|
|
return;
|
|
|
|
|
else if(_soundOutput == null)
|
|
|
|
|
return;
|
|
|
|
|
else if(!_soundOutput.Playing)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
_soundOutput?.Stop();
|
|
|
|
|
_opticalDisc.LoadFirstTrack();
|
|
|
|
|
Playing = null;
|
|
|
|
|
}
|
|
|
|
|
|
2021-06-06 21:43:47 -07:00
|
|
|
/// <summary>
|
2021-06-29 12:08:08 -07:00
|
|
|
/// Move to the next playable track
|
2021-06-06 21:43:47 -07:00
|
|
|
/// </summary>
|
2021-06-29 12:08:08 -07:00
|
|
|
public void NextTrack()
|
2021-03-19 17:07:27 -03:00
|
|
|
{
|
2021-07-04 23:17:30 -07:00
|
|
|
if(_opticalDisc == null || !_opticalDisc.Initialized)
|
2021-03-19 17:07:27 -03:00
|
|
|
return;
|
|
|
|
|
|
2021-07-03 15:37:56 -07:00
|
|
|
bool? wasPlaying = Playing;
|
2021-07-04 23:17:30 -07:00
|
|
|
if(wasPlaying == true) Pause();
|
2021-06-29 12:08:08 -07:00
|
|
|
|
2021-07-04 23:17:30 -07:00
|
|
|
_opticalDisc.NextTrack();
|
|
|
|
|
if(_opticalDisc is CompactDisc compactDisc)
|
|
|
|
|
_soundOutput.SetDeEmphasis(compactDisc.TrackHasEmphasis);
|
2021-06-29 12:08:08 -07:00
|
|
|
|
2021-07-04 23:17:30 -07:00
|
|
|
if(wasPlaying == true) Play();
|
2021-06-29 12:08:08 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Move to the previous playable track
|
|
|
|
|
/// </summary>
|
2021-07-05 22:13:00 -07:00
|
|
|
public void PreviousTrack()
|
2021-06-29 12:08:08 -07:00
|
|
|
{
|
2021-07-04 23:17:30 -07:00
|
|
|
if(_opticalDisc == null || !_opticalDisc.Initialized)
|
2021-06-29 12:08:08 -07:00
|
|
|
return;
|
|
|
|
|
|
2021-07-03 15:37:56 -07:00
|
|
|
bool? wasPlaying = Playing;
|
2021-07-04 23:17:30 -07:00
|
|
|
if(wasPlaying == true) Pause();
|
|
|
|
|
|
2021-07-05 22:13:00 -07:00
|
|
|
_opticalDisc.PreviousTrack();
|
2021-07-04 23:17:30 -07:00
|
|
|
if(_opticalDisc is CompactDisc compactDisc)
|
|
|
|
|
_soundOutput.SetDeEmphasis(compactDisc.TrackHasEmphasis);
|
2021-06-29 12:08:08 -07:00
|
|
|
|
2021-07-04 23:17:30 -07:00
|
|
|
if(wasPlaying == true) Play();
|
2021-06-29 12:08:08 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Move to the next index
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="changeTrack">True if index changes can trigger a track change, false otherwise</param>
|
|
|
|
|
public void NextIndex(bool changeTrack)
|
|
|
|
|
{
|
2021-07-04 23:17:30 -07:00
|
|
|
if(_opticalDisc == null || !_opticalDisc.Initialized)
|
2021-06-29 12:08:08 -07:00
|
|
|
return;
|
|
|
|
|
|
2021-07-03 15:37:56 -07:00
|
|
|
bool? wasPlaying = Playing;
|
2021-07-04 23:17:30 -07:00
|
|
|
if(wasPlaying == true) Pause();
|
2021-06-29 12:08:08 -07:00
|
|
|
|
2021-07-04 23:17:30 -07:00
|
|
|
_opticalDisc.NextIndex(changeTrack);
|
|
|
|
|
if(_opticalDisc is CompactDisc compactDisc)
|
|
|
|
|
_soundOutput.SetDeEmphasis(compactDisc.TrackHasEmphasis);
|
2021-06-29 12:08:08 -07:00
|
|
|
|
2021-07-04 23:17:30 -07:00
|
|
|
if(wasPlaying == true) Play();
|
2021-06-29 12:08:08 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Move to the previous index
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="changeTrack">True if index changes can trigger a track change, false otherwise</param>
|
2021-07-05 22:13:00 -07:00
|
|
|
public void PreviousIndex(bool changeTrack)
|
2021-06-29 12:08:08 -07:00
|
|
|
{
|
2021-07-04 23:17:30 -07:00
|
|
|
if(_opticalDisc == null || !_opticalDisc.Initialized)
|
2021-06-29 12:08:08 -07:00
|
|
|
return;
|
|
|
|
|
|
2021-07-03 15:37:56 -07:00
|
|
|
bool? wasPlaying = Playing;
|
2021-07-04 23:17:30 -07:00
|
|
|
if(wasPlaying == true) Pause();
|
|
|
|
|
|
2021-07-05 22:13:00 -07:00
|
|
|
_opticalDisc.PreviousIndex(changeTrack);
|
2021-07-04 23:17:30 -07:00
|
|
|
if(_opticalDisc is CompactDisc compactDisc)
|
|
|
|
|
_soundOutput.SetDeEmphasis(compactDisc.TrackHasEmphasis);
|
2021-06-29 12:08:08 -07:00
|
|
|
|
2021-07-04 23:17:30 -07:00
|
|
|
if(wasPlaying == true) Play();
|
2021-06-29 12:08:08 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Fast-forward playback by 75 sectors, if possible
|
|
|
|
|
/// </summary>
|
|
|
|
|
public void FastForward()
|
|
|
|
|
{
|
2021-07-04 23:17:30 -07:00
|
|
|
if(_opticalDisc == null || !_opticalDisc.Initialized)
|
2021-06-29 12:08:08 -07:00
|
|
|
return;
|
|
|
|
|
|
2021-07-05 16:30:38 -07:00
|
|
|
_opticalDisc.SetCurrentSector(Math.Min(_opticalDisc.TotalSectors, _opticalDisc.CurrentSector + 75));
|
2021-06-29 12:08:08 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Rewind playback by 75 sectors, if possible
|
|
|
|
|
/// </summary>
|
|
|
|
|
public void Rewind()
|
|
|
|
|
{
|
2021-07-04 23:17:30 -07:00
|
|
|
if(_opticalDisc == null || !_opticalDisc.Initialized)
|
2021-06-29 12:08:08 -07:00
|
|
|
return;
|
|
|
|
|
|
2021-07-04 23:17:30 -07:00
|
|
|
if(_opticalDisc.CurrentSector >= 75)
|
2021-07-05 16:30:38 -07:00
|
|
|
_opticalDisc.SetCurrentSector(_opticalDisc.CurrentSector - 75);
|
2021-03-19 17:07:27 -03:00
|
|
|
}
|
|
|
|
|
|
2021-06-06 21:43:47 -07:00
|
|
|
#endregion
|
2021-03-19 17:07:27 -03:00
|
|
|
|
2021-07-12 10:41:11 -07:00
|
|
|
#region Volume
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Increment the volume value
|
|
|
|
|
/// </summary>
|
|
|
|
|
public void VolumeUp() => SetVolume(Volume + 1);
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Decrement the volume value
|
|
|
|
|
/// </summary>
|
|
|
|
|
public void VolumeDown() => SetVolume(Volume + 1);
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Set the value for the volume
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="volume">New volume value</param>
|
|
|
|
|
public void SetVolume(int volume) => _soundOutput?.SetVolume(volume);
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Temporarily mute playback
|
|
|
|
|
/// </summary>
|
|
|
|
|
public void ToggleMute()
|
|
|
|
|
{
|
|
|
|
|
if(_lastVolume == null)
|
|
|
|
|
{
|
|
|
|
|
_lastVolume = Volume;
|
|
|
|
|
SetVolume(0);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
SetVolume(_lastVolume.Value);
|
|
|
|
|
_lastVolume = null;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region Emphasis
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Enable de-emphasis
|
|
|
|
|
/// </summary>
|
|
|
|
|
public void EnableDeEmphasis() => SetDeEmphasis(true);
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Disable de-emphasis
|
|
|
|
|
/// </summary>
|
|
|
|
|
public void DisableDeEmphasis() => SetDeEmphasis(false);
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Toggle de-emphasis
|
|
|
|
|
/// </summary>
|
|
|
|
|
public void ToggleDeEmphasis() => SetDeEmphasis(!ApplyDeEmphasis);
|
2021-06-06 21:43:47 -07:00
|
|
|
|
2021-07-03 15:37:56 -07:00
|
|
|
/// <summary>
|
2021-07-04 23:17:30 -07:00
|
|
|
/// Set de-emphasis status
|
2021-07-03 15:37:56 -07:00
|
|
|
/// </summary>
|
2021-07-04 23:17:30 -07:00
|
|
|
/// <param name="apply"></param>
|
2021-07-12 10:41:11 -07:00
|
|
|
private void SetDeEmphasis(bool apply) => _soundOutput?.SetDeEmphasis(apply);
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region Helpers
|
2021-07-03 15:37:56 -07:00
|
|
|
|
2021-07-05 11:55:36 -07:00
|
|
|
/// <summary>
|
|
|
|
|
/// Set the value for loading data tracks [CompactDisc only]
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="load">True to enable loading data tracks, false otherwise</param>
|
2021-07-12 10:57:52 -07:00
|
|
|
public void SetLoadDataTracks(bool load)
|
|
|
|
|
{
|
|
|
|
|
if(_opticalDisc is CompactDisc compactDisc)
|
|
|
|
|
compactDisc.LoadDataTracks = load;
|
|
|
|
|
}
|
2021-07-05 11:55:36 -07:00
|
|
|
|
2021-07-05 22:13:00 -07:00
|
|
|
/// <summary>
|
|
|
|
|
/// Set the value for loading hidden tracks [CompactDisc only]
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="load">True to enable loading hidden tracks, false otherwise</param>
|
2021-07-12 10:57:52 -07:00
|
|
|
public void SetLoadHiddenTracks(bool load)
|
|
|
|
|
{
|
|
|
|
|
if(_opticalDisc is CompactDisc compactDisc)
|
|
|
|
|
compactDisc.LoadHiddenTracks = load;
|
|
|
|
|
}
|
2021-07-05 22:13:00 -07:00
|
|
|
|
2021-07-04 23:43:55 -07:00
|
|
|
/// <summary>
|
|
|
|
|
/// Update the player from the current OpticalDisc
|
|
|
|
|
/// </summary>
|
2021-07-05 13:00:20 -07:00
|
|
|
private void OpticalDiscStateChanged(object sender, PropertyChangedEventArgs e)
|
2021-07-04 23:17:30 -07:00
|
|
|
{
|
|
|
|
|
CurrentTrackNumber = _opticalDisc.CurrentTrackNumber;
|
|
|
|
|
CurrentTrackIndex = _opticalDisc.CurrentTrackIndex;
|
|
|
|
|
CurrentSector = _opticalDisc.CurrentSector;
|
2021-07-05 00:48:14 -07:00
|
|
|
SectionStartSector = _opticalDisc.SectionStartSector;
|
2021-07-04 23:17:30 -07:00
|
|
|
|
|
|
|
|
HiddenTrack = TimeOffset > 150;
|
|
|
|
|
|
|
|
|
|
if(_opticalDisc is CompactDisc compactDisc)
|
|
|
|
|
{
|
|
|
|
|
QuadChannel = compactDisc.QuadChannel;
|
|
|
|
|
IsDataTrack = compactDisc.IsDataTrack;
|
|
|
|
|
CopyAllowed = compactDisc.CopyAllowed;
|
|
|
|
|
TrackHasEmphasis = compactDisc.TrackHasEmphasis;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
QuadChannel = false;
|
|
|
|
|
IsDataTrack = _opticalDisc.TrackType != TrackType.Audio;
|
|
|
|
|
CopyAllowed = false;
|
|
|
|
|
TrackHasEmphasis = false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2021-07-05 13:00:20 -07:00
|
|
|
/// <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;
|
|
|
|
|
}
|
|
|
|
|
|
2021-06-06 21:43:47 -07:00
|
|
|
#endregion
|
2021-03-19 17:07:27 -03:00
|
|
|
}
|
2021-06-06 20:28:36 +01:00
|
|
|
}
|