Closed jemise111 closed 2 years ago
Which version of react-native do you use ? Notive that on my working fork, I fully reimplement the lifecycle management. Normally video should not stop when app is paused... I need to find time to backport this change! Edit: and yes, the breakpoint to correctly placed
Hey @freeboub react native version is 0.66.4
Normally video should not stop when app is paused...
That's fine but I would think the playInBackground
prop can control this behavior
Great to hear you have it working on a fork, hopefully it can make it in the main branch here too. I appreciate all of the work on this!
I check on basic sample in the repo, I don't reproduce the issue ... even if I force playInBackground={false} but this should be the default behavior Can it be an issue with react / react integration ?
Wow @freeboub you're right. I created a fresh react native app and tried to reproduce this and I could not. I supposed it's an issue with an older version of react-native. Thanks for the suggestion!
I had the same issue, onHostResume/Pause methods not called. Fixed it by refactoring a bit.
I can't understand why though.
Instead of ReactExoplayerView implementing LifecycleEventListener
class ReactExoplayerView implements LifecycleEventListener {
....
themedReactContext.addLifecycleEventListener(this);
....
@Override
public void onHostResume() {
Create a new instance of lifecyclelistener and add it.
LifecycleEventListener lifecycleListener = new LifecycleEventListener() {
@Override
public void onHostResume() {
if (!playInBackground || !isInBackground) {
setPlayWhenReady(!isPaused);
}
isInBackground = false;
}
@Override
public void onHostPause() {
isInBackground = true;
if (playInBackground) {
return;
}
setPlayWhenReady(false);
}
@Override
public void onHostDestroy() {
stopPlayback();
themedReactContext.removeLifecycleEventListener(this);
}
};
themedReactContext.addLifecycleEventListener(lifecycleListener);
Bug
(Android only) Putting an app in the background with a video that is currently playing will not pause the video despite passing
playInBackground={false}
.I tried to debug a little and suspect that the React Native Lifecycle event callbacks aren't being triggered. I added a breakpoint here and it never gets called when backgrounding the app.
Platform
Environment info
Library version: 6.0.0-alpha.3
Steps To Reproduce
Expected behaviour
playInBackground
prop is set to false (which is the default) video should pause until app is resumedReproducible sample code
Should be reproducible with any instance of
Video
. e.g.