Ios 使用AVQueuePlayer时没有声音
我正在尝试播放两种声音,一种接着一种使用AVQueuePlayer,但两种声音都没有播放。我可以使用AVAudioPlayer单独播放它们 这是我的队列播放器代码:Ios 使用AVQueuePlayer时没有声音,ios,objective-c,audio,avqueueplayer,Ios,Objective C,Audio,Avqueueplayer,我正在尝试播放两种声音,一种接着一种使用AVQueuePlayer,但两种声音都没有播放。我可以使用AVAudioPlayer单独播放它们 这是我的队列播放器代码: NSURL *hitURL = [NSURL fileURLWithPath:[NSString stringWithFormat:@"%@/sfx_hit.wav", [[NSBundle mainBundle]resourcePath]]]; NSURL *dieURL = [NSURL fileURLWithPath:
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];