diff --git a/src/base/commands.c b/src/base/commands.c index 7cf09f54390993fdf09ed61d766d8ca2d1274b5c..029eaec9a8a7737dcdb73296126b5fa12e91297d 100644 --- a/src/base/commands.c +++ b/src/base/commands.c @@ -183,8 +183,12 @@ command_next(struct lkt_state *srv, char UNUSED *args[LKT_MESSAGE_ARGS_MAX]) { srv->mpd_idle_events |= MPD_IDLE_PLAYER; char filepath[PATH_MAX]; - if (!database_queue_next(srv->db, filepath)) + if (!database_queue_next(srv->db, filepath)) { + LOG_DEBUG("COMMAND", + "Failed to get next, stop the player because we may be at the end of the queue"); + command_stop(srv, NULL); return false; + } if (MOD_CALL(srv->window_mod, "load", filepath)) return false; else { @@ -243,7 +247,7 @@ command_play(struct lkt_state *srv, char UNUSED *args[LKT_MESSAGE_ARGS_MAX]) /* If position is after the queue, don't do anything */ RETURN_UNLESS(database_queue_state(srv->db, &queue_state), "Can't get playback status", false); - if (queue_state.length <= pos) { + if (queue_state.length < pos) { LOG_INFO("COMMAND", "Don't perform play command, queue is empty or position is after queue length"); return false; }