     }
     
     @IBAction func togglePlay(_ sender: AnyObject) {
-        let state = self.musicPlayerManager.currentPlayer!.playbackState
-        switch state {
-        case .paused:
-            self.musicPlayerManager.currentPlayer?.play()
-        case .playing:
-            self.musicPlayerManager.currentPlayer?.pause()
-        default: break
-
-        }
+        if let state = self.musicPlayerManager.currentPlayer?.playbackState {
+            switch state {
+            case .paused:
+                self.musicPlayerManager.currentPlayer?.play()
+            case .playing:
+                self.musicPlayerManager.currentPlayer?.pause()
+            default: break
+            }
+        }
+
     }
     
     @IBAction func toggleRightTime(_ sender: AnyObject) {

//
//    }

//    private func updateButton() {
//        updateButton(SpotifyAppleScript.playerState)
//    }
    
//    private func updateButton(_ state: PlayerState){
//        switch state {
//        case .paused:
//            playerStateButton.title = "▶︎"
//        case .playing:
//            playerStateButton.title = "❚❚"
//        }
//    }
    
    private func secondsToHoursMinutesSeconds (seconds : Double) -> (Int, Int, Int) {
        return (Int(seconds / 3600),


extension PopOverViewController:  MusicPlayerManagerDelegate {
    func manager(_ manager: MusicPlayerManager, trackingPlayer player: MusicPlayer, didChangeTrack track: MusicTrack, atPosition position: TimeInterval) {
        updateInfo(track: track)
    }
    
    func manager(_ manager: MusicPlayerManager, trackingPlayer player: MusicPlayer, playbackStateChanged playbackState: MusicPlaybackState, atPosition position: TimeInterval) {
        updateInfo(track: player.currentTrack)
        updateButton(state: playbackState)
    }
    
    func manager(_ manager: MusicPlayerManager, trackingPlayerDidQuit player: MusicPlayer) {
        updateInfo(track: nil)
    }
    
    func manager(_ manager: MusicPlayerManager, trackingPlayerDidChange player: MusicPlayer) {
