我正在使用webrtc在iOS中进行VOIP。

如何为拨出电话产生拨号音,即在拨出电话连接之前如何在耳塞扬声器中产生铃声?

最佳答案

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];

08-16 02:50