Make view-model stop playback

This commit is contained in:
Matt Nadareski
2021-07-03 16:25:56 -07:00
parent 4b5d0af58d
commit 416772ab35
2 changed files with 4 additions and 3 deletions

View File

@@ -64,9 +64,6 @@ namespace RedBookPlayer.GUI
/// <param name="path">Path to the image to load</param>
public async Task<bool> LoadImage(string path)
{
// If the player is currently running, stop it
if(PlayerViewModel.Playing != true) PlayerViewModel.Playing = null;
bool result = await Dispatcher.UIThread.InvokeAsync(() =>
{
PlayerViewModel.Init(path, App.Settings.AutoPlay, App.Settings.Volume);

View File

@@ -118,6 +118,10 @@ namespace RedBookPlayer.GUI
/// <param name="defaultVolume">Default volume between 0 and 100 to use when starting playback</param>
public void Init(string path, bool autoPlay, int defaultVolume)
{
// Stop current playback, if necessary
if(Playing != null) Playing = null;
// Create and attempt to initialize new Player
_player = new Player(path, autoPlay, defaultVolume);
if(Initialized)
UpdateModel();