System Sound plays very quietly over speakers

I'm using AudioServicesPlaySystemSound in Objective-C to play my sound effects. They play perfectly loud on simulator and on my iPad's speakers, but when I plug an audio cord from my iPad into a speaker, the sound is ridiculously low, barely audible. I've tried different speakers and got the same effect. Over bluetooth the sound is still quiet but at least audible. Here's my code:

- (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);
}

This appears to be a problem with simply using AudioServicesPlaySystemSound. My workaround was to use SimpleAudioEngine which does some work behind the scenes that I assume keep the audio volume and quality intact even when playing over bluetooth or line in.

链接地址: http://www.djcxy.com/p/67936.html

上一篇: 在iOS上播放和停止声音样本(Novocaine)

下一篇: 系统声音通过扬声器非常安静地播放