Code Monkey home page Code Monkey logo

Comments (6)

marinaserranomontes avatar marinaserranomontes commented on June 12, 2024

Hi @sebastienrouif,

I think you could call session.onPause() from onStop() method in Android. But please note, the onPause() and onStop() in Android are a little different.

OnPause: an activity has lost focus but is still visible. A paused activity is completely alive.
OnStop: an activity is completely obscured by another activity. It is no longer visible to the user so its window is hidden and it will often be killed by the system when memory is needed elsewhere.

Best,
Marina

from opentok-android-sdk-samples.

sebastienrouif avatar sebastienrouif commented on June 12, 2024

Thanks @marinaserranomontes ,
Yes, I'm well aware of the basic definition of onPause() and onStop(), I was wondering if there was any hidden reason you specifically recommended onPause().
The Picture in picture example can be simplified by calling session.onPause in the activity onStop lifecycle callback as there is no need to check isInPictureInPictureMode()

from opentok-android-sdk-samples.

marinaserranomontes avatar marinaserranomontes commented on June 12, 2024

hi @sebastienrouif ,

Please note, the sample shows a specific use case for PiP scenario, where we have a button in the sample to "enter in PiP mode", so, in the sample, we will be "onPause" from:

  • PiP button
  • Home button

In the sample, we want to continue showing the video if we are in PiP mode. In other, case, we want to stop the video rendering. That is the main reason why we have a check of the PiP mode in the onPause method.

Best,
Marina

from opentok-android-sdk-samples.

sebastienrouif avatar sebastienrouif commented on June 12, 2024

Hi @marinaserranomontes ,
when entering Pip the activity is Paused but not stopped moving :
if (session != null) { session.onResume(); }
to onStart

and
if (session != null) { session.onPause(); }
to onStop
would avoid specifically checking for isInPictureInPictureMode
I'm happy to raise a PR to show it

from opentok-android-sdk-samples.

marinaserranomontes avatar marinaserranomontes commented on June 12, 2024

Hi @sebastienrouif ,

I am not sure what is the specific case you want to test.

Regarding the sample we have in the repo and the doc for PiP, just to comment, the PiP mode is going to call to "onPause()" method, and in our sample, we don't want to stop the video rendering in the PiP case. That is the main reason, why we have a check for PiP mode in the "onPause()" callback.
But if we are not in PiP mode, and we pause the activity, we want to stop the video rendering for publishers and subscribers, and to do that, we are using the OpenTok SDK method: "session.onPause()".

https://developer.android.com/guide/topics/ui/picture-in-picture
You can observe "When your activity switches to PIP, the system places the activity in the paused state and calls the activity's onPause() method. Video playback should not be paused and should continue playing if the activity is paused while in PIP mode."

Best,
Marina

from opentok-android-sdk-samples.

marinaserranomontes avatar marinaserranomontes commented on June 12, 2024

Hi @sebastienrouif ,

Iā€™m closing this issue because it has been inactive for a few weeks.

Please reopen if you still encounter this issue. You can also contribute directly to samples by providing a patch.

Thank you!

Best,
Marina

from opentok-android-sdk-samples.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    šŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. šŸ“ŠšŸ“ˆšŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ā¤ļø Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.