Skip to content

Commit

Permalink
fix #211 and fix #205 (same issue)
Browse files Browse the repository at this point in the history
  • Loading branch information
theweavr committed Nov 15, 2017
1 parent c6f2dff commit afab809
Showing 1 changed file with 18 additions and 11 deletions.
29 changes: 18 additions & 11 deletions BreadPlayer.Views.UWP/CoreWindowLogic.cs
Original file line number Diff line number Diff line change
Expand Up @@ -181,9 +181,12 @@ public async static void UpdateSmtc()

private static async void _smtc_ButtonPressed(SystemMediaTransportControls sender, SystemMediaTransportControlsButtonPressedEventArgs args)
{
//we do not want to pause the background player.
//pausing may cause stutter, that's why.
_player?.Play();
if (ApiInformation.IsApiContractPresent("Windows.Phone.PhoneContract", 1))
{
//we do not want to pause the background player.
//pausing may cause stutter, that's why.
_player?.Play();
}
await BreadDispatcher.InvokeAsync(() =>
{
switch (args.Button)
Expand Down Expand Up @@ -223,13 +226,15 @@ private void Player_MediaStateChanged(object sender, MediaStateChangedEventArgs
switch (e.NewState)
{
case PlayerState.Playing:
//@TODO Potential issue here. Github issue: #211. Related to Github issue: #205
_player?.Play();
//check if the player was paused by another app
if (externalPaused)
if (ApiInformation.IsApiContractPresent("Windows.Phone.PhoneContract", 1))
{
UpdateSmtc();
externalPaused = false;
_player?.Play();
//check if the player was paused by another app
if (externalPaused)
{
UpdateSmtc();
externalPaused = false;
}
}
_smtc.PlaybackStatus = MediaPlaybackStatus.Playing;
break;
Expand Down Expand Up @@ -259,9 +264,11 @@ private void Player_MediaStateChanged(object sender, MediaStateChangedEventArgs
public static void DisposeObjects()
{
BLogger.I("Background Player ran for: " + _player?.PlaybackSession.Position.TotalSeconds);
//@TODO Possible issue here #205
if (ApiInformation.IsApiContractPresent("Windows.Phone.PhoneContract", 1))
{
_player?.Dispose();
}
_smtc.DisplayUpdater.ClearAll();
_player?.Dispose();
}

#endregion CoreWindow Dispose Methods
Expand Down

0 comments on commit afab809

Please sign in to comment.