Skip to content

Commit

Permalink
Safely re-add view after fullscreen. Ensure non-fullscreen after PiP (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
Jmilham21 authored Oct 23, 2024
1 parent 83c1fd2 commit 80059bc
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions android/src/main/java/com/jwplayer/rnjwplayer/RNJWPlayerView.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,10 @@
import android.os.Handler;
import android.os.Looper;
import android.util.Log;
import android.view.Choreographer;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.view.WindowManager;
import android.widget.FrameLayout;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;

Expand All @@ -41,8 +39,8 @@
import com.facebook.react.uimanager.events.RCTEventEmitter;
import com.google.common.collect.ImmutableMap;
import com.google.gson.Gson;
import com.jwplayer.pub.api.JsonHelper;
import com.jwplayer.pub.api.JWPlayer;
import com.jwplayer.pub.api.JsonHelper;
import com.jwplayer.pub.api.UiGroup;
import com.jwplayer.pub.api.background.MediaServiceController;
import com.jwplayer.pub.api.configuration.PlayerConfig;
Expand Down Expand Up @@ -113,15 +111,15 @@
import com.jwplayer.pub.api.media.playlists.PlaylistItem;
import com.jwplayer.ui.views.CueMarkerSeekbar;

import org.json.JSONObject;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;

import org.json.JSONObject;

public class RNJWPlayerView extends RelativeLayout implements
VideoPlayerEvents.OnFullscreenListener,
VideoPlayerEvents.OnReadyListener,
Expand Down Expand Up @@ -622,6 +620,9 @@ public void onFullscreenExitRequested() {
mPlayerViewContainer.post(new Runnable() {
@Override
public void run() {
// View may not have been removed properly (especially if returning from PiP)
mPlayerViewContainer.removeView(mPlayerView);

mPlayerViewContainer.addView(mPlayerView, new ViewGroup.LayoutParams(
ViewGroup.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.MATCH_PARENT));
Expand Down Expand Up @@ -714,6 +715,11 @@ public void onReceive(Context context, Intent intent) {
mPlayer.setForceControlsVisibility(true);
mPlayer.setForceControlsVisibility(false);

// If player was in fullscreen when going into PiP, we need to force it back out
if (mPlayer.getFullscreen()) {
mPlayer.setFullscreen(false, true);
}

// Strip player view
rootView.removeView(mPlayerView);

Expand Down

0 comments on commit 80059bc

Please sign in to comment.