Swift: Keep playing sounds when the device is locked

后端 未结 4 1039
眼角桃花
眼角桃花 2021-01-15 04:50

I\'m using the following code to play a sound off a URL from the internet:

var audioPlayer = AVPlayer()

...

let audioSessio         


        
4条回答
  •  天命终不由人
    2021-01-15 05:35

    You use wrong category, for AVAudioSessionCategoryAmbient it's normal behavior "Your audio is silenced by screen locking and by the Silent switch". Use AVAudioSessionCategoryPlayback instead.

提交回复
热议问题