我正在开发 WebRTC 应用程序,通话时一切正常,但我们想在通话响铃时运行拨号声音,直到对方接听电话
我尝试运行音频(wav 文件),但它播放了一秒钟,然后我觉得它被静音了
我想这是因为覆盖了 AVAudioSession
这是我在通话开始后播放拨号声音的代码
func startDialSound() {
do {
let session = AVAudioSession.sharedInstance()
try session.setCategory(.playAndRecord, options: [.duckOthers])
try session.setActive(true, options: .notifyOthersOnDeactivation)
let path = Bundle.main.path(forResource: "dial.wav", ofType: nil)!
let url = URL(fileURLWithPath: path)
self.dialPlayer = try AVAudioPlayer(contentsOf: url)
self.dialPlayer?.prepareToPlay()
self.dialPlayer?.numberOfLoops = -1
self.dialPlayer?.volume = 1
dialPlayer?.play()
} catch {}
}
所以请你帮我解决这个问题吗?
等待回复
谢谢