summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--DOCS/man/en/input.rst12
-rw-r--r--player/command.c24
2 files changed, 32 insertions, 4 deletions
diff --git a/DOCS/man/en/input.rst b/DOCS/man/en/input.rst
index e705763d85..43cea2fcd9 100644
--- a/DOCS/man/en/input.rst
+++ b/DOCS/man/en/input.rst
@@ -925,6 +925,18 @@ an option at runtime.
List of chapters, current entry marked. Currently, the raw property value
is useless.
+ This has a number of sub-properties. Replace ``N`` with the 0-based chapter
+ index.
+
+ ``chapter-list/count``
+ Number of chapters.
+
+ ``chapter-list/N/title``
+ Chapter title as stored in the file. Not always available.
+
+ ``chapter-list/N/time``
+ Chapter start time in seconds as float.
+
``quvi-format`` (RW)
See ``--quvi-format``. Cycling this property (``cycle``) will attempt to
cycle through known format, although currently this feature doesn't work
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),