I am new to coding applications, and I have created a simple app that plays a sound. I have tested it and it works just fine. However, I want to play the sound on silent mode.
Here is the code:
#import "ViewController.h"
@interface ViewController ()
@end
@implementation ViewController
-(IBAction)Button1Sound:(id)sender{
AudioServicesPlaySystemSound(Button1);
}
- (void)viewDidLoad {
NSURL *Button1Sound = [NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"nobody" ofType:@"m4a"]];
AudioServicesCreateSystemSoundID((__bridge CFURLRef)Button1Sound, & Button1);
[super viewDidLoad];
}
@end
I have looked at other questions online, and they said to add this line of code:
[[AVAudioSession sharedInstance]
setCategory: AVAudioSessionCategoryPlayback
error: nil];
I am not sure where to put it or if I am using the right syntax. I am using an audiotoolbox framework as well.