Sbstatusbarcontroller Instance

SBStatusBarController instance

Ok, I've found the way how to show double-height status bar like In-Call status bar without SpringBoard and using legal means. Here is a solution. There are two ways to show a double-height status bar with application name while an application is in background mode: Connect to VoIP service using sockets or to simulate audio recording. Using the first way you will see a green glowing status bar and if you prefer red color you have to use the second one. Ok, I use the second approach and perform audio recording simulation. To reach this, just add the following strings to PLIST config file of application:

<key>UIBackgroundModes</key>
<array>
<string>voip</string>
<string>audio</string>
</array>

It will tells iOS that your application will use audio and VoIP in background. And now code. We will simulate audio recording from microphone to NULL device:

- (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;
}

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;
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];
[alert release];
return;
}

//prepare to record
[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];
[cantRecordAlert release];
return;
}

// start recording
[recorder record];//recordForDuration:(NSTimeInterval) 40];

}

Add this method to your application delegate and call it from didFinishLaunchingWithOptions. Also, as I understood, you can just set the audio session category as AVAudioSessionCategoryPlayAndRecord and make it active. If you add this code to your project then in case you put your application into the background you will see a double-height status bar with your application name inside.

I think that's all.

Thanks.

Show green bar on top of screen to return to app

if your app is not a voip or audio app, apple wont like this

but it works using a plist key. see: SBStatusBarController instance

AVAudioRecorder not working on iPhone 5S

Did some more digging and I apparently found the solution. I simply got rid of AVEncoderBitRateKey and everything works fine. So now my recordSettings dictionary looks like this:

// Setup audio recording
NSDictionary *recordSettings = @{AVFormatIDKey: @(kAudioFormatMPEG4AAC),
AVEncoderAudioQualityKey: @(AVAudioQualityLow),
AVNumberOfChannelsKey: @1,
AVSampleRateKey: @22050.0f};

Still not sure why this would be the case only on an iPhone 5S. Again, I've tested on all other devices running iOS6 and iOS7, and the old settings dictionary works fine on everything except for the 5S. Now that I've removed the AVEncoderBitRateKey and value, it also works on the 5S.

iOS Change device speaker

Twilio developer evangelist here.

You should not use AVAudioSession APIs directly with Twilio Video. Instead, you should use the TVIAudioController and set the audioOutput property to one of the options enumerated in TVIAudioOutput.

TVIAudioController.sharedController().audioOutput = .TVIAudioOutputVideoChatSpeaker

Let me know if that helps.



Related Topics



Leave a reply



Submit