Comments (11)
Was able to fix this by simply adding a listener using AppStateIOS
module and setting the repeat
prop to false
when the app was not active
. Closing this issue as it's really more of an enhancement. Feel free to reopen as such.
from react-native-video.
Quick update. Still seeing this issue sometimes even with use of AppStateIOS. Haven't figured out root cause as it's difficult to reproduce consistently. What I can mention is that, when the device wakes, it's often running hot and the video seems to appear momentarily before getting replaced with a black background.
In closed beta right now and none of my internal testers have brought it up yet, but if they do I may have to get more surgical to address.
from react-native-video.
Thanks for re-opening @brentvatne. Just had my first beta user report the issue and mentioned the black screen. Said he'd left the app running in the background and when he came back to it some time later this issue occurred.
from react-native-video.
@jhabdas - I think the desired behaviour here is to automatically pause the video when we background the app, and resume it when you jump back in. But we can make this controllable via a prop as well, because there may be situations where you want to have audio/video running in background (eg: a media player app like Rdio or Spotify) π
from react-native-video.
Sounds good. Will continue with your recommendations and tightening up my state management and update later. Hope to see some sweet control center integration with the audio going into this awesome component. Keep up the great work!
from react-native-video.
Based on additional research and debugging today I was able to replicate this issue even without the video looping. As such I have adjusted the title and description of this issue, cut a pre-release version of the affected app and updated the steps to replicate.
As far as I can tell, this issue should be able to be replicated on any app which uses this component if the device is locked (replicated consistently on iPhone 6) without first sending the app into the background, and with the USB connection to Xcode unplugged.
A workaround for this issue would be to remove the video component when the app state goes into the background
, but, from what I can see, the AppStateIOS module doesn't fire the UIApplicationDidEnterBackgroundNotification
event in time for it to make it over the bridge; the JS event listeners can't catch it in time to respond.
I tried to speed things up a little by dispatching my own inactive
event across the bridge with some light abuse of appStateDidChange
, though, unfortunately, even this event wasn't fast enough and was only received after the app was unlocked (as if it were somehow deferred).
Here's some code for anyone who want's to give the inactive
hack a try:
- (void) applicationWillResign
{
[self.bridge.eventDispatcher sendDeviceEventWithName:@"appStateDidChange"
body:@{@"app_state": @"inactive"}]; // received on JS side of bridge only after the device is unlocked
NSLog(@"derp"); // outputs to log a moment after the screen is locked
}
- (void) subscribeToNotifications
{
[[NSNotificationCenter defaultCenter]
addObserver:self
selector:@selector(applicationWillResign)
name:UIApplicationWillResignActiveNotification
object:nil];
}
Unfortunately this means I'm going to have to remove this component from my app until a suitable workaround or fix can be found. I'd love to study any app using this component which does not express this issue if someone can point me in the right direction.
from react-native-video.
@jhabdas - I can't seem to get your project running :( followed your README instructions and got this:
I tried the steps you mentioned above on an app that I have which uses video and I didn't have the problem, but I tried a fix anyways and pushed it in 0.4.8
- can you let me know if that works for you? (1f901be)
from react-native-video.
Thanks for cutting a new version @brentvatne. Unfortunately I'm still seeing the same problem after pulling in 0.4.8
. Because my app's about 2 minors behind react-native
now I'm going to pull it forward to the latest stable to see if that helps clear things up. I also subbed #65, though I'm not sure it's necessary as, at least in my case, I noticed the problem occurred with and without looping enabled.
I'll update with more info mid to late next week on the outcomes of the update. Meanwhile, unless others are seeing this issue, it may be pertinent to bump again to pull the changes in 1f901be. Your call, of course.
Thanks for your time and attention on this. More info to follow.
from react-native-video.
Hey @jhabdas - that's very strange, I wonder why this would be happening if it's being paused when the app becomes inactive. I haven't seen any mention of this in googling for AVPlayer issues so it doesn't seem to be specific to that. @johanneslumpe - any ideas?
from react-native-video.
Resolved with bump to React Native v0.5.0
(or v0.6.0
) and React Native Video v0.4.9
. Looks like there were some dispatcher bugs resolved in v0.5.0-rc
which I overlooked while debugging, and when I test drove the latest version of this component the other day I did so using a 0.4.x
version of React Native. Derp.
from react-native-video.
Awesome! π
from react-native-video.
Related Issues (20)
- [BUG]: After destroying the player on iOS, the sound continues playing. HOT 6
- [BUG]: `onTextTracks` Callback Not Logging Subtitles Correctly Despite VTT Files Being Fetched HOT 2
- [BUG]: iOS Audio Ducking on muted or silent video HOT 5
- [BUG]: onSeek event called instantly on Android
- [BUG]: iOS βΒ After returning to active after Mirroring, video auto-restarts HOT 1
- [BUG]: Video's not playing (black screen) specifically on iOS 17.0.2 HOT 3
- [BUG]: requireNativeComponent: "RCTVideo" was not found in the UIManager HOT 3
- [BUG]:v6 beta donβt load mp4 HOT 3
- [BUG]: v6 don't load Internet source mp4 style file,but local source mp4 and other file style can be loaded HOT 2
- Offline DRM support
- [BUG]: How do i import react native video in swift file (iOS native side) HOT 6
- [BUG]: multi audio selection HOT 2
- [BUG]: In iOS, seek is working perfect in portrait mode but when i rotate my device in landscape then on seek i am getting JSON value '0' of type NSNumber cannot be converted to NSDictionary HOT 7
- [Feature]: Privacy Manifest for Promises SDK HOT 3
- [BUG]: shutterColor not typed in Typescript HOT 3
- [BUG]: AVFoundationErrorDomain on iOS when playing .mp3 file HOT 4
- The screen turns off in fullscreen mode HOT 6
- [BUG]: codepush + RNV6, TypeError: Cannot read property 'ScaleAspectFill' of undefined HOT 3
- [Feature]: Improve error typing and management for entire react-native-video package HOT 2
- [BUG]: React Native Video Player Crashes on iOS and Apple TV with Invalid URL HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from react-native-video.