         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


        // TODO:
        // Seek to 0 if time is more than 5 seconds, else go to previous
        if hasPreviousItem {
            self.cleanupCurrentItem()
            self.play(self.currentIndex - 1)
        }
    }
