Iphone 在ios6中播放视频
应用程序启动时,视频将自动运行 但按下home(主页)按钮并再次打开,应用程序冻结,不知道原因 我能做什么Iphone 在ios6中播放视频,iphone,ios,xcode,ipad,mpmovieplayercontroller,Iphone,Ios,Xcode,Ipad,Mpmovieplayercontroller,应用程序启动时,视频将自动运行 但按下home(主页)按钮并再次打开,应用程序冻结,不知道原因 我能做什么 - (void)viewDidLoad{ m_player = [[MPMoviePlayerController alloc] initWithContentURL:url]; [m_player.backgroundView setBackgroundColor:[UIColor blackColor]]; [m_player.
- (void)viewDidLoad{
m_player = [[MPMoviePlayerController alloc] initWithContentURL:url];
[m_player.backgroundView setBackgroundColor:[UIColor blackColor]];
[m_player.view setBackgroundColor:[UIColor blackColor]];
[m_player setControlStyle:MPMovieControlStyleNone];
[[m_player view] setFrame:[self.view bounds]];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(moviePlayBackDidFinish:) name:MPMoviePlayerPlaybackDidFinishNotification object:nil];
[m_player play];
[self.view addSubview:[m_player view]];
}
- (void) moviePlayBackDidFinish:(NSNotification*)_notification
{
[[NSNotificationCenter defaultCenter] removeObserver:self
name:MPMoviePlayerPlaybackDidFinishNotification
object:nil];
[m_player.view removeFromSuperview];
[m_player stop];
m_player = nil;
}
}
这段代码帮助我避免在按下home(主页)按钮时冻结应用程序,视频正在播放并正常工作强>
[[NSNotificationCenter defaultCenter] addObserver: self
selector: @selector(handleEnteredBackground:)
name: UIApplicationDidEnterBackgroundNotification
object: nil];
-(void)handleEnteredBackground:(NSNotification*)_notification{
[m_player play];
}
那么,应用程序完全冻结了,还是只是视频冻结了?请检查crashlog,或者您是否连接到xcode、控制台和共享。可能这就说明了原因。应用程序和视频冻结并显示[MPAVController]自动播放:跳过自动播放,没有足够的缓冲来跟上。