From d525da2863c6ecec7041f76e603b9cbebf00cd0e Mon Sep 17 00:00:00 2001 From: dhk2 Date: Sun, 28 Jun 2020 07:49:36 -0700 Subject: [PATCH] fixing duplicate controlelrs --- .../schueller/peertube/activity/VideoPlayActivity.java | 8 +++++--- .../schueller/peertube/fragment/VideoPlayerFragment.java | 4 +++- 2 files changed, 8 insertions(+), 4 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 4fb14bc..1a22981 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,6 @@ 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 +108,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); @@ -287,7 +286,7 @@ public class VideoPlayActivity extends AppCompatActivity { public void onBackPressed() { SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(this); - videoPlayerFragment = (VideoPlayerFragment) + VideoPlayerFragment videoPlayerFragment = (VideoPlayerFragment) getSupportFragmentManager().findFragmentById(R.id.video_player_fragment); //copying Youtube behavior to have back button exit full screen. @@ -353,6 +352,9 @@ 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); 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 9bdc382..f7cac8a 100644 --- a/app/src/main/java/net/schueller/peertube/fragment/VideoPlayerFragment.java +++ b/app/src/main/java/net/schueller/peertube/fragment/VideoPlayerFragment.java @@ -200,7 +200,9 @@ public class VideoPlayerFragment extends Fragment implements VideoRendererEventL }); } public void useController(boolean value){ - simpleExoPlayerView.setUseController(value); + if (mBound){ + simpleExoPlayerView.setUseController(value); + } } private void playVideo(Video video) {