Reputation: 334
I am working on VOIP in iOS using webrtc
.
How to produce dialer tone for outgoing call , i.e. how to produce the ringer sound in ear speaker till the outgoing call connected?
Upvotes: 5
Views: 1654
Reputation: 1457
Based on Maverick's answer.This will play ringtone in ear speaker like in a phone call (works on iOS 10.3).
NSError *av_error = nil;
NSURL *url = [NSURL fileURLWithPath:[NSString stringWithFormat:@"%@/digitalphone.caf", [[NSBundle mainBundle] resourcePath]]];
av_Player = [[AVAudioPlayer alloc] initWithContentsOfURL:url error:&av_error];
NSError *sesionError = nil;
[[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryPlayAndRecord withOptions:kAudioSessionProperty_OverrideAudioRoute error:&sesionError];
av_Player.numberOfLoops = -1;
[av_Player play];
Upvotes: 0
Reputation: 85
NSURL *url = [NSURL fileURLWithPath:[NSString stringWithFormat:@"%@/TEST.aif", [[NSBundle mainBundle] resourcePath]]];
AVAudioPlayer * keepAwakePlayer = [[AVAudioPlayer alloc] initWithContentsOfURL:url error:&error];
UInt32 doSetProperty = TRUE;
[[AVAudioSession sharedInstance] setCategory: AVAudioSessionCategoryPlayback error: nil]; AudioSessionSetProperty (kAudioSessionProperty_OverrideCategoryMixWithOthers, sizeof(doSetProperty), &doSetProperty);
keepAwakePlayer.numberOfLoops = -1;
[keepAwakePlayer play];
Upvotes: 1
Reputation: 7949
I can think of two ways to do that.
Upvotes: 0