diff --git a/ios/Video/RCTVideo.m b/ios/Video/RCTVideo.m index fe319992bd..d1471aee8d 100644 --- a/ios/Video/RCTVideo.m +++ b/ios/Video/RCTVideo.m @@ -703,9 +703,15 @@ - (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(N if (!CGRectEqualToRect(oldRect, newRect)) { if (CGRectEqualToRect(newRect, [UIScreen mainScreen].bounds)) { - NSLog(@"in fullscreen"); - if (!_fullscreenPlayerPresented && _controls) { - _fullscreenPlayerPresented = YES; + bool shouldFire = !_fullscreenPlayerPresented; + + dispatch_async(dispatch_get_main_queue(), ^{ + if (shouldFire) { + _fullscreenPlayerPresented = YES; + } + }); + + if (shouldFire) { if(self.onVideoFullscreenPlayerWillPresent) { self.onVideoFullscreenPlayerWillPresent(@{@"target": self.reactTag}); } @@ -714,9 +720,15 @@ - (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(N } } } else { - NSLog(@"not fullscreen"); - if (_fullscreenPlayerPresented && _controls) { - _fullscreenPlayerPresented = NO; + bool shouldFire = _fullscreenPlayerPresented; + + dispatch_async(dispatch_get_main_queue(), ^{ + if (shouldFire) { + _fullscreenPlayerPresented = NO; + } + }); + + if (shouldFire) { if(self.onVideoFullscreenPlayerWillDismiss) { self.onVideoFullscreenPlayerWillDismiss(@{@"target": self.reactTag}); }