diff --git a/src/commands.c b/src/commands.c index 1604dbbed4b539fb6133327265473ecd43a209f9..b9f6a8e8e5c64ee9fad3b06d30ff353a4da12636 100644 --- a/src/commands.c +++ b/src/commands.c @@ -202,6 +202,7 @@ __play_that_file(sqlite3 *db, struct lkt_win *win, int pos) goto error; } + return true; error: return false; } @@ -238,7 +239,7 @@ command_play(sqlite3 *db, struct lkt_win *win, char *args[LKT_MESSAGE_ARGS_MAX], if (win->window) win->close(win); - if (!win->new (win)) { + if (!win->new(win)) { fprintf(stderr, " ! command_play: command failed because of null mpv ctx\n"); goto error; } @@ -279,7 +280,12 @@ command_playid(sqlite3 *db, struct lkt_win *win, char *args[LKT_MESSAGE_ARGS_MAX /* Do the work. */ - if (!win->window && !win->new(win)) + database_queue_stop(db); + + if (win->window) + win->close(win); + + if (!win->new(win)) goto error; if (!database_queue_seekid(db, (int) id, &pos)) diff --git a/src/database/queue.c b/src/database/queue.c index 5186795c81d757b9454bd09689f63b14f192c4a2..ecd45d86a6db8f679c6f1384a16b916433677998 100644 --- a/src/database/queue.c +++ b/src/database/queue.c @@ -731,7 +731,7 @@ database_queue_seekid(sqlite3 *db, int id, int *out_pos) SQLITE_PREPARE(db, stmt, SQL_STMT, error); SQLITE_BIND_INT(db, stmt, 1, id, error); - if (SQLITE_OK != sqlite3_step(stmt)) { + if (SQLITE_ROW != sqlite3_step(stmt)) { fprintf(stderr, "database_queue_seekid: Failed: %s\n", sqlite3_errmsg(db)); goto error; } diff --git a/src/net/listen.c b/src/net/listen.c index 3ec2fdf1e321ecd212cfec5c20a9827065e1be4f..e2b7dbee7187783bf813f8d322f777f195aa5b11 100644 --- a/src/net/listen.c +++ b/src/net/listen.c @@ -202,6 +202,8 @@ handle_simple_command(struct lkt_state *srv, size_t c, struct lkt_command cmd) else if (!strcmp(cmd.name, "play")) err = ! (command_stop(srv->db, &srv->win, &srv->mpd_idle_events) && command_play(srv->db, &srv->win, cmd.args, &srv->mpd_idle_events)); + else if (!strcmp(cmd.name, "playid")) + err = ! command_playid(srv->db, &srv->win, cmd.args, &srv->mpd_idle_events); else if (!strcmp(cmd.name, "stop")) err = !command_stop(srv->db, &srv->win, &srv->mpd_idle_events); else if (!strcmp(cmd.name, "clear"))