THEOplayer / react-native-theoplayer

A React Native THEOplayerView component
https://theoplayer.github.io/react-native-theoplayer/
MIT License
58 stars 21 forks source link

Android PIP layout is broken #225

Closed KestasVenslauskas closed 4 months ago

KestasVenslauskas commented 9 months ago

When trying to use PIP on android while player is not a fullscreen view it renders just the top of the screen:

image

Here is that screen:

image
tvanlaerhoven commented 9 months ago

Hi @KestasVenslauskas ,

The PiP presentation mode gets the visible rectangle of the player screen and passes this to the PiP parameters when transitioning to PiP.

https://github.com/THEOplayer/react-native-theoplayer/blob/develop/android/src/main/java/com/theoplayer/presentation/PipUtils.kt#L198

So I wouldn't expect to see the action bar here. Can you check if the visible rectangle is computed correctly here? As a workaround you could also experiment with hiding/showing the action bar when transitioning to/from PiP.

Additionally, you can also contact us through the service desk to pass some relevant app code. In that case the issue will flow through our regular defect flow.

KestasVenslauskas commented 9 months ago

Everyting works fine if I make a full screen layout will test different layouting options

KestasVenslauskas commented 9 months ago

@tvanlaerhoven

So I tried to play around with layouts. To get the best results I tried to use as minimal layout as possible:

image

My findings:

  1. If a player is at the top of the screen & screen is without header so there is nothing above the player it works fine. Rect(0, 66 - 1080, 673)

    image
  2. I tried adding text "test" on over the video player. Rect(0, 119 - 1080, 726)

    image
  3. Added 2 more "test" texts on top & 2 "test" texts on bottom Rect(0, 225 - 1080, 832)

    image
tvanlaerhoven commented 8 months ago

@KestasVenslauskas we'll take it up internally

tvanlaerhoven commented 4 months ago

Hey @KestasVenslauskas , following up on the issue above. Was this solved? We do set a sourceRectHint in our code, as mentioned before, but this is only for the transition from/to PiP. The screen's layout needs to make sure no other UI elements are visible: https://developer.android.com/develop/ui/views/picture-in-picture#best

PiP is intended for activities that play full-screen video. When switching your activity into PiP mode, avoid showing anything except video content. Track when your activity enters PiP mode and hide UI elements, as described in Handling UI during PiP.

So in the example above, the "test" Text element would need to be hidden in PiP mode: {presentationMode !== PresentationMode.pip && <Text>test</Text>}

tvanlaerhoven commented 4 months ago

@KestasVenslauskas closing this ticket for now. Let us know in case you need additional support.