     }
     
     private func addObservers() {
-        player.addObserver(self, forKeyPath: "currentItem.status",
-            options: .New, context: &kvoStatusDidChangeContext)
-        player.addObserver(self, forKeyPath: "currentItem.loadedTimeRanges",
-            options: .New, context: &kvoTimeRangesContext)
-        player.addObserver(self, forKeyPath: "currentItem.playbackLikelyToKeepUp",
-            options: .New, context: &kvoBufferingContext)
-        player.addObserver(self, forKeyPath: "currentItem.playbackBufferEmpty",
-            options: .New, context: &kvoBufferingContext)
+        player?.addObserver(self, forKeyPath: "currentItem.status",
+                            options: .New, context: &kvoStatusDidChangeContext)
+        player?.addObserver(self, forKeyPath: "currentItem.loadedTimeRanges",
+                            options: .New, context: &kvoTimeRangesContext)
+        player?.addObserver(self, forKeyPath: "currentItem.playbackLikelyToKeepUp",
+                            options: .New, context: &kvoBufferingContext)
+        player?.addObserver(self, forKeyPath: "currentItem.playbackBufferEmpty",
+                            options: .New, context: &kvoBufferingContext)
         
         NSNotificationCenter.defaultCenter().addObserver(self, selector: #selector(AVFoundationPlayback.playbackDidEnd),
-            name: AVPlayerItemDidPlayToEndTimeNotification, object: player.currentItem)
+                                                         name: AVPlayerItemDidPlayToEndTimeNotification, object: player?.currentItem)
     }
     
     func playbackDidEnd() {
         trigger(.Ended)
         updateState(.Idle)
-        player.seekToTime(kCMTimeZero)
+        player?.seekToTime(kCMTimeZero)
     }
     
     public override func pause() {
-        player.pause()
+        player?.pause()
         updateState(.Paused)
     }
     
     public override func stop() {
-        player.pause()
+        player?.pause()
         playbackDidEnd()
         removeObservers()
-        playerLayer.removeFromSuperlayer()
+        playerLayer?.removeFromSuperlayer()
         player = nil
     }
     
     public override func isPlaying() -> Bool {
-        return player != nil &&  player.rate > 0
+        return player != nil && player?.rate > 0
     }
     
     public override func seekTo(timeInterval: NSTimeInterval) {
         let time = CMTimeMakeWithSeconds(timeInterval, Int32(NSEC_PER_SEC))
         
-        player.currentItem?.seekToTime(time)
+        player?.currentItem?.seekToTime(time)
         trigger(.TimeUpdated, userInfo: ["position" : CMTimeGetSeconds(time)])
     }
     
     public override func duration() -> Double {
-        guard playbackType() == .VOD, let item = player.currentItem else {
+        guard playbackType() == .VOD, let item = player?.currentItem else {
             return 0
         }
-
+        
         return CMTimeGetSeconds(item.asset.duration)
     }
     
     public override func playbackType() -> PlaybackType {
-        guard player != nil, let duration = player.currentItem?.asset.duration else {
+        guard let player = player, let duration = player.currentItem?.asset.duration else {
             return .Unknown
         }
         

        }
    }
    
    deinit {
        removeObservers()
    }
    
    private func removeObservers() {
        if player != nil {
            player.removeObserver(self, forKeyPath: "currentItem.status")
            player.removeObserver(self, forKeyPath: "currentItem.loadedTimeRanges")
            player.removeObserver(self, forKeyPath: "currentItem.playbackLikelyToKeepUp")
            player.removeObserver(self, forKeyPath: "currentItem.playbackBufferEmpty")
        }
        NSNotificationCenter.defaultCenter().removeObserver(self)
    }

    }
    
    private func addTimeElapsedCallback() {
        player?.addPeriodicTimeObserverForInterval(CMTimeMakeWithSeconds(0.2, 600), queue: nil) { [weak self] time in
            self?.timeUpdated(time)
        }
    }
