Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/112.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/26.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/wix/2.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
Ios 在AVPlayer中播放会导致UI冻结_Ios_Objective C_Avplayer_Avplayeritem - Fatal编程技术网

Ios 在AVPlayer中播放会导致UI冻结

Ios 在AVPlayer中播放会导致UI冻结,ios,objective-c,avplayer,avplayeritem,Ios,Objective C,Avplayer,Avplayeritem,我正在做一个带有视频播放器的iOS应用程序。我必须改变我的视频网址每次用户切换它的视角。但是当我切换到一个新的URL时,我的UI会被冻结一段时间。下面是我切换视频URL函数的代码 // Create the AVPlayer using the playeritem m_pMoviePlayer = [AVPlayer playerWithURL:[NSURL URLWithString:pUrl]]; NSError *_error = nil; [[AV

我正在做一个带有视频播放器的iOS应用程序。我必须改变我的视频网址每次用户切换它的视角。但是当我切换到一个新的URL时,我的UI会被冻结一段时间。下面是我切换视频URL函数的代码

    // Create the AVPlayer using the playeritem
    m_pMoviePlayer =   [AVPlayer playerWithURL:[NSURL URLWithString:pUrl]];

    NSError *_error = nil;
    [[AVAudioSession sharedInstance] setCategory: AVAudioSessionCategoryPlayback error: &_error];

    m_pMoviePlayer.allowsExternalPlayback = NO;

    // You can play/pause using the AVPlayer object
    [m_pMoviePlayer play];

    [self registerMoviePlayerObservers];

提前感谢。

在播放下一个Url之前,请“暂停”当前Url。但是,当我第一次初始化时,我收到了一个UI冻结[self registerMoviePlayerObservers],请在[m_pMoviePlayer播放]之前调用它;你每次都需要设置音频会话类别吗?我已经试过了。但是运气不好。在播放下一个Url之前,暂停当前Url。但是当我第一次初始化时,我得到了一个UI冻结[self-registerMoviePlayerObservers],在[m_pMoviePlayer play]播放之前调用它;你每次都需要设置音频会话类别吗?我已经试过了。但是没有运气。