diff --git a/BassBoom.Basolia/Playback/PlaybackState.cs b/BassBoom.Basolia/Playback/PlaybackState.cs index 6424afc..9a84468 100644 --- a/BassBoom.Basolia/Playback/PlaybackState.cs +++ b/BassBoom.Basolia/Playback/PlaybackState.cs @@ -35,6 +35,10 @@ public enum PlaybackState /// /// Music has been paused by the user or by the call to the function /// - Paused + Paused, + /// + /// Music is stopping + /// + Stopping, } } diff --git a/BassBoom.Basolia/Playback/PlaybackTools.cs b/BassBoom.Basolia/Playback/PlaybackTools.cs index e132a87..6e56952 100644 --- a/BassBoom.Basolia/Playback/PlaybackTools.cs +++ b/BassBoom.Basolia/Playback/PlaybackTools.cs @@ -149,7 +149,7 @@ public static void Play() FeedRadio(); } } while (err == (int)mpg123_errors.MPG123_OK && Playing); - if (Playing) + if (Playing || state == PlaybackState.Stopping) state = PlaybackState.Stopped; } } @@ -187,7 +187,8 @@ public static void Stop() throw new BasoliaException("Can't stop a file that's not open", mpg123_errors.MPG123_BAD_FILE); // Stop the music and seek to the beginning - state = PlaybackState.Stopped; + state = state == PlaybackState.Playing ? PlaybackState.Stopping : PlaybackState.Stopped; + SpinWait.SpinUntil(() => state == PlaybackState.Stopped); if (!FileTools.IsRadioStation) PlaybackPositioningTools.SeekToTheBeginning(); }