MPMoviePlayerController 在调用停止播放时显示最后一帧的重影

发布于 2024-11-14 20:39:05 字数 1308 浏览 7 评论 0原文

每当我停止视频时,请调用 [video.movi​​ePlayer setInitialPlaybackTime:0]; [video.movi​​ePlayerprepareToPlay]; 我在视频播放前得到了最后一帧的重影图像。知道如何防止这种情况发生吗?

- (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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文