summaryrefslogtreecommitdiffstats
path: root/player
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2014-02-15 16:54:55 +0100
committerwm4 <wm4@nowhere>2014-02-16 03:51:02 +0100
commite41d27c7dbc05d4df3107cdea3186e480a473210 (patch)
tree981b5975518a38daeb3fd7a329a1cebf1341d046 /player
parent92133b1dcd403b0befd955c83833edcba249c1b1 (diff)
downloadmpv-e41d27c7dbc05d4df3107cdea3186e480a473210.tar.bz2
mpv-e41d27c7dbc05d4df3107cdea3186e480a473210.tar.xz
command: export playlist as properties
Diffstat (limited to 'player')
-rw-r--r--player/command.c28
1 files changed, 17 insertions, 11 deletions
diff --git a/player/command.c b/player/command.c
index 826a94fd75..068bf7816d 100644
--- a/player/command.c
+++ b/player/command.c
@@ -1779,20 +1779,25 @@ static int mp_property_playlist_pos(m_option_t *prop, int action, void *arg,
return M_PROPERTY_NOT_IMPLEMENTED;
}
-static int mp_property_playlist_count(m_option_t *prop, int action, void *arg,
- MPContext *mpctx)
+static int get_playlist_entry(int item, int action, void *arg, void *ctx)
{
- if (action == M_PROPERTY_GET) {
- *(int *)arg = playlist_entry_count(mpctx->playlist);
- return M_PROPERTY_OK;
- }
- return M_PROPERTY_NOT_IMPLEMENTED;
+ struct MPContext *mpctx = ctx;
+ struct playlist_entry *e = playlist_entry_from_index(mpctx->playlist, item);
+ if (!e)
+ return M_PROPERTY_ERROR;
+
+ struct m_sub_property props[] = {
+ {"filename", SUB_PROP_STR(e->filename)},
+ {0}
+ };
+
+ return m_property_read_sub(props, action, arg);
}
static int mp_property_playlist(m_option_t *prop, int action, void *arg,
MPContext *mpctx)
{
- if (action == M_PROPERTY_GET) {
+ if (action == M_PROPERTY_PRINT) {
char *res = talloc_strdup(NULL, "");
for (struct playlist_entry *e = mpctx->playlist->first; e; e = e->next)
@@ -1807,7 +1812,8 @@ static int mp_property_playlist(m_option_t *prop, int action, void *arg,
*(char **)arg = res;
return M_PROPERTY_OK;
}
- return M_PROPERTY_NOT_IMPLEMENTED;
+ return m_property_read_list(action, arg, playlist_entry_count(mpctx->playlist),
+ get_playlist_entry, mpctx);
}
static char *print_obj_osd_list(struct m_obj_settings *list)
@@ -1984,9 +1990,9 @@ static const m_option_t mp_properties[] = {
{ "chapter-list", mp_property_list_chapters, CONF_TYPE_STRING },
M_PROPERTY("track-list", property_list_tracks),
- { "playlist", mp_property_playlist, CONF_TYPE_STRING },
+ M_PROPERTY("playlist", mp_property_playlist),
{ "playlist-pos", mp_property_playlist_pos, CONF_TYPE_INT },
- { "playlist-count", mp_property_playlist_count, CONF_TYPE_INT },
+ M_PROPERTY_ALIAS("playlist-count", "playlist/count"),
// Audio
{ "volume", mp_property_volume, CONF_TYPE_FLOAT,