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

Take out auto-resume behavior on Android #795

Closed
wants to merge 1 commit into from
Closed

Take out auto-resume behavior on Android #795

wants to merge 1 commit into from

Conversation

lucask42
Copy link

@lucask42 lucask42 commented Sep 26, 2017

Upon pausing the video by backgrounding the app the video would restart upon bringing it to the foreground. This was due to using mActiveStatePauseStatus which is false after pausing via onHostPause(). This behavior is undesirable for our media playing app and also not the behavior on iOS. An alternative to this would have been to use mPaused as the boolean in onHostResume().

Upon pausing the video by backgrounding the app the video would restart upon bringing it to the foreground.  This was due to using mActiveStatePauseStatus which is false after pausing via onHostPause().  This behavior is undesirable for our media playing app.  An alternative to this would have been to use mPaused as the boolean in onHostResume().
@jasongonzales23
Copy link

👍

This change saved our bacon!

@lucask42 lucask42 changed the title reverse order of operations in onHostPause() Take out auto-resume behavior on Android Oct 9, 2017
@cobarx
Copy link
Contributor

cobarx commented Jun 9, 2018

Even though the behavior isn't consistent between iOS & Android, we need to keep it the same until we do a major version bump so that this doesn't break for people. I'll merge this when we do a 3.0 release.

@lucask42
Copy link
Author

Ok, makes sense, thanks for the work you do on this

@cobarx
Copy link
Contributor

cobarx commented Jun 22, 2018

@jasongonzales23 @lucask42
Ok, I've done some testing on this and what I'm seeing is that on both iOS & ExoPlayer when you return from the background the video starts playing if it wasn't paused before backgrounding.

I think the right choice is to keep that behavior for two reasons:

  1. That's the existing behavior and doesn't require changes to apps
  2. It makes sense for the video to always respect the paused prop. If I return to the app and paused is false, I'd expect the video to play not be paused.

If we take that approach, app developers who want the video to be paused after returning to the app can setup an AppState handler. When the handler sees a background event, it should update the app state so that a paused={true} prop gets passed.

However, on Android MediaPlayer onHostPause is wiping out the paused prop so that approach doesn't work currently. To fix that, I think we copy the ExoPlayer approach where there is a separate method that doesn't update the prop that's used to pause the player when going to the background. I'm happy to write that code, but would like to get your thoughts first in case I missed something.

@cobarx
Copy link
Contributor

cobarx commented Jun 22, 2018

Ok I've created #1082 to implement this. Please give it a test. It's working perfectly for me.

@cobarx cobarx closed this Jun 23, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants