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
This commit is contained in:
parent
2b5fc21caf
commit
ce7f82b884
@ -145,7 +145,7 @@ static NSString *const statusKeyPath = @"status";
|
|||||||
if (_playerItem.status == AVPlayerItemStatusReadyToPlay) {
|
if (_playerItem.status == AVPlayerItemStatusReadyToPlay) {
|
||||||
// NSLog(@"duration: %f",CMTimeGetSeconds(_playerItem.asset.duration));
|
// NSLog(@"duration: %f",CMTimeGetSeconds(_playerItem.asset.duration));
|
||||||
[_eventDispatcher sendInputEventWithName:RNVideoEventLoaded body:@{
|
[_eventDispatcher sendInputEventWithName:RNVideoEventLoaded body:@{
|
||||||
@"duration": [NSNumber numberWithFloat:CMTimeGetSeconds(_playerItem.duration)],
|
@"duration": [NSNumber numberWithFloat:(CMTimeGetSeconds(_playerItem.duration) || 0.0)],
|
||||||
@"currentTime": [NSNumber numberWithFloat:CMTimeGetSeconds(_playerItem.currentTime)],
|
@"currentTime": [NSNumber numberWithFloat:CMTimeGetSeconds(_playerItem.currentTime)],
|
||||||
@"canPlayReverse": [NSNumber numberWithBool:_playerItem.canPlayReverse],
|
@"canPlayReverse": [NSNumber numberWithBool:_playerItem.canPlayReverse],
|
||||||
@"canPlayFastForward": [NSNumber numberWithBool:_playerItem.canPlayFastForward],
|
@"canPlayFastForward": [NSNumber numberWithBool:_playerItem.canPlayFastForward],
|
||||||
|
Loading…
Reference in New Issue
Block a user