Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/iphone/39.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Iphone 在ios6中播放视频_Iphone_Ios_Xcode_Ipad_Mpmovieplayercontroller - Fatal编程技术网

Iphone 在ios6中播放视频

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.

应用程序启动时,视频将自动运行

但按下home(主页)按钮并再次打开,应用程序冻结,不知道原因

我能做什么

- (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]自动播放:跳过自动播放,没有足够的缓冲来跟上。