gpt4 book ai didi

ios - 使用AVQueuePlayer时无声音

转载 作者:行者123 更新时间:2023-12-03 02:13:36 26 4
gpt4 key购买 nike

我正在尝试播放两种声音,一种使用AVQueuePlayer,一种紧接在另一种,但是没有一种被播放。我可以使用AVAudioPlayer单独播放它们。

这是我的队列播放器代码:

NSURL *hitURL = [NSURL fileURLWithPath:[NSString stringWithFormat:@"%@/sfx_hit.wav", [[NSBundle mainBundle]resourcePath]]];
NSURL *dieURL = [NSURL fileURLWithPath:[NSString stringWithFormat:@"%@/sfx_die.wav", [[NSBundle mainBundle]resourcePath]]];

AVPlayerItem *hit = [AVPlayerItem playerItemWithURL:hitURL];
AVPlayerItem *die = [AVPlayerItem playerItemWithURL:dieURL];

NSArray *playerItems = [NSArray arrayWithObjects:hit, die, nil];

AVQueuePlayer *queuePlayer = [AVQueuePlayer queuePlayerWithItems:playerItems];
[queuePlayer play];

最佳答案

我通过创建queuePlayer属性并初始化如下来修复它:

queuePlayer = [[AVQueuePlayer alloc]initWithItems:playerItems];

关于ios - 使用AVQueuePlayer时无声音,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22024373/

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