AVPlayerItem无法与播放多个视频的多个AVPlayer实例关联

时间:2016-06-23 23:50:09

标签: ios xcode avplayer avplayerviewcontroller

因此,我搜索了有关此错误的所有帖子,但没有任何效果。会发生什么是第一次打开以下视图控制器时,一切正常。但是,当我关闭控制器并尝试再次播放视频时,我收到此错误。不知道为什么。

  NSMutableArray *AVPlayerItems;

 AVQueuePlayer *player ;

  NSURL *url = [NSURL fileURLWithPath:filePath];

  AVPlayerItem *firstItem = [AVPlayerItem playerItemWithURL: url3];



       [AVPlaterItems addObject:firstItem];



        player = [AVQueuePlayer queuePlayerWithItems:AVPlayerItems];


            playerController = [AVPlayerViewController new];
            playerController.delegate = self;
            [self.viewPlayer addSubview:playerController.view];
            playerController.view.frame = self.viewPlayer.frame;

            playerController.showsPlaybackControls = NO;


            playerController.player = player;
            [playerController.player play];
        playerController.player.muted = YES;



        [self.presentingViewController dismissViewControllerAnimated:YES completion:nil];

1 个答案:

答案 0 :(得分:2)

if(avPlayer==nil)
{

    avPlayer = [AVPlayer playerWithPlayerItem:_avPlayerItem];
}else{
    [avPlayer replaceCurrentItemWithPlayerItem:_avPlayerItem];

}

这将解决此类问题