I created a UISwitch. And wants it to control sound. But not work.
@interface SoundViewController ()
{
AVPlayer *_audioPlayer;
}
@end
@implementation SoundViewController
-(IBAction)soundSwitch:(id)sender{
if (_soundSwitch.on) {
CFBundleRef mainBundle = CFBundleGetMainBundle();
CFURLRef soundFileURLRef;
soundFileURLRef = CFBundleCopyResourceURL(mainBundle, (CFStringRef) @"soundN ame), NULL);
UInt32 soundID;
AudioServicesCreateSystemSoundID(soundFileURLRef, &soundID);
AudioServicesPlaySystemSound(soundID);
}else
{
/
}
}
No sound is playing. Please help. Thanks