I am working on WebRTC application and everything is doing fine on call but we want to run dial sound when call is ringing until other side accpet the call
i try to run audio (wav file) but it is play for a sec and then i feel it is muted
i guess it is because overriding of AVAudioSession
here is my code to play dial sound after call is starting
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 {}
}
so please can you help me to fix that?
waiting responses
thanks
RTCAudioSession
to use manual audio:RTCAudioSession.sharedInstance().useManualAudio = true
AudioSession
for call in thefunc provider(_ provider: CXProvider, perform action: CXStartCallAction)
:func provider(_ provider: CXProvider, didActivate audioSession: AVAudioSession)
called: