From f3066a4f18064d89684c55e2cebdd2e0a70614b4 Mon Sep 17 00:00:00 2001 From: YangJH Date: Sat, 20 Jan 2024 02:19:04 +0900 Subject: [PATCH] feat: add pipFullscreenPlayerView for makes PIP include video only --- .../exoplayer/ReactExoplayerView.java | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/android/src/main/java/com/brentvatne/exoplayer/ReactExoplayerView.java b/android/src/main/java/com/brentvatne/exoplayer/ReactExoplayerView.java index 631d94de81..4723d5f655 100644 --- a/android/src/main/java/com/brentvatne/exoplayer/ReactExoplayerView.java +++ b/android/src/main/java/com/brentvatne/exoplayer/ReactExoplayerView.java @@ -165,6 +165,7 @@ public class ReactExoplayerView extends FrameLayout implements private ExoPlayerView exoPlayerView; private FullScreenPlayerView fullScreenPlayerView; + private FullScreenPlayerView pipFullScreenPlayerView; private ImaAdsLoader adsLoader; private DataSource.Factory mediaDataSourceFactory; @@ -1886,6 +1887,32 @@ public void setPictureInPicture(boolean pictureInPictureEnabled) { protected void setIsInPictureInPicture(boolean isInPictureInPicture) { this.isInPictureInPicture = isInPictureInPicture; eventEmitter.onPictureInPictureStatusChanged(isInPictureInPicture); + if (isInPictureInPicture) { + if (fullScreenPlayerView != null && fullScreenPlayerView.isShowing()) { + fullScreenPlayerView.dismiss(); + } + if (pipFullScreenPlayerView == null) { + pipFullScreenPlayerView = new FullScreenPlayerView(getContext(), exoPlayerView, null, new OnBackPressedCallback(true) { + @Override + public void handleOnBackPressed() { } + }); + } + pipFullScreenPlayerView.show(); + } else { + if (pipFullScreenPlayerView != null && pipFullScreenPlayerView.isShowing()) { + pipFullScreenPlayerView.dismiss(); + } + if (controls) { + fullScreenPlayerView = new FullScreenPlayerView(getContext(), exoPlayerView, playerControlView, new OnBackPressedCallback(true) { + @Override + public void handleOnBackPressed() { + setFullscreen(false); + } + }); + fullScreenPlayerView.show(); + updateFullScreenButtonVisbility(); + } + } } private void updatePictureInPictureActions(boolean isPaused) {