             }
         
         } else if (context == &PlayerLayerObserverContext) {
-            if self._playerView.playerLayer.isReadyForDisplay {
-                self.executeClosureOnMainQueueIfNecessary(withClosure: {
-                    self.delegate?.playerReady?(self)
-                })
+            if let layer = self._playerView.playerLayer {
+                if layer.isReadyForDisplay {
+                    self.executeClosureOnMainQueueIfNecessary(withClosure: {
+                        self.delegate?.playerReady?(self)
+                    })
+                }
             }
         }
         

    /// Player view's initial background color.
    open var layerBackgroundColor: UIColor? {
        get {
            guard let backgroundColor = self._playerView.playerLayer.backgroundColor else { return nil }
            return UIColor(cgColor: backgroundColor)
        }
        set {
            self._playerView.playerLayer.backgroundColor = newValue?.cgColor
        }
    }
    

    open override func loadView() {
        self._playerView = PlayerView(frame: CGRect.zero)
        self._playerView.fillMode = AVLayerVideoGravityResizeAspect
        self._playerView.playerLayer?.isHidden = true
        self.view = self._playerView
    }
    
