opentok / opentok-react-native

OpenTok React Native - a library for OpenTok iOS and Android SDKs
https://tokbox.com/
MIT License
212 stars 156 forks source link

Picture-in-picture support for backgrounded Android app #172

Open sunweiyang opened 6 years ago

sunweiyang commented 6 years ago

Feature Request

Description Android picture-in-picture (PIP) multi-window mode lets the user continue to have an OpenTok video chat (most likely only the subscriber view is visible) pinned to a corner of the screen while navigating between different other apps.

Proposal The opentok-react-native package's Android implementation can support picture-in-picture as an option. App backgrounding and app switching is an extremely common user behavior for video calling apps, and users' expectations are typically to continue the video call throughout these switches (i.e. checking their calendar/email for a quick item to tell their video call partner, etc.)

Links / references https://developer.android.com/guide/topics/ui/picture-in-picture https://tokbox.com/blog/android-picture-in-picture/

msach22 commented 5 years ago

@sunweiyang We should be able to add this in. Can you propose an API and how you would expect it to work? For example, should it be the publisher or the subscriber that we see when it goes into background mode. What happens when there are multiple subscribers?

sunweiyang commented 5 years ago

Here is a proposal: by default, the PIP would show the first subscriber (if it exists), and if no subscribers exist, then the first publisher (if it exists). Otherwise, developers can also manually choose which publisher or subscriber to show, via an optional prop.

If no stream exists, or if no publisher or subscriber exists, or if the optional prop is null, then PIP would not be enabled.

msach22 commented 5 years ago

@sunweiyang Since PIP is not the default, I think it should be an opt in API.

pip={true} // default would be false
by default, the PIP would show the first subscriber (if it exists), and if no subscribers exist, then the first publisher (if it exists). 

This may get a bit confusing because what if you publish and also immediately subscribe then we would see some sort of. How about specifying explicitly which view you want to see in background mode?

sunweiyang commented 5 years ago

@msach22 Yes, opt-in PIP and explicitly specifying the view to show in PIP both sound good, and is simpler.

msach22 commented 5 years ago

@sunweiyang To continue on this, do you think it should be a session level setting (like using a prop for OTSession)? This way we can always make sure they know if it's the publisher or the subscriber?

sunweiyang commented 5 years ago

@msach22 I think you're right; an OTSession prop for defining the PIP view would make things more explicit, and it's something we would expect as a developer experience.