0

我正在使用该课程在我的游戏中播放音效SystemSoundID,但结果有些奇怪。我的一些声音,包括landed1下面的声音,会根据音量按钮改变音量,但其他声音,比如deathsound总是以最大音量播放。以下是与这两种声音相关的所有代码。

SystemSoundID deathsound;

SystemSoundID landed1;

...

NSURL *soundURL;

soundURL = [[NSBundle mainBundle] URLForResource:@"SMPKLanded1" withExtension:@"mp3"];
    AudioServicesCreateSystemSoundID ((__bridge CFURLRef) soundURL, &landed1);

soundURL = [[NSBundle mainBundle] URLForResource:@"SMPKDeathSound" withExtension:@"mp3"];
    AudioServicesCreateSystemSoundID ((__bridge CFURLRef) soundURL, &deathsound);

...

AudioServicesPlaySystemSound(landed1);

...

AudioServicesPlaySystemSound(deathsound);

如果代码和文件类型基本相同,为什么两者的行为会如此不同?这没有道理!

4

1 回答 1

0

Well, I finally figured it out, after inordinate amounts of time driving myself crazy. Some of them are being played at the same time as an AVAudioPlayer, which for some reason made them conform to the volume buttons, and some weren't. My obvious next step would be to make a silent AVAudioPlayer, which I have now done, and the program works as I would expect.

As a follow up question, does anybody have any clue why having an AVAudioPlayer affects SystemSoundIDs?

于 2013-05-21T02:09:29.497 回答