开发者

Playing sound on iPad, using AudioToolbox

I found a function to play sounds using toolbox, creds going to whomever created it:

-(SystemSoundID) createSo开发者_高级运维undID: (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;
}

However once I want the sound the play and I use the function

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

AudioServicesPlaySystemSound(mySound);

It only plays in the simulator and not once I move it over to the iPad. Please help


The same thing happened to me a while ago. Check whether your iPad is muted :)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜