我想以不同的速度在 MPMoviePlayerController 中播放/转发视频。任何人都可以建议我如何做到这一点。
现在我正在快进(单速),但几秒钟后它又恢复正常速度。
请建议。
我想以不同的速度在 MPMoviePlayerController 中播放/转发视频。任何人都可以建议我如何做到这一点。
现在我正在快进(单速),但几秒钟后它又恢复正常速度。
请建议。
MPMoviePlayerController Conforms to MPMediaPlayback protocol
you can see the property currentPlaybackRate as :-
@property(nonatomic) float currentPlaybackRate
A value of 0 represents that the video is stopped , a value of 1 indicates normal speed and further positive values indicate increased speed while negative ones indicate reverse .
还要检查你的 MPMediaPlayback 的 endseeing 委托方法,因为它是恢复正常播放的唯一方法
这是 MPMoviePlayerViewController 以 2x 3x 4x 速度前进和后退电影的代码
在 .h 文件中
@property(nonatomic) float currentPlaybackRate;
在 .m 文件中
- (void)viewDidLoad
{
currentPlaybackRate=1.0; //video Play in Normal speed
}
现在在 FastForward 和 FastBackward 按钮操作
[fastForward addTarget:self action:@selector(fastForward) forControlEvents:UIControlEventTouchUpInside];
[fastBackWard addTarget:self action:@selector(fastBackward) forControlEvents:UIControlEventTouchUpInside];
动作代码
-(void)fastForward
{
[mp.moviePlayer pause];
playPauseButton.selected=TRUE;
if (currentPlaybackRate < 0.0) {
currentPlaybackRate = 1.0;
}
if (currentPlaybackRate < 4.0) {
currentPlaybackRate=currentPlaybackRate+1.0;
NSLog(@"Forward::%f",currentPlaybackRate);
mp.moviePlayer.currentPlaybackRate=currentPlaybackRate;
}
}
-(void)fastBackward
{
[mp.moviePlayer pause];
playPauseButton.selected=TRUE;
if (currentPlaybackRate > 0.0) {
currentPlaybackRate = 0.0;
}
if (currentPlaybackRate > -4.0) {
currentPlaybackRate=currentPlaybackRate-1.0;
NSLog(@"BackWard::%f",currentPlaybackRate);
mp.moviePlayer.currentPlaybackRate=currentPlaybackRate;
}
}