我似乎无法使用AVQueuePlayer
. 应用程序编译并运行良好,但是当调用 `imageTouched' 方法时我没有收到任何音频。任何人都可以帮忙吗?
-(void) imageTouched
{
NSString * path1 = [[NSBundle mainBundle] pathForResource:@"sound1" ofType:@"wav"];
NSString * path2 = [[NSBundle mainBundle] pathForResource:@"sound2" ofType:@"wav"];
NSURL *url1 = [NSURL fileURLWithPath:path1];
NSURL *url2 = [NSURL fileURLWithPath:path2];
AVPlayerItem *firstSound = [AVPlayerItem playerItemWithURL:url1];
AVPlayerItem *secondSound = [AVPlayerItem playerItemWithURL:url2];
NSArray *sounds = [NSArray arrayWithObjects:firstSound, secondSound, nil];
AVQueuePlayer *player = [AVQueuePlayer queuePlayerWithItems:sounds];
[player play];
NSLog(@"%d",player.status);
}
编辑 1:我检查了文件名(大小写、拼写等)是否有任何问题,但似乎没有。我已经能够使用以下代码播放声音,但我真的需要开始AVQueuePlayer
工作。请帮忙!
NSString *path;
SystemSoundID soundId;
path = [[NSBundle mainBundle] pathForResource:@"sound1" ofType:@"wav"];
NSURL *url = [NSURL fileURLWithPath:path];
AudioServicesCreateSystemSoundID( (CFURLRef)objc_unretainedPointer( url), &soundId);
AudioServicesPlaySystemSound(soundId);