MPMoviePlayerController 在调用停止播放时显示最后一帧的重影
每当我停止视频时,请调用 [video.moviePlayer setInitialPlaybackTime:0]; [video.moviePlayerprepareToPlay];
我在视频播放前得到了最后一帧的重影图像。知道如何防止这种情况发生吗?
- (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];
}
}
Whenever I stop the video, then call [video.moviePlayer setInitialPlaybackTime:0]; [video.moviePlayer prepareToPlay];
I get a ghost image of the last frame before the video plays. Any idea how to prevent this from occurring?
- (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];
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论