From 9eaa9abaec1c7c6bdc06d5fba85cb01d4d53c5fb Mon Sep 17 00:00:00 2001 From: dhk2 Date: Sun, 28 Jun 2020 07:29:40 -0700 Subject: [PATCH] fixing duplicate controlelrs --- .../schueller/peertube/activity/VideoPlayActivity.java | 7 +++++-- .../schueller/peertube/fragment/VideoPlayerFragment.java | 4 +++- .../schueller/peertube/service/VideoPlayerService.java | 8 ++++++-- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/net/schueller/peertube/activity/VideoPlayActivity.java b/app/src/main/java/net/schueller/peertube/activity/VideoPlayActivity.java index 28e80ad..49a23eb 100644 --- a/app/src/main/java/net/schueller/peertube/activity/VideoPlayActivity.java +++ b/app/src/main/java/net/schueller/peertube/activity/VideoPlayActivity.java @@ -61,7 +61,7 @@ import static net.schueller.peertube.helper.Constants.THEME_PREF_KEY; public class VideoPlayActivity extends AppCompatActivity { private static final String TAG = "VideoPlayActivity"; - + VideoPlayerFragment videoPlayerFragment; @Override protected void onCreate(Bundle savedInstanceState) { @@ -109,7 +109,7 @@ public class VideoPlayActivity extends AppCompatActivity { protected void onNewIntent(Intent intent) { super.onNewIntent(intent); setIntent(intent); - VideoPlayerFragment videoPlayerFragment = (VideoPlayerFragment) + videoPlayerFragment = (VideoPlayerFragment) getSupportFragmentManager().findFragmentById(R.id.video_player_fragment); assert videoPlayerFragment != null; String videoUuid = intent.getStringExtra(VideoListActivity.EXTRA_VIDEOID); @@ -355,8 +355,11 @@ public class VideoPlayActivity extends AppCompatActivity { public void onPictureInPictureModeChanged (boolean isInPictureInPictureMode, Configuration newConfig) { if (isInPictureInPictureMode) { Log.v(TAG,"switched to pip "); + videoPlayerFragment.useController(false); } else { Log.v(TAG,"switched to normal"); + videoPlayerFragment.useController(true); } } + } 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 a37af1c..9bdc382 100644 --- a/app/src/main/java/net/schueller/peertube/fragment/VideoPlayerFragment.java +++ b/app/src/main/java/net/schueller/peertube/fragment/VideoPlayerFragment.java @@ -199,7 +199,9 @@ public class VideoPlayerFragment extends Fragment implements VideoRendererEventL } }); } - + public void useController(boolean value){ + simpleExoPlayerView.setUseController(value); + } private void playVideo(Video video) { Context context = getContext(); 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 bb22505..e3fcb71 100644 --- a/app/src/main/java/net/schueller/peertube/service/VideoPlayerService.java +++ b/app/src/main/java/net/schueller/peertube/service/VideoPlayerService.java @@ -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();