     
     public override func play() {
         player.play()
-        currentState = .Playing
         
         if !player.currentItem!.playbackLikelyToKeepUp {
-            trigger(.Buffering)
+            updateState(.Buffering)
         }
     }
     
     public override func pause() {
         player.pause()
-        currentState = .Paused
-        trigger(.Pause)
+        updateState(.Paused)
     }
     
     public override func isPlaying() -> Bool {

    
    private func handleBufferingEvent(keyPath: String) {
        if keyPath == "currentItem.playbackLikelyToKeepUp" {
            if shouldResumePlayAfterBufferEvent() {
                play()
            } else if !player.currentItem!.playbackLikelyToKeepUp {
                trigger(.Buffering)
            }
        } else if keyPath == "currentItem.playbackBufferEmpty" {
            trigger(.Buffering)
        }
    }
    
    private func shouldResumePlayAfterBufferEvent() -> Bool {
        return player.rate == 0 && currentState == .Playing
            && player.currentItem!.playbackLikelyToKeepUp
    }
    
    deinit {

            options: .New, context: &kvoBufferingContext)
        player.addObserver(self, forKeyPath: "currentItem.playbackBufferEmpty",
            options: .New, context: &kvoBufferingContext)
        
        NSNotificationCenter.defaultCenter().addObserver(self, selector: "playbackDidEnd",
            name: AVPlayerItemDidPlayToEndTimeNotification, object: player.currentItem)
    }
    
    func playbackDidEnd() {
        trigger(.Ended)
        updateState(.Idle)
        player.seekToTime(kCMTimeZero)
    }
    
    private func addTimeElapsedCallback() {
        player.addPeriodicTimeObserverForInterval(CMTimeMakeWithSeconds(0.2, 600), queue: nil) { [weak self] time in
            self?.timeUpdated(time)
        }
    }
    
    private func timeUpdated(time: CMTime) {
        if isPlaying() {
            updateState(.Playing)
            trigger(.TimeUpdated, userInfo: ["position" : CMTimeGetSeconds(time)])
        }
    }
