Fixing unregister error for noisy audio

This commit is contained in:
dhk2 2020-07-03 20:33:14 -07:00
parent 9d1ffd77c3
commit a99e9978de
2 changed files with 10 additions and 5 deletions

View File

@ -259,11 +259,14 @@ public class VideoPlayerFragment extends Fragment implements VideoRendererEventL
mService.player.setPlayWhenReady(false); mService.player.setPlayWhenReady(false);
} }
} }
public void pauseToggle() { public void unPauseVideo() {
if (mBound) { if (mBound) {
mService.player.setPlayWhenReady(!mService.player.getPlayWhenReady()); mService.player.setPlayWhenReady(true);
} }
} }
public boolean isPaused(){
return !mService.player.getPlayWhenReady();
}
public void showControls(boolean value){ public void showControls(boolean value){
simpleExoPlayerView.setUseController(value); simpleExoPlayerView.setUseController(value);
} }

View File

@ -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 if (playbackState == ACTION_PLAY) { // this means that play is available, hence the audio is paused or stopped
Log.v(TAG, "ACTION_PAUSE: " + playbackState); Log.v(TAG, "ACTION_PAUSE: " + playbackState);
unregisterReceiver(myNoisyAudioStreamReceiver); unregisterReceiver(myNoisyAudioStreamReceiver);
myNoisyAudioStreamReceiver=null;
} }
} }
} ); } );
@ -133,6 +134,7 @@ public class VideoPlayerService extends Service {
//Was seeing an error when exiting the program about about not unregistering the receiver. //Was seeing an error when exiting the program about about not unregistering the receiver.
if (null!=myNoisyAudioStreamReceiver) { if (null!=myNoisyAudioStreamReceiver) {
this.unregisterReceiver(myNoisyAudioStreamReceiver); this.unregisterReceiver(myNoisyAudioStreamReceiver);
myNoisyAudioStreamReceiver=null;
} }
if (player != null) { if (player != null) {
player.release(); player.release();