AVAudioSession setCategory Swift 4.2 iOS 12 - Play Sound on Silent

前端 未结 9 1944
醉酒成梦
醉酒成梦 2020-12-13 06:06

To play sound even on Silent mode I use to use below method. But how it\'s not working.

// Works on Swift 3  
do {
    try AVAudioSession.sharedInstance().se         


        
9条回答
  •  执笔经年
    2020-12-13 06:14

    For Swift 4.2 in iOS 12, it is simply:

    try AVAudioSession.sharedInstance().setCategory(.playAndRecord, mode: .default, options: [])
    

提交回复
热议问题