iOS 14 Play audio from video in background
Add a Comment
Disconnecting player by 'AVPlayerLayer.player = nil' won't catch when appDidEnterBackGround, but it will be catch when appWillResignActive.
The problem is: when player is playing, user push locked button, phone goes directly to backgroundMode, and app 'AVPlayerLayer.player = nil'. So the player is paused. User have to click play button at lockedScreen to continue playing in background mode.
Code Block func applicationWillResignActive(_ application: UIApplication) { let viewController = window?.rootViewController as! ViewController viewController.disconnectAVPlayer() }
Code Block public func disconnectAVPlayer() { playerViewController.player = nil }