From ce7f82b8840076ec67e301bc3a7c2b45799bcfa7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=ABl=20Gillard?= Date: Tue, 28 Apr 2015 12:00:38 +0200 Subject: [PATCH] Provide a fallback if the duration cannot be get This to avoid to send an errors stack caused by the `NaN` given in the JSON of the RCTEventDispatcher. fixes #26 --- RCTVideo.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/RCTVideo.m b/RCTVideo.m index 1c9f3b6e..9923e23e 100644 --- a/RCTVideo.m +++ b/RCTVideo.m @@ -145,7 +145,7 @@ static NSString *const statusKeyPath = @"status"; if (_playerItem.status == AVPlayerItemStatusReadyToPlay) { // NSLog(@"duration: %f",CMTimeGetSeconds(_playerItem.asset.duration)); [_eventDispatcher sendInputEventWithName:RNVideoEventLoaded body:@{ - @"duration": [NSNumber numberWithFloat:CMTimeGetSeconds(_playerItem.duration)], + @"duration": [NSNumber numberWithFloat:(CMTimeGetSeconds(_playerItem.duration) || 0.0)], @"currentTime": [NSNumber numberWithFloat:CMTimeGetSeconds(_playerItem.currentTime)], @"canPlayReverse": [NSNumber numberWithBool:_playerItem.canPlayReverse], @"canPlayFastForward": [NSNumber numberWithBool:_playerItem.canPlayFastForward],