2011-10-05 152 views
3

我发现了一个功能使用工具箱播放声音,creds打算给谁就给谁创造了它:在iPad上播放声音,使用AudioToolbox

-(SystemSoundID) createSoundID: (NSString*)name { 
    NSString *path = [NSString stringWithFormat: @"%@/%@", 
      [[NSBundle mainBundle] resourcePath], name]; 

    NSURL* filePath = [NSURL fileURLWithPath: path isDirectory: NO]; 
    SystemSoundID soundID; 
    AudioServicesCreateSystemSoundID((CFURLRef)filePath, &soundID); 
    NSLog(@"%@, %@", path, filePath); 
    return soundID; 
} 

然而,一旦我想要的声音播放和我使用的功能

mySound = [self createSoundID: @"canopen.wav"]; 

AudioServicesPlaySystemSound(mySound); 

它只在模拟器中播放,而不是一旦我将它移动到iPad。请帮忙

+1

难道你的iPad是静音的吗? – Phlibbo

+0

Dupe?你的声音太长了吗? http://stackoverflow.com/questions/2014578/sound-on-simulator-but-not-device –

+0

是的!哈哈声音已打开,但侧面的按钮已关闭! xD谢谢! – user981320

回答

0

前段时间我也发生过同样的事情。检查你的iPad是否静音:)