Made seek
a float value again, now triggered through this.refs.myVideoNode.seek(time)
This commit is contained in:
parent
45d79b701e
commit
380c1d46cc
18
RCTVideo.m
18
RCTVideo.m
@ -189,19 +189,8 @@ static NSString *const statusKeyPath = @"status";
|
||||
}
|
||||
}
|
||||
|
||||
- (void)setSeek:(NSDictionary*)seek {
|
||||
NSNumber *seekValue = [seek objectForKey:@"time"];
|
||||
if (!seekValue) {
|
||||
return;
|
||||
}
|
||||
|
||||
- (void)setSeek:(float)seekTime {
|
||||
int timeScale = 10000;
|
||||
float seekTime = [RCTConvert float:seekValue];
|
||||
bool force = [RCTConvert BOOL:[seek objectForKey:@"force"]];
|
||||
|
||||
if (seekTime == _lastSeekTime && !force) {
|
||||
return;
|
||||
}
|
||||
|
||||
AVPlayerItem *item = _player.currentItem;
|
||||
if (item && item.status == AVPlayerItemStatusReadyToPlay) {
|
||||
@ -211,14 +200,13 @@ static NSString *const statusKeyPath = @"status";
|
||||
CMTime current = item.currentTime;
|
||||
// TODO figure out a good tolerance level
|
||||
CMTime tolerance = CMTimeMake(1000, timeScale);
|
||||
|
||||
|
||||
if (CMTimeCompare(current, cmSeekTime) != 0) {
|
||||
[_player seekToTime:cmSeekTime toleranceBefore:tolerance toleranceAfter:tolerance];
|
||||
_pendingSeek = false;
|
||||
_lastSeekTime = seekTime;
|
||||
[_eventDispatcher sendInputEventWithName:RNVideoEventSeek body:@{
|
||||
@"currentTime": [NSNumber numberWithFloat:CMTimeGetSeconds(item.currentTime)],
|
||||
@"seekTime": seekValue,
|
||||
@"seekTime": [NSNumber numberWithFloat:seekTime],
|
||||
@"target": self.reactTag
|
||||
}];
|
||||
}
|
||||
|
@ -42,7 +42,7 @@ RCT_EXPORT_VIEW_PROPERTY(paused, BOOL);
|
||||
RCT_EXPORT_VIEW_PROPERTY(muted, BOOL);
|
||||
RCT_EXPORT_VIEW_PROPERTY(volume, float);
|
||||
RCT_EXPORT_VIEW_PROPERTY(rate, float);
|
||||
RCT_EXPORT_VIEW_PROPERTY(seek, NSDictionary);
|
||||
RCT_EXPORT_VIEW_PROPERTY(seek, float);
|
||||
|
||||
- (NSDictionary *)constantsToExport
|
||||
{
|
||||
|
13
Video.ios.js
13
Video.ios.js
@ -21,7 +21,6 @@ var Video = React.createClass({
|
||||
resizeMode: PropTypes.string,
|
||||
repeat: PropTypes.bool,
|
||||
paused: PropTypes.bool,
|
||||
seek: PropTypes.number,
|
||||
muted: PropTypes.bool,
|
||||
volume: PropTypes.number,
|
||||
rate: PropTypes.number,
|
||||
@ -58,6 +57,10 @@ var Video = React.createClass({
|
||||
this.props.onSeek && this.props.onSeek(event.nativeEvent);
|
||||
},
|
||||
|
||||
seek(time) {
|
||||
this.refs.video.setNativeProps({seek: parseFloat(time)});
|
||||
},
|
||||
|
||||
render() {
|
||||
var style = flattenStyle([styles.base, this.props.style]);
|
||||
var source = this.props.source;
|
||||
@ -76,10 +79,6 @@ var Video = React.createClass({
|
||||
}
|
||||
|
||||
var nativeProps = merge(this.props, {
|
||||
seek: {
|
||||
time: this.props.seek,
|
||||
force: this.props.forceSeek
|
||||
},
|
||||
style,
|
||||
resizeMode: resizeMode,
|
||||
src: {
|
||||
@ -92,14 +91,14 @@ var Video = React.createClass({
|
||||
onProgress: this._onProgress,
|
||||
});
|
||||
|
||||
return <RCTVideo {... nativeProps} />
|
||||
return <RCTVideo ref="video" {... nativeProps} />
|
||||
},
|
||||
});
|
||||
|
||||
var RCTVideo = createReactIOSNativeComponentClass({
|
||||
validAttributes: merge(ReactIOSViewAttributes.UIView,
|
||||
{src: {diff: deepDiffer}, resizeMode: true, repeat: true,
|
||||
seek: {diff: () => true}, paused: true, muted: true, volume: true, rate: true}),
|
||||
seek: true, paused: true, muted: true, volume: true, rate: true}),
|
||||
uiViewClassName: 'RCTVideo',
|
||||
});
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user