From 9eaa9abaec1c7c6bdc06d5fba85cb01d4d53c5fb Mon Sep 17 00:00:00 2001 From: dhk2 Date: Sun, 28 Jun 2020 07:29:40 -0700 Subject: [PATCH 1/5] 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(); From 6b26de862dbc110675f4e403082d6d5b71ea60a2 Mon Sep 17 00:00:00 2001 From: dhk2 Date: Sun, 28 Jun 2020 07:41:48 -0700 Subject: [PATCH 2/5] fixing duplicate controlelrs --- .../java/net/schueller/peertube/activity/VideoPlayActivity.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 49a23eb..4fb14bc 100644 --- a/app/src/main/java/net/schueller/peertube/activity/VideoPlayActivity.java +++ b/app/src/main/java/net/schueller/peertube/activity/VideoPlayActivity.java @@ -287,7 +287,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. From d525da2863c6ecec7041f76e603b9cbebf00cd0e Mon Sep 17 00:00:00 2001 From: dhk2 Date: Sun, 28 Jun 2020 07:49:36 -0700 Subject: [PATCH 3/5] 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) { From a6aa82892d7ec68f42004fc7f69d2c9fbcebf558 Mon Sep 17 00:00:00 2001 From: dhk2 Date: Sun, 28 Jun 2020 07:55:07 -0700 Subject: [PATCH 4/5] fixing duplicate controlelrs --- .../java/net/schueller/peertube/activity/VideoPlayActivity.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 1a22981..45cddf7 100644 --- a/app/src/main/java/net/schueller/peertube/activity/VideoPlayActivity.java +++ b/app/src/main/java/net/schueller/peertube/activity/VideoPlayActivity.java @@ -108,7 +108,7 @@ public class VideoPlayActivity extends AppCompatActivity { protected void onNewIntent(Intent intent) { super.onNewIntent(intent); setIntent(intent); - VideoPlayerFragment videoPlayerFragment = (VideoPlayerFragment) + VideoPlayerFragment videoPlayerFragment = (VideoPlayerFragment) getSupportFragmentManager().findFragmentById(R.id.video_player_fragment); assert videoPlayerFragment != null; String videoUuid = intent.getStringExtra(VideoListActivity.EXTRA_VIDEOID); From 5da8d68682e6791d4de07f55fe5fb46909c55e4b Mon Sep 17 00:00:00 2001 From: dhk2 Date: Sun, 28 Jun 2020 07:57:24 -0700 Subject: [PATCH 5/5] fixing duplicate controlelrs --- .../java/net/schueller/peertube/activity/VideoPlayActivity.java | 1 + 1 file changed, 1 insertion(+) 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 45cddf7..3f658da 100644 --- a/app/src/main/java/net/schueller/peertube/activity/VideoPlayActivity.java +++ b/app/src/main/java/net/schueller/peertube/activity/VideoPlayActivity.java @@ -62,6 +62,7 @@ public class VideoPlayActivity extends AppCompatActivity { private static final String TAG = "VideoPlayActivity"; + @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState);