进行播放时,MPMoviePlayerController setCurrentPlaybackTime变为零

时间:2015-07-01 19:25:24

标签: objective-c playback mpmovieplayer playsound

[playerView setCurrentPlaybackTime:5.100000];

LOG -> playerView.currentPlaybackTime = @"5.100000"
[playerView play];
LOG -> playerView.currentPlaybackTime = @"0"

在其他情况下会发生这种情况

LOG -> playerView.currentPlaybackTime = @"25.000000"
[playerView play];
LOG -> playerView.currentPlaybackTime = @"23.156467"

我在播放前尝试使用[playerView prepareToPlay],但它不起作用

2 个答案:

答案 0 :(得分:0)

如果您想从某个值开始播放,则需要将initialPlaybackTime实例上的MPMoviePlayerController属性设置为您希望播放的值。

答案 1 :(得分:0)

我最终决定切换到AVPlayer

setCurrentPlayback是

int32_t timeScale = playerView.currentItem.asset.duration.timescale;
CMTime time = CMTimeMakeWithSeconds(value, timeScale);
[playerView seekToTime:time toleranceBefore:kCMTimeZero toleranceAfter:kCMTimeZero];

持续时间

CMTime duration = playerView.currentItem.asset.duration;
float seconds = CMTimeGetSeconds(duration);

相同的暂停和播放功能。