gpt4 book ai didi

ios - 一个 AVPlayerItem 无法与多个 AVPlayer 实例关联,播放多个视频时出错

转载 作者:行者123 更新时间:2023-12-01 18:44:07 27 4
gpt4 key购买 nike

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

  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];

最佳答案

if(avPlayer==nil)
{

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

}

这将解决此类问题

关于ios - 一个 AVPlayerItem 无法与多个 AVPlayer 实例关联,播放多个视频时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38003633/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com