mirror of
https://github.com/aaru-dps/RedBookPlayer.git
synced 2025-12-16 19:24:41 +00:00
Fix stopping playback
This commit is contained in:
@@ -1,6 +1,5 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.ComponentModel;
|
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
@@ -112,7 +111,6 @@ namespace RedBookPlayer.GUI
|
|||||||
private void InitializeComponent(string xaml)
|
private void InitializeComponent(string xaml)
|
||||||
{
|
{
|
||||||
DataContext = new PlayerViewModel();
|
DataContext = new PlayerViewModel();
|
||||||
PlayerViewModel.PropertyChanged += UpdateModel;
|
|
||||||
|
|
||||||
// Load the theme
|
// Load the theme
|
||||||
try
|
try
|
||||||
@@ -182,17 +180,6 @@ namespace RedBookPlayer.GUI
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Update the Player with the most recent information from the UI
|
|
||||||
/// </summary>
|
|
||||||
private void UpdateModel(object sender, PropertyChangedEventArgs e)
|
|
||||||
{
|
|
||||||
Dispatcher.UIThread.InvokeAsync(() =>
|
|
||||||
{
|
|
||||||
PlayerViewModel.UpdateModel();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Update the UI with the most recent information from the Player
|
/// Update the UI with the most recent information from the Player
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -20,27 +20,48 @@ namespace RedBookPlayer.GUI
|
|||||||
|
|
||||||
#region Player Status
|
#region Player Status
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Indicate if the model is ready to be used
|
||||||
|
/// </summary>
|
||||||
public bool Initialized => _player?.Initialized ?? false;
|
public bool Initialized => _player?.Initialized ?? false;
|
||||||
|
|
||||||
private bool? _playing;
|
/// <summary>
|
||||||
|
/// Indicate the player state
|
||||||
|
/// </summary>
|
||||||
public bool? Playing
|
public bool? Playing
|
||||||
{
|
{
|
||||||
get => _playing;
|
get => _player?.Playing ?? false;
|
||||||
set => this.RaiseAndSetIfChanged(ref _playing, value);
|
set
|
||||||
|
{
|
||||||
|
if(_player != null)
|
||||||
|
_player.Playing = value;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private int _volume;
|
/// <summary>
|
||||||
|
/// Indicate the current playback volume
|
||||||
|
/// </summary>
|
||||||
public int Volume
|
public int Volume
|
||||||
{
|
{
|
||||||
get => _volume;
|
get => _player?.Volume ?? 100;
|
||||||
set => this.RaiseAndSetIfChanged(ref _volume, value);
|
set
|
||||||
|
{
|
||||||
|
if(_player != null)
|
||||||
|
_player.Volume = value;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool _applyDeEmphasis;
|
/// <summary>
|
||||||
|
/// Indicates if de-emphasis should be applied
|
||||||
|
/// </summary>
|
||||||
public bool ApplyDeEmphasis
|
public bool ApplyDeEmphasis
|
||||||
{
|
{
|
||||||
get => _applyDeEmphasis;
|
get => _player?.ApplyDeEmphasis ?? false;
|
||||||
set => this.RaiseAndSetIfChanged(ref _applyDeEmphasis, value);
|
set
|
||||||
|
{
|
||||||
|
if(_player != null)
|
||||||
|
_player.ApplyDeEmphasis = value;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
@@ -223,12 +244,9 @@ namespace RedBookPlayer.GUI
|
|||||||
if(_player?.Initialized != true)
|
if(_player?.Initialized != true)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Playing = _player.Playing;
|
|
||||||
CurrentSector = _player.GetCurrentSectorTime();
|
CurrentSector = _player.GetCurrentSectorTime();
|
||||||
TotalSectors = _player.OpticalDisc.TotalTime;
|
TotalSectors = _player.OpticalDisc.TotalTime;
|
||||||
Volume = _player.Volume;
|
|
||||||
|
|
||||||
ApplyDeEmphasis = _player.ApplyDeEmphasis;
|
|
||||||
HiddenTrack = _player.OpticalDisc.TimeOffset > 150;
|
HiddenTrack = _player.OpticalDisc.TimeOffset > 150;
|
||||||
|
|
||||||
if(_player.OpticalDisc is CompactDisc compactDisc)
|
if(_player.OpticalDisc is CompactDisc compactDisc)
|
||||||
@@ -247,19 +265,6 @@ namespace RedBookPlayer.GUI
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Update the internal player from the UI
|
|
||||||
/// </summary>
|
|
||||||
public void UpdateModel()
|
|
||||||
{
|
|
||||||
if(_player?.Initialized != true)
|
|
||||||
return;
|
|
||||||
|
|
||||||
_player.Playing = Playing;
|
|
||||||
_player.Volume = Volume;
|
|
||||||
_player.ApplyDeEmphasis = ApplyDeEmphasis;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user