开发者

Playing sound on iPad, using AudioToolbox

开发者 https://www.devze.com 2023-04-11 05:49 出处:网络
I found a function to play sounds using toolbox, creds going to whomever created it: -(SystemSoundID) createSo开发者_高级运维undID: (NSString*)name {

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

精彩评论

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