Merge pull request #191 from dhk2/develop

fix the duplicate controllers in floating mode, and a possible crashing bug
This commit is contained in:
Stefan Schüller 2020-06-28 21:21:57 +02:00 committed by GitHub
commit a7874e35fe
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 17 additions and 3 deletions

View File

@ -353,10 +353,16 @@ public class VideoPlayActivity extends AppCompatActivity {
}
@Override
public void onPictureInPictureModeChanged (boolean isInPictureInPictureMode, Configuration newConfig) {
FragmentManager fragmentManager = getSupportFragmentManager();
VideoPlayerFragment videoPlayerFragment = (VideoPlayerFragment) fragmentManager.findFragmentById(R.id.video_player_fragment);
if (isInPictureInPictureMode) {
Log.v(TAG,"switched to pip ");
videoPlayerFragment.useController(false);
} else {
Log.v(TAG,"switched to normal");
videoPlayerFragment.useController(true);
}
}
}

View File

@ -199,7 +199,11 @@ public class VideoPlayerFragment extends Fragment implements VideoRendererEventL
}
});
}
public void useController(boolean value){
if (mBound){
simpleExoPlayerView.setUseController(value);
}
}
private void playVideo(Video video) {
Context context = getContext();

View File

@ -130,8 +130,12 @@ 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);
try {
if (null!=myNoisyAudioStreamReceiver) {
this.unregisterReceiver(myNoisyAudioStreamReceiver);
}
} catch (Exception e) {
Log.e("VideoPlayerService", "attempted to unregister a nonregistered service");
}
if (player != null) {
player.release();