首页 文章

系统声音在扬声器上播放非常安静 - C,Objective-C

提问于
浏览
1

我在Objective-C中使用AudioServicesPlaySystemSound来播放我的音效 . 它们在模拟器和我的iPad扬声器上播放得非常响亮,但当我将iPad上的音频线插入扬声器时,声音非常低,几乎听不见 . 我尝试了不同的扬声器并获得了同样的效果 . 通过蓝牙,声音仍然安静,但至少听得见 . 这是我的代码:

- (IBAction)playSound:(UIButton *)sender
{
    NSString *path = [NSString stringWithFormat: @"%@/%@", [[NSBundle mainBundle] resourcePath], @"MySoundEffect.caf"];
    NSURL *filePath = [NSURL fileURLWithPath: path isDirectory: NO];
    NSLog(@"filepath = %@", filePath);

    SystemSoundID soundID;
    AudioServicesCreateSystemSoundID((__bridge CFURLRef)filePath, &soundID);

    AudioServicesPlaySystemSound(soundID);
}

1 回答

  • 0

    这似乎是简单地使用AudioServicesPlaySystemSound的问题 . 我的解决方法是使用SimpleAudioEngine,它在幕后做了一些工作,我认为即使在蓝牙或线路上播放时,音频音量和质量也保持不变 .

相关问题