From 9af09c204d93a7d52a94c8587b48101c27609c5c Mon Sep 17 00:00:00 2001 From: chme Date: Sat, 30 Jul 2016 08:09:30 +0200 Subject: [PATCH] [mpd] Fix mpd command 'play' if player is already playing While playing issueing command 'play' with a songposition -1 does noting in mpd, with songposition > 0 it starts playback of the song at this position (if this song is already playing, it starts from the beginning). --- src/mpd.c | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/src/mpd.c b/src/mpd.c index 39f17766..193d4c10 100644 --- a/src/mpd.c +++ b/src/mpd.c @@ -1146,16 +1146,6 @@ mpd_command_play(struct evbuffer *evbuf, int argc, char **argv, char **errmsg) player_get_status(&status); - //TODO verfiy handling of play with parameter if already playing - if (status.status == PLAY_PLAYING) - { - ret = player_playback_pause(); - if (ret < 0) - { - DPRINTF(E_LOG, L_MPD, "Error pausing playback\n"); - } - } - songpos = 0; if (argc > 1) { @@ -1169,6 +1159,18 @@ mpd_command_play(struct evbuffer *evbuf, int argc, char **argv, char **errmsg) } } + if (status.status == PLAY_PLAYING && songpos < 0) + { + DPRINTF(E_DBG, L_MPD, "Ignoring play command with parameter '%s', player is already playing.\n", argv[1]); + return 0; + } + + if (status.status == PLAY_PLAYING) + { + // Stop playback, if player is already playing and a valid song position is given (it will be restarted for the given song position) + player_playback_stop(); + } + if (songpos > 0) ret = player_playback_start_byindex(songpos, NULL); else