                 if let status = change?[NSKeyValueChangeKey.newKey] as? NSNumber {
                     switch (status.intValue as AVPlayerStatus.RawValue) {
                     case AVPlayerStatus.readyToPlay.rawValue:
-                        self._playerView.playerLayer.player = self._avplayer
-                        self._playerView.playerLayer.isHidden = false
+                        if let layer = self._playerView.playerLayer {
+                            layer.player = self._avplayer
+                            layer.isHidden = false
+                        }
                     case AVPlayerStatus.failed.rawValue:
                         self.playbackState = PlaybackState.failed
                     default:

                if let status = change?[NSKeyValueChangeKey.newKey] as? NSNumber {
                    switch (status.intValue as AVPlayerStatus.RawValue) {
                    case AVPlayerStatus.readyToPlay.rawValue:
                        self._playerView.playerLayer.player = self._avplayer
                        self._playerView.playerLayer.isHidden = false
                    case AVPlayerStatus.failed.rawValue:
                        self.playbackState = PlaybackState.failed
                    default:

    /// 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
        }
    }
    
