0

I'm trying to play two sounds, one right after the other using AVQueuePlayer but neither is getting played. I can play them individually using AVAudioPlayer.

Here is my queue player code:

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];
raginggoat
  • 3,570
  • 10
  • 48
  • 108

1 Answers1

0

I fixed it by creating a queuePlayer property and initializing it like this:

queuePlayer = [[AVQueuePlayer alloc]initWithItems:playerItems];
raginggoat
  • 3,570
  • 10
  • 48
  • 108