         registerListener(#selector(Twist.playerItemPlaybackStall(_:)), notification: AVPlayerItemPlaybackStalledNotification)
         registerListener(#selector(Twist.interruption(_:)), notification: AVAudioSessionInterruptionNotification)
         registerListener(#selector(Twist.routeChange(_:)), notification: AVAudioSessionRouteChangeNotification)
+        
+        let commandCenter = MPRemoteCommandCenter.sharedCommandCenter()
+        commandCenter.nextTrackCommand.addTarget(self, action: #selector(Twist.next))
+        commandCenter.previousTrackCommand.addTarget(self, action: #selector(Twist.previous))
+        commandCenter.playCommand.addTarget(self, action: #selector(Twist.play(_:)))
+        commandCenter.pauseCommand.addTarget(self, action: #selector(Twist.pause))
+        commandCenter.togglePlayPauseCommand.addTarget(self, action: #selector(Twist.togglePlayPause))
     }
     
     func playerItemDidReachEnd(notification: NSNotification) {


import Foundation
import AVFoundation

let debugging  = true
var myContext  = 0

            debug("Pausing current item")
            self.player?.pause()
            self.currentState = .Paused
            self.triggerPlaybackStateChanged()
        }
    }

    public func stop() {
        if (self.player != nil) {
            self.cleanupCurrentItem()
            debug("Stopping current item")
            self.triggerPlaybackStateChanged()
        }
    }
    
    func cleanupCurrentItem() {
        self.currentState = .Waiting
        self.currentPlayerItem?.removeObserver(self, forKeyPath: kStatusKey)
        self.currentPlayerItem?.removeObserver(self, forKeyPath: kLoadedTimeRangesKey)
        self.currentPlayerItem = nil
        self.player = nil
    }

    public func next() {
        if !isPlayable() {
            return
        }
    
        if hasNextItem {
            self.cleanupCurrentItem()
            self.play(self.currentIndex + 1)
        }
    }
    
    // TODO:
    // Check the repeat
    // Check the shuffle settings
    var hasNextItem: Bool {
        return self.currentIndex < self.dataSource!.twistNumberOfItems() - 1
    }
    
    // Check the repeat
    // Check the shuffle settings
    var hasPreviousItem: Bool {
        return self.currentIndex != 0
    }

    public func previous() {
