Address to the problem that the video is paused during background transition while playing video on iOS14

Correspondence

** Change the execution timing of **

@objc func applicationWillResignActive(_ notification: NSNotification?) {
   playerView.player = nil
}

@objc func applicationDidBecomeActive(_ notification: NSNotification?) {
   playerView.player = player
}

Background

Before correspondence

Survey

Verification

  1. Manually playerView.player = nil during video playback and before background migration
  2. Go to background

⇒ ** "Playback continued!" **

The conclusion drawn is ... ** "Isn't the timing of checking if there is a player in the layer changed?" **

Revalidation

  1. Changed to playerView.player = nil in ** ʻapplicationWillResignActive ** that runs before ʻapplicationDidEnterBackground
  2. ʻapplicationWillResignActive is paired with ** ʻapplicationDidBecomeActive **, so change to playerView.player = player.

⇒ ** "Playback continued!" **

Summary

Other

References

  1. Apple : Playing media while in the background using AV Foundation on iOS
  2. Apple : Playing Audio from a Video Asset in the Background
  3. @KenNagami: iOS App Lifecycle
  4. @bosteri_bon: Fixed the problem that "background playback" is not possible on iOS14

Recommended Posts

Address to the problem that the video is paused during background transition while playing video on iOS14
How to solve the problem that notification cannot be requested on iOS14
How to solve the problem that the website image is not displayed after deploying to heroku on Rails 5
Get the event that the iOS application moves to the back on the View side
How to fix the problem that the upper half is cut off when using UITabBar