From 973651e4161be124f7272c9f6427caf3132b3da0 Mon Sep 17 00:00:00 2001 From: olivier bouillet Date: Thu, 3 Nov 2022 08:26:06 +0100 Subject: [PATCH 1/6] fix(android): hide fullscreen button when already in full screen --- .../java/com/brentvatne/exoplayer/ReactExoplayerView.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/android/src/main/java/com/brentvatne/exoplayer/ReactExoplayerView.java b/android/src/main/java/com/brentvatne/exoplayer/ReactExoplayerView.java index 6d94dc6c..8d1393e2 100644 --- a/android/src/main/java/com/brentvatne/exoplayer/ReactExoplayerView.java +++ b/android/src/main/java/com/brentvatne/exoplayer/ReactExoplayerView.java @@ -406,7 +406,12 @@ class ReactExoplayerView extends FrameLayout implements }); //Handling the fullScreenButton click event - ImageButton fullScreenButton = playerControlView.findViewById(R.id.exo_fullscreen); + final ImageButton fullScreenButton = playerControlView.findViewById(R.id.exo_fullscreen); + if (isFullscreen && !fullScreenPlayerView.isShowing()) { + fullScreenButton.setVisibility(GONE); + } else { + fullScreenButton.setVisibility(VISIBLE); + } fullScreenButton.setOnClickListener(v -> setFullscreen(!isFullscreen)); // Invoking onPlaybackStateChanged and onPlayWhenReadyChanged events for Player @@ -421,7 +426,6 @@ class ReactExoplayerView extends FrameLayout implements if (pauseButton != null && pauseButton.getVisibility() == GONE) { pauseButton.setVisibility(INVISIBLE); } - reLayout(playPauseControlContainer); //Remove this eventListener once its executed. since UI will work fine once after the reLayout is done player.removeListener(eventListener); From 845f34fefd784a6f07f47983e6578132921e5be6 Mon Sep 17 00:00:00 2001 From: olivier bouillet Date: Thu, 3 Nov 2022 08:26:31 +0100 Subject: [PATCH 2/6] test: add fullscreen prop in sample --- examples/basic/src/VideoPlayer.android.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/examples/basic/src/VideoPlayer.android.tsx b/examples/basic/src/VideoPlayer.android.tsx index 4b426ace..ef17ac5b 100644 --- a/examples/basic/src/VideoPlayer.android.tsx +++ b/examples/basic/src/VideoPlayer.android.tsx @@ -715,6 +715,7 @@ class VideoPlayer extends Component { paused={this.state.paused} volume={this.state.volume} muted={this.state.muted} + fullscreen={this.state.fullscreen} controls={this.state.showRNVControls} resizeMode={this.state.resizeMode} onLoad={this.onLoad} From a323bd0523eff8c68940e7fbe6aca254679adf96 Mon Sep 17 00:00:00 2001 From: olivier bouillet Date: Thu, 3 Nov 2022 23:05:39 +0100 Subject: [PATCH 3/6] fix: refactor fullScreenPlayerView creation --- .../exoplayer/ReactExoplayerView.java | 24 +++++++------------ 1 file changed, 9 insertions(+), 15 deletions(-) diff --git a/android/src/main/java/com/brentvatne/exoplayer/ReactExoplayerView.java b/android/src/main/java/com/brentvatne/exoplayer/ReactExoplayerView.java index 8d1393e2..520ec3ce 100644 --- a/android/src/main/java/com/brentvatne/exoplayer/ReactExoplayerView.java +++ b/android/src/main/java/com/brentvatne/exoplayer/ReactExoplayerView.java @@ -372,6 +372,15 @@ class ReactExoplayerView extends FrameLayout implements playerControlView = new PlayerControlView(getContext()); } + if (fullScreenPlayerView == null) { + fullScreenPlayerView = new FullScreenPlayerView(getContext(), exoPlayerView, playerControlView, new OnBackPressedCallback(true) { + @Override + public void handleOnBackPressed() { + setFullscreen(false); + } + }); + } + // Setting the player for the playerControlView playerControlView.setPlayer(player); playPauseControlContainer = playerControlView.findViewById(R.id.exo_play_pause_container); @@ -679,12 +688,6 @@ class ReactExoplayerView extends FrameLayout implements setControls(controls); applyModifiers(); startBufferCheckTimer(); - fullScreenPlayerView = new FullScreenPlayerView(getContext(), exoPlayerView, playerControlView, new OnBackPressedCallback(true) { - @Override - public void handleOnBackPressed() { - setFullscreen(false); - } - }); } private DrmSessionManager buildDrmSessionManager(UUID uuid, String licenseUrl, String[] keyRequestPropertiesArray) throws UnsupportedDrmException { @@ -1786,15 +1789,6 @@ class ReactExoplayerView extends FrameLayout implements return; } - if (fullScreenPlayerView == null) { - fullScreenPlayerView = new FullScreenPlayerView(getContext(), exoPlayerView, playerControlView, new OnBackPressedCallback(true) { - @Override - public void handleOnBackPressed() { - setFullscreen(false); - } - }); - } - Window window = activity.getWindow(); View decorView = window.getDecorView(); int uiOptions; From 53fe1973e5c47589601ccc8be56fecb42ab5beb3 Mon Sep 17 00:00:00 2001 From: olivier bouillet Date: Thu, 3 Nov 2022 23:06:12 +0100 Subject: [PATCH 4/6] fix: review safety checks --- .../java/com/brentvatne/exoplayer/ReactExoplayerView.java | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/android/src/main/java/com/brentvatne/exoplayer/ReactExoplayerView.java b/android/src/main/java/com/brentvatne/exoplayer/ReactExoplayerView.java index 520ec3ce..375c58db 100644 --- a/android/src/main/java/com/brentvatne/exoplayer/ReactExoplayerView.java +++ b/android/src/main/java/com/brentvatne/exoplayer/ReactExoplayerView.java @@ -454,7 +454,7 @@ class ReactExoplayerView extends FrameLayout implements * Adding Player control to the frame layout */ private void addPlayerControl() { - if(player == null) return; + if(playerControlView == null) return; LayoutParams layoutParams = new LayoutParams( LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT); @@ -1802,7 +1802,7 @@ class ReactExoplayerView extends FrameLayout implements | SYSTEM_UI_FLAG_FULLSCREEN; } eventEmitter.fullscreenWillPresent(); - if (controls) { + if (controls && fullScreenPlayerView != null) { fullScreenPlayerView.show(); } post(() -> { @@ -1812,7 +1812,7 @@ class ReactExoplayerView extends FrameLayout implements } else { uiOptions = View.SYSTEM_UI_FLAG_VISIBLE; eventEmitter.fullscreenWillDismiss(); - if (controls) { + if (controls && fullScreenPlayerView != null) { fullScreenPlayerView.dismiss(); reLayout(exoPlayerView); } @@ -1889,7 +1889,6 @@ class ReactExoplayerView extends FrameLayout implements */ public void setControls(boolean controls) { this.controls = controls; - if (player == null || exoPlayerView == null) return; if (controls) { addPlayerControl(); } else { From 55209b48c04ef01ef6593972c8313d61abfceb21 Mon Sep 17 00:00:00 2001 From: olivier bouillet Date: Thu, 3 Nov 2022 23:06:42 +0100 Subject: [PATCH 5/6] fix: refactor full screen button visibility update --- .../exoplayer/ReactExoplayerView.java | 25 +++++++++++++++---- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/android/src/main/java/com/brentvatne/exoplayer/ReactExoplayerView.java b/android/src/main/java/com/brentvatne/exoplayer/ReactExoplayerView.java index 375c58db..8850610f 100644 --- a/android/src/main/java/com/brentvatne/exoplayer/ReactExoplayerView.java +++ b/android/src/main/java/com/brentvatne/exoplayer/ReactExoplayerView.java @@ -416,12 +416,8 @@ class ReactExoplayerView extends FrameLayout implements //Handling the fullScreenButton click event final ImageButton fullScreenButton = playerControlView.findViewById(R.id.exo_fullscreen); - if (isFullscreen && !fullScreenPlayerView.isShowing()) { - fullScreenButton.setVisibility(GONE); - } else { - fullScreenButton.setVisibility(VISIBLE); - } fullScreenButton.setOnClickListener(v -> setFullscreen(!isFullscreen)); + updateFullScreenButtonVisbility(); // Invoking onPlaybackStateChanged and onPlayWhenReadyChanged events for Player eventListener = new Player.Listener() { @@ -1774,6 +1770,22 @@ class ReactExoplayerView extends FrameLayout implements this.disableBuffering = disableBuffering; } + private void updateFullScreenButtonVisbility() { + if (playerControlView != null) { + final ImageButton fullScreenButton = playerControlView.findViewById(R.id.exo_fullscreen); + if (controls) { + //Handling the fullScreenButton click event + if (isFullscreen && fullScreenPlayerView != null && !fullScreenPlayerView.isShowing()) { + fullScreenButton.setVisibility(GONE); + } else { + fullScreenButton.setVisibility(VISIBLE); + } + } else { + fullScreenButton.setVisibility(GONE); + } + } + } + public void setDisableDisconnectError(boolean disableDisconnectError) { this.disableDisconnectError = disableDisconnectError; } @@ -1821,6 +1833,8 @@ class ReactExoplayerView extends FrameLayout implements eventEmitter.fullscreenDidDismiss(); }); } + // need to be done at the end to avoid hiding fullscreen control button when fullScreenPlayerView is shown + updateFullScreenButtonVisbility(); } public void setUseTextureView(boolean useTextureView) { @@ -1891,6 +1905,7 @@ class ReactExoplayerView extends FrameLayout implements this.controls = controls; if (controls) { addPlayerControl(); + updateFullScreenButtonVisbility(); } else { int indexOfPC = indexOfChild(playerControlView); if (indexOfPC != -1) { From 870f831936ec3a7432e1807dc5149a57a0da9f9c Mon Sep 17 00:00:00 2001 From: olivier bouillet Date: Mon, 7 Nov 2022 22:35:06 +0100 Subject: [PATCH 6/6] chore: update changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0a956d2a..d5ae6b65 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ - Android: fix linter warning [#2891] (https://github.com/react-native-video/react-native-video/pull/2891) - Fix iOS RCTSwiftLog naming collision [#2868](https://github.com/react-native-video/react-native-video/issues/2868) - Added "homepage" to package.json [#2882](https://github.com/react-native-video/react-native-video/pull/2882) +- Fix regression when fullscreen prop is used combined with controls [#2911](https://github.com/react-native-video/react-native-video/pull/2911) ### Version 6.0.0-alpha.3