summaryrefslogtreecommitdiffstats
path: root/player/command.c
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2014-02-15 16:55:40 +0100
committerwm4 <wm4@nowhere>2014-02-16 03:51:02 +0100
commit98349fa910be0d9b4f36d53566dbcc93dd73cfce (patch)
tree500b0d07770bba264221280dc434800c1e31aa33 /player/command.c
parente41d27c7dbc05d4df3107cdea3186e480a473210 (diff)
downloadmpv-98349fa910be0d9b4f36d53566dbcc93dd73cfce.tar.bz2
mpv-98349fa910be0d9b4f36d53566dbcc93dd73cfce.tar.xz
command: export chapter list as properties
Diffstat (limited to 'player/command.c')
-rw-r--r--player/command.c24
1 files changed, 20 insertions, 4 deletions
diff --git a/player/command.c b/player/command.c
index 068bf7816d..71b0fa1e60 100644
--- a/player/command.c
+++ b/player/command.c
@@ -469,11 +469,27 @@ static int mp_property_chapter(m_option_t *prop, int action, void *arg,
return M_PROPERTY_NOT_IMPLEMENTED;
}
+static int get_chapter_entry(int item, int action, void *arg, void *ctx)
+{
+ struct MPContext *mpctx = ctx;
+ char *name = chapter_name(mpctx, item);
+ double time = chapter_start_time(mpctx, item);
+ struct m_sub_property props[] = {
+ {"title", SUB_PROP_STR(name)},
+ {"time", CONF_TYPE_TIME, {.time = time}},
+ {0}
+ };
+
+ int r = m_property_read_sub(props, action, arg);
+ talloc_free(name);
+ return r;
+}
+
static int mp_property_list_chapters(m_option_t *prop, int action, void *arg,
MPContext *mpctx)
{
- if (action == M_PROPERTY_GET) {
- int count = get_chapter_count(mpctx);
+ int count = get_chapter_count(mpctx);
+ if (action == M_PROPERTY_PRINT) {
int cur = mpctx->num_sources ? get_current_chapter(mpctx) : -1;
char *res = NULL;
int n;
@@ -498,7 +514,7 @@ static int mp_property_list_chapters(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, count, get_chapter_entry, mpctx);
}
static int mp_property_edition(m_option_t *prop, int action, void *arg,
@@ -1987,7 +2003,7 @@ static const m_option_t mp_properties[] = {
{ "clock", mp_property_clock, CONF_TYPE_STRING,
0, 0, 0, NULL },
- { "chapter-list", mp_property_list_chapters, CONF_TYPE_STRING },
+ M_PROPERTY("chapter-list", mp_property_list_chapters),
M_PROPERTY("track-list", property_list_tracks),
M_PROPERTY("playlist", mp_property_playlist),