0

我正在尝试播放两种声音,一个接一个地使用 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];
4

1 回答 1

0

我通过创建 queuePlayer 属性并像这样初始化它来修复它:

queuePlayer = [[AVQueuePlayer alloc]initWithItems:playerItems];
于 2014-02-25T19:57:04.460 回答