每当我停止播放视频时,请拨打[video.moviePlayer setInitialPlaybackTime:0]; [video.moviePlayer prepareToPlay];
我会在播放视频之前获得最后一帧的重影。知道如何防止这种情况发生吗?
- (void)prepareVideo {
video = [[MPMoviePlayerViewController alloc] initWithContentURL:[NSURL URLWithString:kVideoURL]];
[video.moviePlayer setControlStyle:MPMovieControlStyleFullscreen];
[video.moviePlayer setScalingMode:MPMovieScalingModeAspectFit];
[video.moviePlayer stop];
[videoFrame addSubview:video.view];
[video.view setFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(playbackFinished:)
name:MPMoviePlayerPlaybackDidFinishNotification
object:video.moviePlayer];
}
- (void)playVideo {
[video.moviePlayer stop];
[video.moviePlayer setInitialPlaybackTime:0];
[video.moviePlayer prepareToPlay];
[video.moviePlayer play];
[self showVideo];
}
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
UITouch *touch = [touches anyObject];
if (touch.view.tag == 101) {
[self playVideo];
}
}