EIDTED代码:
-(voID)vIEwDIDLoad { [self movIEPlayer2]; } - (voID) movIEPlayer2 { Nsstring *path = [[NSBundle mainBundle] pathForResource:@"cloud" ofType:@"mp4"]; player = [[MPMovIEPlayerVIEwController alloc] initWithContentURL:[NSURL fileURLWithPath:path]]; player.vIEw.userInteractionEnabled = YES; player.movIEPlayer.repeatMode = YES; player.movIEPlayer.scalingMode = MPMovIEScalingModeFill; player.movIEPlayer.controlStyle = MPMovIEControlStyleNone; [[NSNotificationCenter defaultCenter] addobserver:self selector:@selector(movIEPlayBackStateChange:) name:MPMovIEPlayerPlaybackStateDIDChangeNotification object:[player movIEPlayer]]; [[player movIEPlayer] play]; [self.vIEw addSubvIEw:player.vIEw]; }-(voID) movIEPlayBackStateChange: (NSNotification *) note { [[NSNotificationCenter defaultCenter] removeObserver:self name:MPMovIEPlayerPlaybackStateDIDChangeNotification object:[player movIEPlayer]]; [[player movIEPlayer] play]; //[player release]; NSLog(@"FINISHED");}
谢谢 .
解决方法 我想你可能需要在下面添加代码:[[NSNotificationCenter defaultCenter] addobserver:self selector:@selector(movIEPlayBackStateChange:) name:MPMovIEPlayerPlaybackStateDIDChangeNotification object:[player movIEPlayer]];
并在movIEPlayBackStateChange方法中处理电影状态.
当电影正在播放并且应用程序在后台进入时,电影将暂停,因此当应用程序从后台返回时,您需要使电影恢复如下所示.如果没有,电影将保持暂停状态.这就是你的应用变黑的原因.
[[player movIEPlayer] play];
然后电影将继续播放.
添加两个方法,当应用程序进入后台并从后台返回时,您应该调用这两个方法:
-(voID) pauseMovIEInBackGround{ [player movIEPlayer] pause]; [player.vIEw removeFromSupervIEw];}-(voID) resumeMovIEInFrontGround{ [self.vIEw addSubvIEw:player.vIEw]; [[player movIEPlayer] play];}
希望这可以帮助你.
总结以上是内存溢出为你收集整理的iphone – 进入后台时MPMoviePlayerViewController变黑全部内容,希望文章能够帮你解决iphone – 进入后台时MPMoviePlayerViewController变黑所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)