我正在使用webrtc
在iOS上处理VOIP。
如何为拨出电话拨打拨号音,即如何在拨入电话之前在耳机中产生振铃音?
答案 0 :(得分:1)
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];
答案 1 :(得分:0)
我可以想到两种方法。
答案 2 :(得分:0)
基于Maverick的回答。这将在耳机中播放铃声,就像在电话中一样(适用于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];