2012-05-12 31 views
2

我uisng这个代码显示短片电影:如何恢复所播放与presentMoviePlayerViewControllerAnimated

MPMoviePlayerViewController *mp = [[MPMoviePlayerViewController alloc] 
initWithContentURL:movieURL]; 
mp.moviePlayer.movieSourceType = MPMovieSourceTypeUnknown; 
[self presentMoviePlayerViewControllerAnimated:mp]; [mp.moviePlayer play]; 

的代码是工作的罚款。但是,当应用程序在播放电影时转到背景时,应用程序返回到前台时,不会显示电影播放器​​。 (我看到进入foregound恢复正在播放之前应用到了后台电影时称为presentMoviePlayerViewControllerAnimated:mp

是否有可能在控制器的看法?

+0

仍然我没有得到解决方案。你如何解决你的问题? – Myaaoonn

回答

0

有你的UIBackgroundmode设置为音频和也一直存在的问题与播放视频应用进入前台.Refer在此之后Tutorial on MPMoviePlayerViewController,你也可以尝试使用MPMoviePlayerViewController这对于实现各种通知选项。

0

可以实现通知技术来处理它。添加一个通知,并在所在班级电影播放器​​正在播放并与它关联一个选择器以再委托方法

- (void)applicationDidEnterBackground:(UIApplication *)application 

{ 

// Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. 

// If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 


    UIApplication *app = [UIApplication sharedApplication]; 
    UIBackgroundTaskIdentifier bgTask = 0; 

    bgTask = [app beginBackgroundTaskWithExpirationHandler:^{ 
     [app endBackgroundTask:bgTask]; 
    }]; 

} 

写这个code.Actually背景当应用程序进入后台它将暂停的MPMoviePlayerController所以当它来到前台您发布该调用其中电影控制器实现在类中的方法通知和用这种方法再玩一次。

-(void)playIntroAnimationAgain 

{ 

[[NSNotificationCenter defaultCenter]removeObserver:self name:NOTIFICATION_PlayAgain_Player object:nil]; 

     [self.moviePlayerController play]; 

     [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(playIntroAnimationAgain)name:NOTIFICATION_PlayAgain_Player object:nil]; 
} 

它解决了我的问题。

相关问题