 
     func applicationDidEnterBackground(notification: NSNotification) {
 
-        self.avPlayerViewController.player = nil
+        func remove() {
+
+            // Remove the reference from AVPlayerViewController for background playback
+            self.avPlayerViewController.player = nil
+        }
+
+        if #available(iOS 9.0, *) {
+
+            if AVPictureInPictureController.isPictureInPictureSupported()
+                && self.allowsPictureInPicturePlayback {
+
+                // Do nothing. Keep the reference from AVPlayerViewController for Picture in Picture.
+            }
+            else {
+
+                remove()
+            }
+        }
+        else {
+
+            remove()
+        }
     }
 
     func applicationWillEnterForeground(notification: NSNotification) {
 
+        // Refer again for case of background playback
         self.avPlayerViewController.player = self.player
     }
 


    public var minimumBufferDuration: Double = 5.0

    public weak var delegate: KKPlayerViewControllerDelegate?

    // MARK: Private properties



        self.backgroundColor = UIColor.blackColor()

        self.avPlayerViewController.addObserver(
            self,
            forKeyPath: avPlayerViewControllerReadyForDisplayKey,
