CFURLRef requires bridge error

I try to play a sound, but when I code:

AudioServicesCreateSystemSoundID ((CFURLRef) alertSound, &soundFileObject);

it produces the following error:

Entering the Objective-C type of the pointer type 'NSURL *' into the C type of the 'CFURLRef' type (aka 'const struct __CFURL *') requires a bridge error

I tried both of the following suggested solutions:

AudioServicesCreateSystemSoundID ((__bridge CFURLRef) alertSound, &soundFileObject);

or

AudioServicesCreateSystemSoundID ((CFURLRef) CFBridgingRetain(alertSound), &soundFileObject);

But I still can not reproduce the sound.

I guess the question is, is a bridge error causing an unplayable sound, or should I look elsewhere?

I can play the sound using the SysSound example code, and I use iOS 6 and Xcode 4.5.

Thanks for any pointers :)

+5
source share
1 answer

The cast may not be the reason that the sound does not play:

AudioServicesCreateSystemSoundID ((__bridge CFURLRef) alertSound, &soundFileObject);

fine.

, , . URL .

:

OSStatus status = AudioServicesCreateSystemSoundID((__bridge CFURLRef)alertSound, &soundFileObject);
NSLog(@"AudioServicesCreateSystemSoundID status = %ld", status);

, ; parmErr (-50) , URL- .

, , , . , AudioServicesCreateSystemSoundID . :

AudioServicesPlaySystemSound(soundFileObject);

, !

+9

All Articles