From e6b53cb88e63c0a9c5d997f69d7d749ea1e13f65 Mon Sep 17 00:00:00 2001 From: chme Date: Sat, 30 Jul 2016 08:31:10 +0200 Subject: [PATCH] [mpd] Fix mpd command 'playid' if player is already playing While playing issueing command 'playid' starts playback of the song with the given item-id (if this song is already playing, it starts from the beginning). --- src/mpd.c | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/src/mpd.c b/src/mpd.c index 193d4c10..686bff3f 100644 --- a/src/mpd.c +++ b/src/mpd.c @@ -1201,19 +1201,10 @@ mpd_command_playid(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"); - } - } - id = 0; if (argc > 1) { + //TODO [mpd] mpd allows passing "-1" as argument and simply ignores it, forked-daapd fails to convert "-1" to an unsigned int ret = safe_atou32(argv[1], &id); if (ret < 0) { @@ -1224,6 +1215,12 @@ mpd_command_playid(struct evbuffer *evbuf, int argc, char **argv, char **errmsg) } } + if (status.status == PLAY_PLAYING) + { + // Stop playback, if player is already playing and a valid item id is given (it will be restarted for the given song) + player_playback_stop(); + } + if (id > 0) ret = player_playback_start_byitemid(id, NULL); else