Swift耳機模式和擴音器模式切換

來源:互聯網
上載者:User

標籤:nbsp   enable   ble   dev   set   ios   uidevice   cat   let   


 本文只作自用筆記,不喜忽噴,誠謝錯誤修正.

耳機模式

UIDevice.current.isProximityMonitoringEnabled = true //開啟紅外線功能

        let session = AVAudioSession()

        do{

            try session.setCategory(AVAudioSessionCategoryPlayAndRecord, with: [])

            try session.setActive(true)

        }catch{

            

        }

擴音器模式

UIDevice.current.isProximityMonitoringEnabled = true //開啟紅外線功能

        let session = AVAudioSession()

        do{

            try session.setCategory(AVAudioSessionCategoryPlayback, with: [])

            try session.setActive(true)

        }catch{

            

        }

Swift耳機模式和擴音器模式切換

相關文章

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.