MPMoviePlayerController setCurrentPlaybackTime 在播放时变为零

MPMoviePlayerController setCurrentPlaybackTime becomes zero when doing play

[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],但它不起作用

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

我终于决定改用 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);

相同的暂停和播放功能。