@@ -272,6 +272,9 @@ public class ReactExoplayerView extends FrameLayout implements
272
272
273
273
private CmcdConfiguration .Factory cmcdConfigurationFactory ;
274
274
275
+ private ViewGroup originalParent ;
276
+ private LayoutParams originalLayoutParams ;
277
+
275
278
public void setCmcdConfigurationFactory (CmcdConfiguration .Factory factory ) {
276
279
this .cmcdConfigurationFactory = factory ;
277
280
}
@@ -2276,29 +2279,39 @@ protected void setIsInPictureInPicture(boolean isInPictureInPicture) {
2276
2279
View decorView = currentActivity .getWindow ().getDecorView ();
2277
2280
ViewGroup rootView = decorView .findViewById (android .R .id .content );
2278
2281
2279
- LayoutParams layoutParams = new LayoutParams (
2280
- LayoutParams .MATCH_PARENT ,
2281
- LayoutParams .MATCH_PARENT );
2282
-
2283
2282
if (isInPictureInPicture ) {
2284
- ViewGroup parent = (ViewGroup )exoPlayerView .getParent ();
2285
- if (parent != null ) {
2286
- parent .removeView (exoPlayerView );
2287
- }
2283
+ // Store original parent and layout params
2284
+ originalParent = (ViewGroup )exoPlayerView .getParent ();
2285
+ originalLayoutParams = (LayoutParams )exoPlayerView .getLayoutParams ();
2286
+
2287
+ if (originalParent != null ) {
2288
+ originalParent .removeView (exoPlayerView );
2289
+ }
2290
+
2288
2291
for (int i = 0 ; i < rootView .getChildCount (); i ++) {
2289
2292
if (rootView .getChildAt (i ) != exoPlayerView ) {
2290
2293
rootViewChildrenOriginalVisibility .add (rootView .getChildAt (i ).getVisibility ());
2291
2294
rootView .getChildAt (i ).setVisibility (View .GONE );
2292
2295
}
2293
2296
}
2294
- rootView .addView (exoPlayerView , layoutParams );
2297
+
2298
+ LayoutParams pipParams = new LayoutParams (
2299
+ LayoutParams .MATCH_PARENT ,
2300
+ LayoutParams .MATCH_PARENT );
2301
+ rootView .addView (exoPlayerView , pipParams );
2295
2302
} else {
2296
2303
rootView .removeView (exoPlayerView );
2297
2304
if (!rootViewChildrenOriginalVisibility .isEmpty ()) {
2298
2305
for (int i = 0 ; i < rootView .getChildCount (); i ++) {
2299
2306
rootView .getChildAt (i ).setVisibility (rootViewChildrenOriginalVisibility .get (i ));
2300
2307
}
2301
- addView (exoPlayerView , 0 , layoutParams );
2308
+
2309
+ // Restore original parent and layout params
2310
+ if (originalParent != null ) {
2311
+ originalParent .addView (exoPlayerView , originalLayoutParams );
2312
+ // Force layout update
2313
+ reLayoutControls ();
2314
+ }
2302
2315
}
2303
2316
}
2304
2317
}
0 commit comments