1

I am playing Videos in UIWebView and using the below code to play its audio in background.

do {
        try AVAudioSession.sharedInstance().setCategory(AVAudioSessionCategoryPlayback)
        print("AVAudioSession Category Playback OK")
        do {
            try AVAudioSession.sharedInstance().setActive(true)

            UIApplication.shared.beginReceivingRemoteControlEvents()
            print("AVAudioSession is Active")
        } catch let error as NSError {
            print(error.localizedDescription)
        }
    } catch let error as NSError {
        print(error.localizedDescription)
    }

The problem is that when I press Home Button, AVAudioSession do not play music automatically until I tap a play button in Toggle or control center menu. Also when I tap Play button, it hides seek track duration and music info, when I pause music then it show.

I have attached a control center image which shows what I need for videos.enter image description here

Please guide me how to fix it? Thanks

user3314286
  • 243
  • 3
  • 18

0 Answers0