summaryrefslogtreecommitdiffstats
path: root/player/command.c
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2020-03-21 17:45:30 +0100
committerwm4 <wm4@nowhere>2020-03-21 19:33:03 +0100
commit7e885a3bc3af4df93681b6e760a34e59e2f47ef7 (patch)
treec2687c6b364a2e5aeef0c466fb04988bafc35ab3 /player/command.c
parent956a5d9ac61ffe4034abcc81405e8ecdacac8b36 (diff)
downloadmpv-7e885a3bc3af4df93681b6e760a34e59e2f47ef7.tar.bz2
mpv-7e885a3bc3af4df93681b6e760a34e59e2f47ef7.tar.xz
client API: add a playlist entry unique ID
This should make dealing with some async. things easier. It's intentionally not a globally unique ID.
Diffstat (limited to 'player/command.c')
-rw-r--r--player/command.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/player/command.c b/player/command.c
index f8e248880a..e567ffb032 100644
--- a/player/command.c
+++ b/player/command.c
@@ -2798,6 +2798,7 @@ static int get_playlist_entry(int item, int action, void *arg, void *ctx)
{"current", SUB_PROP_FLAG(1), .unavailable = !current},
{"playing", SUB_PROP_FLAG(1), .unavailable = !playing},
{"title", SUB_PROP_STR(e->title), .unavailable = !e->title},
+ {"id", SUB_PROP_INT64(e->id)},
{0}
};
@@ -4881,6 +4882,10 @@ static void cmd_loadfile(void *p)
}
playlist_add(mpctx->playlist, entry);
+ struct mpv_node *res = &cmd->result;
+ node_init(res, MPV_FORMAT_NODE_MAP, NULL);
+ node_map_add_int64(res, "playlist_entry_id", entry->id);
+
if (!append || (append == 2 && !mpctx->playlist->current)) {
if (mpctx->opts->position_save_on_quit) // requested in issue #1148
mp_write_watch_later_conf(mpctx);
@@ -4904,6 +4909,8 @@ static void cmd_loadlist(void *p)
struct playlist_entry *new = pl->current;
if (!append)
playlist_clear(mpctx->playlist);
+ struct playlist_entry *first = playlist_entry_from_index(pl, 0);
+ int num_entries = pl->num_entries;
playlist_append_entries(mpctx->playlist, pl);
talloc_free(pl);
@@ -4913,6 +4920,13 @@ static void cmd_loadlist(void *p)
if (!append && new)
mp_set_playlist_entry(mpctx, new);
+ struct mpv_node *res = &cmd->result;
+ node_init(res, MPV_FORMAT_NODE_MAP, NULL);
+ if (num_entries) {
+ node_map_add_int64(res, "playlist_entry_id", first->id);
+ node_map_add_int64(res, "num_entries", num_entries);
+ }
+
mp_notify(mpctx, MP_EVENT_CHANGE_PLAYLIST, NULL);
mp_wakeup_core(mpctx);
} else {