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

Native Events Not Being Fired Upon Completion of Video When Device is Locked and Screen Turned Off #500

Closed
alexpareto opened this issue Feb 20, 2017 · 1 comment

Comments

@alexpareto
Copy link

alexpareto commented Feb 20, 2017

The events are emitted as long as the screen is on (even if the app is in the background), however when the device is locked and the screen is turned off events are never emitted until the application is opened back up.

For example the following code will output "video end" in the console but will never trigger the listener on the JS side of the application.

- (void)playerItemDidReachEnd:(NSNotification *)notification
{
  RCTLog(@"video end")
  [_eventDispatcher sendInputEventWithName:@"onVideoEnd" body:@{@"target": self.reactTag}];

  if (_repeat) {
    AVPlayerItem *item = [notification object];
    [item seekToTime:kCMTimeZero];
    [self applyModifiers];
  }
}

It appears to be related to this issue: facebook/react-native#1282 that was apparently solved in 0.14. However am experiencing this problem in react-native 0.37.

Any ideas on how to fix this/get around this issue?

Want to be able to fetch new audio tracks from the network while the app is in the background (similar to Spotify/other audio streaming apps).

@alexpareto
Copy link
Author

alexpareto commented Feb 23, 2017

Finally figured it out. My onEnd() javascript callback did not take in an event parameter. Changing it to onEnd(event) solved all the problems. Interestingly no errors/exceptions were thrown throughout the debugging process and the callback worked fine as long as the screen was not both turned off and locked. Weird. Turns out it was not related to native events as I initially thought.

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

No branches or pull requests

1 participant