AVAudioPlayer在同时播放时使系统声音更响亮

时间:2016-06-22 12:42:55

标签: objective-c avaudioplayer

我之前已经问过这个问题,甚至设定了赏金,但仍然没有答案。请有人帮帮我!! System sound becomes louder when AVAudioPlayer is initiated

我使用SystemSound播放按钮点击声音等声音效果,使用AVAudioPlayer播放背景音乐。当AVAudioPlayer在播放SystemSound时启动时,该特定系统声音突然变得大5倍。还有其他人经历过吗?可能有什么问题?

这些是在SoundControl.m中,我在转换后立即玩gameBG。

-(void)gameBG {

self.sharedSoundControl = [SoundControl sharedSoundControl];
if (self.sharedSoundControl.musicOff == NO) {
    self.audioPlayer = [[AVAudioPlayer alloc] initWithContentsOfURL:[[NSBundle mainBundle] URLForResource:@"bgm" withExtension:@"mp3"] error:nil];
    self.audioPlayer.numberOfLoops = -1;
    self.audioPlayer.volume = 0.3f;
        [self.audioPlayer play];
}}

-(void)transition {

if (self.sharedSoundControl.effectOff == NO) {

NSString *soundPath = [[NSBundle mainBundle] pathForResource:@"transition" ofType:@"caf"];
SystemSoundID soundID;
AudioServicesCreateSystemSoundID((__bridge CFURLRef)[NSURL fileURLWithPath:soundPath], &soundID);
AudioServicesPlaySystemSound(soundID);
}}

0 个答案:

没有答案