diff --git a/Persephone/MPDClient.swift b/Persephone/MPDClient.swift index 0bb7b9f..cf61b4d 100644 --- a/Persephone/MPDClient.swift +++ b/Persephone/MPDClient.swift @@ -87,11 +87,11 @@ class MPDClient { // Transport commands case .prevTrack: - mpd_run_previous(connection) + sendPreviousTrack() case .nextTrack: - mpd_run_next(connection) + sendNextTrack() case .stop: - mpd_run_stop(connection) + sendStop() case .playPause: sendPlay() @@ -103,6 +103,22 @@ class MPDClient { print(getLastErrorMessage()!) } + func sendNextTrack() { + if getState() == .playing { + mpd_run_next(connection) + } + } + + func sendPreviousTrack() { + if getState() == .playing { + mpd_run_previous(connection) + } + } + + func sendStop() { + mpd_run_stop(connection) + } + func sendPlay() { if getState() == .stopped { mpd_run_play(connection)