[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).
This commit is contained in:
chme 2016-07-30 08:31:10 +02:00
parent 9af09c204d
commit e6b53cb88e

View File

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