I am developing a sip call based application and I want to send a call in the background if someone starts a call and exits the application. In this case, I want to display the duration of the call on the screen. For this, I use the in_call status bar. But the code I used sets the background color of the in_call status bar to red, and I don’t understand how to change its color to green, I also want to show the timer on it. Since I am using this first time, I am not getting how to solve this. Here is my code. Please help if anyone can. I call this method the didFinishLaunchingWithOptions method
+(void) startRecording {
AVAudioSession * audioSession = [AVAudioSession sharedInstance];
NSError * err = nil;
[audioSession setCategory: AVAudioSessionCategoryPlayAndRecord error: & err];
if (err) {
NSLog(@"audioSession: %@ %d %@", [err domain], [err code], [
[err userInfo] description
]);
return;
}
[audioSession setActive: YES error: & err];
err = nil;
if (err) {
NSLog(@"audioSession: %@ %d %@", [err domain], [err code], [
[err userInfo] description
]);
return;
}
NSMutableDictionary * recordSetting = [
[NSMutableDictionary alloc] init
];
[recordSetting setValue: [NSNumber numberWithInt: kAudioFormatLinearPCM] forKey: AVFormatIDKey];
[recordSetting setValue: [NSNumber numberWithFloat: 44100.0] forKey: AVSampleRateKey];
[recordSetting setValue: [NSNumber numberWithInt: 2] forKey: AVNumberOfChannelsKey];
[recordSetting setValue: [NSNumber numberWithInt: 16] forKey: AVLinearPCMBitDepthKey];
[recordSetting setValue: [NSNumber numberWithBool: NO] forKey: AVLinearPCMIsBigEndianKey];
[recordSetting setValue: [NSNumber numberWithBool: NO] forKey: AVLinearPCMIsFloatKey];
NSURL * url = [NSURL fileURLWithPath: @"/dev/null"];
err = nil;
AVAudioRecorder * recorder = [
[AVAudioRecorder alloc] initWithURL: url settings: recordSetting error: & err
];
if (!recorder) {
NSLog(@"recorder: %@ %d %@", [err domain], [err code], [
[err userInfo] description
]);
UIAlertView * alert = [
[UIAlertView alloc] initWithTitle: @"Warning"
message: [err localizedDescription]
delegate: nil
cancelButtonTitle: @"OK"
otherButtonTitles: nil
];
[alert show];
return;
}
[recorder setDelegate: self];
[recorder prepareToRecord];
recorder.meteringEnabled = YES;
BOOL audioHWAvailable = audioSession.inputIsAvailable;
if (!audioHWAvailable) {
UIAlertView * cantRecordAlert = [
[UIAlertView alloc] initWithTitle: @"Warning"
message: @"Audio input hardware not available"
delegate: nil
cancelButtonTitle: @"OK"
otherButtonTitles: nil
];
[cantRecordAlert show];
return;
}
[recorder record];
}