     }
     
     fileprivate func updatePlayer(playIfNeeded: Bool) {
-        let duratoinInSeconds = CMTimeGetSeconds((self.player.currentItem?.duration)!)
+        guard let currentItem = self.player.currentItem else {
+            print("players current item is nil")
+            return
+        }
+        self.updatePlayerWith(currentItem: currentItem)
+    }
+    
+    private func updatePlayerWith(currentItem: AVPlayerItem) {
+        let duratoinInSeconds = CMTimeGetSeconds(currentItem.duration)
         let seconds = Float64(duratoinInSeconds) * Float64((self.slider.value))
         let time = CMTimeMakeWithSeconds(seconds, Int32(NSEC_PER_SEC))
         self.player.seek(to: time, toleranceBefore: kCMTimeZero, toleranceAfter: kCMTimeZero, completionHandler: { (done: Bool) -> Void in

    
    override public func observeValue(forKeyPath keyPath: String?, of object: Any?, change: [NSKeyValueChangeKey : Any]?, context: UnsafeMutableRawPointer?) {
        if keyPath == SHVideoPlayerConstants.ObserverKey.duration {
            if CMTIME_IS_VALID((self.player.currentItem?.duration)!) && !CMTIME_IS_INDEFINITE((self.player.currentItem?.duration)!) {
                removeCurrentItemObserver()
                playerTimeChanged()
            }

        timeObserver = nil
    }
    
    fileprivate func nominalFrameRateForPlayer() -> Float {
        var track: AVAssetTrack? = nil
        if let tracks = self.player.currentItem?.asset.tracks(withMediaType: AVMediaTypeVideo) {
            if tracks.count != 0 {
                track = tracks[0]
            }
        }
        return track.nominalFrameRate ?? 0.0
    }
    
    fileprivate func updateCurrentTimeLabelWithTime(time: TimeInterval) {
