Physical Address
304 North Cardinal St.
Dorchester Center, MA 02124
Physical Address
304 North Cardinal St.
Dorchester Center, MA 02124
presently I’m enjoying ringtone utilizing AVPlayer on the time of incoming name. However in background default ringtone is enjoying from the system. How can I cease background ringtone of the system.
var participant: AVPlayer?
func playSound() {
let url = Bundle.major.url(forResource: "Maintain Music", withExtension: "mp3")!
do {
let audioSession = AVAudioSession.sharedInstance()
attempt audioSession.setActive(false, choices: [])
attempt audioSession.setCategory(.playback,mode: .default, choices: .mixWithOthers)
attempt audioSession.setActive(true)
let playerItem:AVPlayerItem = AVPlayerItem(url: url)
participant = AVPlayer(playerItem: playerItem
participant?.quantity = 1
participant.play()
} catch let error {
print("lool (error.localizedDescription)")
}
}
Name observer for getting name standing.
extension LandingViewController: CXCallObserverDelegate{
func callObserver(_ callObserver: CXCallObserver, callChanged name: CXCall) {
if name.hasEnded == true {
participant?.pause()
print("name Disconnected")
}
if name.isOutgoing == true && name.hasConnected == false {
print("name Dialing")
participant?.pause()
}
if name.isOutgoing == false && name.hasConnected == false && name.hasEnded == false {
print("name Incoming")
self.playSound()
}
}
if name.hasConnected == true && name.hasEnded == false {
print("name Related")
participant?.pause()
}
}