From 9900a9c51d84e10f40aeae2512812f94d9d1b64b Mon Sep 17 00:00:00 2001 From: Johannes Lumpe Date: Mon, 11 May 2015 09:54:58 +0300 Subject: [PATCH] Fixed invalid usage of JS-like OR --- RCTVideo.m | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/RCTVideo.m b/RCTVideo.m index 018aef0c65..c57779870a 100644 --- a/RCTVideo.m +++ b/RCTVideo.m @@ -135,8 +135,14 @@ - (AVPlayerItem*)playerItemForSource:(NSDictionary *)source { - (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context { if (object == _playerItem) { if (_playerItem.status == AVPlayerItemStatusReadyToPlay) { + 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],