Commit ce7f82b8 authored by Gaël Gillard's avatar Gaël Gillard Committed by Brent Vatne
Browse files

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
parent 2b5fc21c
Loading
Loading
Loading
Loading
+1 −1
Changes for RCTVideo.m: 1 added line, 1 removed line.
Original line number Diff line number Diff line
@@ -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],