diff --git a/Examples/VideoPlayer/VideoPlayer.xcodeproj/project.xcworkspace/xcuserdata/brentvatne.xcuserdatad/UserInterfaceState.xcuserstate b/Examples/VideoPlayer/VideoPlayer.xcodeproj/project.xcworkspace/xcuserdata/brentvatne.xcuserdatad/UserInterfaceState.xcuserstate index 4eed5183..7b8c98fd 100644 Binary files a/Examples/VideoPlayer/VideoPlayer.xcodeproj/project.xcworkspace/xcuserdata/brentvatne.xcuserdatad/UserInterfaceState.xcuserstate and b/Examples/VideoPlayer/VideoPlayer.xcodeproj/project.xcworkspace/xcuserdata/brentvatne.xcuserdatad/UserInterfaceState.xcuserstate differ diff --git a/RCTVideo.m b/RCTVideo.m index ad2d7b8a..be64ea4b 100644 --- a/RCTVideo.m +++ b/RCTVideo.m @@ -144,9 +144,14 @@ static NSString *const statusKeyPath = @"status"; - (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context { if (object == _playerItem) { if (_playerItem.status == AVPlayerItemStatusReadyToPlay) { - // NSLog(@"duration: %f",CMTimeGetSeconds(_playerItem.asset.duration)); + float duration = CMTimeGetSeconds(_playerItem.asset.duration); + + if (isnan(duration)) { + duration = 0.0; + } + [_eventDispatcher sendInputEventWithName:RNVideoEventLoaded body:@{ - @"duration": [NSNumber numberWithFloat:(CMTimeGetSeconds(_playerItem.duration) || 0.0)], + @"duration": [NSNumber numberWithFloat:duration], @"currentTime": [NSNumber numberWithFloat:CMTimeGetSeconds(_playerItem.currentTime)], @"canPlayReverse": [NSNumber numberWithBool:_playerItem.canPlayReverse], @"canPlayFastForward": [NSNumber numberWithBool:_playerItem.canPlayFastForward],