我uisng这个代码显示短片:
MPMoviePlayerViewController *mp = [[MPMoviePlayerViewController alloc]
initWithContentURL:movieURL];
mp.moviePlayer.movieSourceType = MPMovieSourceTypeUnknown;
[self presentMoviePlayerViewControllerAnimated:mp]; [mp.moviePlayer play];
该代码是工作的罚款。 然而,当应用程序转到后台,同时播放电影,当应用程序回来在不显示movieplayer前景。 (I看到称为控制器的视图presentMoviePlayerViewControllerAnimated:mp
进入foregound恢复正在播放之前的应用程序去后台电影时是否有可能?
有你的UIBackgroundmode设置为音频,也出现了问题,播放视频的应用程序后进入前台.Refer这对MPMoviePlayerViewController教程 ,你也可以尝试使用MPMoviePlayerViewController这对于实现各种通知选项。
你可以实现的通知技术来处理它。 在电影播放器播放和与之相关联的选择器类添加一个通知。 当应用程序被切换到后台然后在委托方法
- (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];
}];
}
当应用程序进入后台它将暂停的MPMoviePlayerController所以当它来到前台您发布,其中电影控制器来实现其调用类中的方法,在这种方法中再次播放通知写这篇code.Actually。
-(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];
}
它解决了我的问题。
文章来源: How to resume a movie that's being played with presentMoviePlayerViewControllerAnimated