Commit f73b7a04 authored by Alexander Nazarov's avatar Alexander Nazarov Committed by Matt Apperson
Browse files

Fixed seekableDuration for time ranges with non-numeric duration (#709) (#728)

parent 4bf2b2c4
Loading
Loading
Loading
Loading
+11 −1
Changes for ios/RCTVideo.m: 11 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -195,7 +195,7 @@ static NSString *const timedMetadata = @"timedMetadata";
                             @"atValue": [NSNumber numberWithLongLong:currentTime.value],
                             @"atTimescale": [NSNumber numberWithInt:currentTime.timescale],
                             @"target": self.reactTag,
                             @"seekableDuration": [NSNumber numberWithFloat:CMTimeGetSeconds([self playerItemSeekableTimeRange].duration)],
                             @"seekableDuration": [self calculateSeekableDuration],
                            });
   }
}
@@ -225,6 +225,16 @@ static NSString *const timedMetadata = @"timedMetadata";
  return [NSNumber numberWithInteger:0];
}

- (NSNumber *)calculateSeekableDuration
{
    CMTimeRange timeRange = [self playerItemSeekableTimeRange];
    if (CMTIME_IS_NUMERIC(timeRange.duration))
    {
        return [NSNumber numberWithFloat:CMTimeGetSeconds(timeRange.duration)];
    }
    return [NSNumber numberWithInteger:0];
}

- (void)addPlayerItemObservers
{
  [_playerItem addObserver:self forKeyPath:statusKeyPath options:0 context:nil];