[player/jsonapi] Do not report error on skip next/prev if end/start of

queue is reached
This commit is contained in:
chme 2020-06-28 11:56:51 +02:00
parent 82d48cba3a
commit 8e333c7978
2 changed files with 14 additions and 11 deletions

View File

@ -1889,8 +1889,10 @@ jsonapi_reply_player_next(struct httpd_request *hreq)
ret = player_playback_next(); ret = player_playback_next();
if (ret < 0) if (ret < 0)
{ {
DPRINTF(E_LOG, L_WEB, "Error switching to next item.\n"); // If skipping to the next song failed, it is most likely we reached the end of the queue,
return HTTP_INTERNAL; // ignore the error (play status change will be reported to the client over the websocket)
DPRINTF(E_DBG, L_WEB, "Error switching to next item (possibly end of queue reached).\n");
return HTTP_NOCONTENT;
} }
ret = player_playback_start(); ret = player_playback_start();

View File

@ -2133,7 +2133,7 @@ playback_start(void *arg, int *retval)
static enum command_state static enum command_state
playback_prev_bh(void *arg, int *retval) playback_prev_bh(void *arg, int *retval)
{ {
struct db_queue_item *queue_item; struct db_queue_item *queue_item = NULL;
int ret; int ret;
// outputs_flush() in playback_pause() may have a caused a failure callback // outputs_flush() in playback_pause() may have a caused a failure callback
@ -2147,11 +2147,11 @@ playback_prev_bh(void *arg, int *retval)
if (pb_session.playing_now->pos_ms > 0) if (pb_session.playing_now->pos_ms > 0)
history_add(pb_session.playing_now->id, pb_session.playing_now->item_id); history_add(pb_session.playing_now->id, pb_session.playing_now->item_id);
// Only skip to the previous song if the playing time is less than 3 seconds, // Only skip to the previous song if the playing time is less than 3 seconds
// otherwise restart the current song.
if (pb_session.playing_now->pos_ms < 3000) if (pb_session.playing_now->pos_ms < 3000)
queue_item = queue_item_prev(pb_session.playing_now->item_id); queue_item = queue_item_prev(pb_session.playing_now->item_id);
else // If there is no previous item in the queue or playing time is greater than 3 seconds, restart the current item
if (!queue_item)
queue_item = db_queue_fetch_byitemid(pb_session.playing_now->item_id); queue_item = db_queue_fetch_byitemid(pb_session.playing_now->item_id);
if (!queue_item) if (!queue_item)
{ {
@ -2203,15 +2203,16 @@ playback_next_bh(void *arg, int *retval)
} }
queue_item = queue_item_next(pb_session.playing_now->item_id); queue_item = queue_item_next(pb_session.playing_now->item_id);
if (!queue_item)
{
DPRINTF(E_DBG, L_PLAYER, "Error finding next source, queue item has disappeared\n");
goto error;
}
if (consume) if (consume)
db_queue_delete_byitemid(pb_session.playing_now->item_id); db_queue_delete_byitemid(pb_session.playing_now->item_id);
if (!queue_item)
{
DPRINTF(E_DBG, L_PLAYER, "Error finding next source, end of queue reached or queue item has disappeared\n");
goto error;
}
ret = pb_session_start(queue_item, 0); ret = pb_session_start(queue_item, 0);
free_queue_item(queue_item, 0); free_queue_item(queue_item, 0);
if (ret < 0) if (ret < 0)