首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >按下完成后,无法停止MPMoviePlayerController中发生的动画

按下完成后,无法停止MPMoviePlayerController中发生的动画
EN

Stack Overflow用户
提问于 2013-05-31 23:47:25
回答 1查看 322关注 0票数 1

我正在尝试阻止当用户按下done时在MPMoviePLayerController中退出视频时发生的过渡动画。我可以使用moviePlayBackDidFinish:通知在电影结束时很好地停止它,但由于某种原因,当我用与exitedFullscreen:通知完全相同的方式尝试它时(它响应完成按下),它不工作,就像在中一样,动画发生了。

这里是完整的代码,任何帮助都将不胜感激。

代码语言:javascript
运行
复制
-(void) playvideo
{
    NSURL *url = [NSURL fileURLWithPath:[[NSBundle mainBundle]
                                         pathForResource:@"test" ofType:@"MOV"]];
    moviePlayer =  [[MPMoviePlayerController alloc]
                    initWithContentURL:url];
    self.navigationController.navigationBar.frame = CGRectMake(0, 0, self.navigationController.navigationBar.frame.size.width, self.navigationController.navigationBar.frame.size.height);

    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(moviePlayBackDidFinish:) name:MPMoviePlayerPlaybackDidFinishNotification object:moviePlayer];

    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(exitedFullscreen:) name:MPMoviePlayerDidExitFullscreenNotification object:moviePlayer];

    moviePlayer.controlStyle = MPMovieControlStyleEmbedded;
    moviePlayer.shouldAutoplay = YES;
    [self.view addSubview:moviePlayer.view];
    moviePlayer.fullscreen = YES;
}



-(void)moviePlayBackDidFinish: (NSNotification*)notification
{
    moviePlayer.fullscreen = NO;
    [moviePlayer.view removeFromSuperview];


}


- (void)exitedFullscreen:(NSNotification*)notification {

    moviePlayer.fullscreen = NO;
    [moviePlayer.view removeFromSuperview];

} 
EN

回答 1

Stack Overflow用户

发布于 2014-12-01 20:47:23

您可以使用此代码删除动画。

代码语言:javascript
运行
复制
 -(void)moviePlayBackDidFinish: (NSNotification*)notification
    {


      [moviePlayer stop];
      [moviePlayerController.view removeFromSuperview];
      moviePlayer = nil;


    }


    - (void)exitedFullscreen:(NSNotification*)notification {

        [moviePlayer stop];
        [moviePlayerController.view removeFromSuperview];
        moviePlayer = nil;

    } 
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/16861177

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档