From a99e9978de2fcb93bb82e77fc0a60cdbf5c4f871 Mon Sep 17 00:00:00 2001 From: dhk2 Date: Fri, 3 Jul 2020 20:33:14 -0700 Subject: [PATCH] Fixing unregister error for noisy audio --- .../schueller/peertube/fragment/VideoPlayerFragment.java | 7 +++++-- .../schueller/peertube/service/VideoPlayerService.java | 8 +++++--- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/net/schueller/peertube/fragment/VideoPlayerFragment.java b/app/src/main/java/net/schueller/peertube/fragment/VideoPlayerFragment.java index 2c4140f..08e4275 100644 --- a/app/src/main/java/net/schueller/peertube/fragment/VideoPlayerFragment.java +++ b/app/src/main/java/net/schueller/peertube/fragment/VideoPlayerFragment.java @@ -259,11 +259,14 @@ public class VideoPlayerFragment extends Fragment implements VideoRendererEventL mService.player.setPlayWhenReady(false); } } - public void pauseToggle() { + public void unPauseVideo() { if (mBound) { - mService.player.setPlayWhenReady(!mService.player.getPlayWhenReady()); + mService.player.setPlayWhenReady(true); } } + public boolean isPaused(){ + return !mService.player.getPlayWhenReady(); + } public void showControls(boolean value){ simpleExoPlayerView.setUseController(value); } diff --git a/app/src/main/java/net/schueller/peertube/service/VideoPlayerService.java b/app/src/main/java/net/schueller/peertube/service/VideoPlayerService.java index a601af4..4b76b0d 100644 --- a/app/src/main/java/net/schueller/peertube/service/VideoPlayerService.java +++ b/app/src/main/java/net/schueller/peertube/service/VideoPlayerService.java @@ -108,6 +108,7 @@ public class VideoPlayerService extends Service { if (playbackState == ACTION_PLAY) { // this means that play is available, hence the audio is paused or stopped Log.v(TAG, "ACTION_PAUSE: " + playbackState); unregisterReceiver(myNoisyAudioStreamReceiver); + myNoisyAudioStreamReceiver=null; } } } ); @@ -131,9 +132,10 @@ public class VideoPlayerService extends Service { playerNotificationManager.setPlayer(null); } //Was seeing an error when exiting the program about about not unregistering the receiver. - if (null!=myNoisyAudioStreamReceiver) { - this.unregisterReceiver(myNoisyAudioStreamReceiver); - } + if (null!=myNoisyAudioStreamReceiver) { + this.unregisterReceiver(myNoisyAudioStreamReceiver); + myNoisyAudioStreamReceiver=null; + } if (player != null) { player.release(); player = null;