1
1
mirror of https://github.com/danbee/persephone synced 2025-03-04 08:39:11 +00:00

Check playing state before sending next/previous

This commit is contained in:
Daniel Barber 2019-02-01 10:26:05 -05:00
parent 693ce17c4d
commit 9ec70e76b0
Signed by: danbarber
GPG Key ID: 931D8112E0103DD8

View File

@ -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)