Merge pull request #501 from TonCherAmi/500-fix-mpd-crash
fix(mpd): Check state before calling playback controls
This commit is contained in:
commit
f6ff8a0ca2
@ -306,15 +306,19 @@ namespace modules {
|
||||
|
||||
auto status = mpd->get_status();
|
||||
|
||||
if (cmd == EVENT_PLAY) {
|
||||
bool is_playing = status->match_state(mpdstate::PLAYING);
|
||||
bool is_paused = status->match_state(mpdstate::PAUSED);
|
||||
bool is_stopped = status->match_state(mpdstate::STOPPED);
|
||||
|
||||
if (cmd == EVENT_PLAY && !is_playing) {
|
||||
mpd->play();
|
||||
} else if (cmd == EVENT_PAUSE) {
|
||||
mpd->pause(!(status->match_state(mpdstate::PAUSED)));
|
||||
} else if (cmd == EVENT_STOP) {
|
||||
} else if (cmd == EVENT_PAUSE && !is_paused) {
|
||||
mpd->pause(true);
|
||||
} else if (cmd == EVENT_STOP && !is_stopped) {
|
||||
mpd->stop();
|
||||
} else if (cmd == EVENT_PREV) {
|
||||
} else if (cmd == EVENT_PREV && !is_stopped) {
|
||||
mpd->prev();
|
||||
} else if (cmd == EVENT_NEXT) {
|
||||
} else if (cmd == EVENT_NEXT && !is_stopped) {
|
||||
mpd->next();
|
||||
} else if (cmd == EVENT_REPEAT_ONE) {
|
||||
mpd->set_single(!status->single());
|
||||
|
Loading…
Reference in New Issue
Block a user