Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PIP support for android in case of nested screen #1858

Closed
nitesh3539 opened this issue Dec 24, 2019 · 6 comments
Closed

PIP support for android in case of nested screen #1858

nitesh3539 opened this issue Dec 24, 2019 · 6 comments
Labels
stale Closed due to inactivity or lack or resources

Comments

@nitesh3539
Copy link

I want to use PIP mode in child screen such that PIP mode comes on top of parent screen.

Like if we have parent screen A and child screen B, If we are in screen B and want to allow Screen B to go In PIP mode, Then , screen B comes as PIP mode on top of Screen A.

Please help me out.

Thanks

@matejpolak
Copy link

Hi @nitesh3539, the above described scenario is not an ideal case for PIP mode. PiP mode in general behaves differently on each platform, like this:

So far, PiP mode as is, is working only on Android and iOS (iPad ONLY!)

  1. iOS (iPad) - Should be working same as you described above.
  2. Android - When entering PIP mode (by setting pictureInPicture prop, or pressing Home/Recent button) Whole app goes to PIP, so the app itself if minified and you see the android home screen for example and the minified app in a PIP window above it.

But the case you are describing is fully achievable by styles of the player window (if player is screen B). I have it like this in several projects already.

See:
65509102-fe732180-ded1-11e9-829b-09c92e47ae68

65509104-003ce500-ded2-11e9-9af2-bf2190e4fa21

65509110-016e1200-ded2-11e9-84b0-3686ee469aaa

All those examples are combination of styles and PanResponers, and obviously it's working on all platforms.

@nitesh3539
Copy link
Author

can you reference me with a set of code ?

Thanks

@nitesh3539
Copy link
Author

Hi @matejpolak please update me on this. I need a neet explanation for this.

Thanks

@matejpolak
Copy link

Hi @nitesh3539, please think about the player as of any other UI element like a div or View for example. You can style it in any way you like, you can for example make it rounded and bouncing on the screen, same as any other element. So in my case, I have a MiniPlayerContainer component, which receiver all the player UI elements and Video component as a children prop and render it like this.

    return renderMiniPlayerContainer ? (
        <Animated.View
            style={{
                position: 'absolute',
                bottom: isMiniPlayer ? margin : 0,
                right: isMiniPlayer ? margin : 0,
                transform: [{ translateX: this.translateX }],
                width: this.playerWidth.interpolate({
                    inputRange: [0, 100],
                    outputRange: ['0%', '100%']
                }),
                height: this.playerHeight.interpolate({
                    inputRange: [0, 100],
                    outputRange: ['0%', '100%']
                })
            }}
            {...(isMiniPlayer ? this.panResponder.panHandlers : {})}
        >
            <View
                // We must keep both views,
                // because Animated.View doesn't have onLayout callback prop
                style={styles}
                onLayout={this.onContainerLayout}
            >
                {children}
            </View>
        </Animated.View>
    ) : (
        children
    );

In the code above, width and height are either 100 and 100 (fullscreen player), or any other value like 25 and 30 (landscape miniplayer). Hope this helps. Please consider this as a non tested raw snippet explaining my idea behind it.

@matejpolak
Copy link

And for the swipe gesture, you can use something like this: https://medium.com/@andi.gu.ca/exploring-react-natives-panresponder-and-layoutanimation-dde77e7f4cc9.

But again, please, this is only my idea, and there are of course similar/better/more... ways how to achieve above described behavior.

@stale
Copy link

stale bot commented Apr 19, 2022

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. If you are having a similar problem, please open a new issue and reference this one instead of commenting on a stale or closed issue.

@stale stale bot added the stale Closed due to inactivity or lack or resources label Apr 19, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stale Closed due to inactivity or lack or resources
Projects
None yet
Development

No branches or pull requests

3 participants