summaryrefslogtreecommitdiffstats
path: root/player
diff options
context:
space:
mode:
authorxylosper <darklin20@gmail.com>2014-03-15 16:25:23 +0900
committerwm4 <wm4@nowhere>2014-03-15 18:42:10 +0100
commit746666f0962b0ee332584c4d7aa2f8f9d453db1d (patch)
tree9b86ae28b7fd9d44866d5e7cec0a106210abf753 /player
parent9e4014d8767b3802563185f6a846dc356274d9b3 (diff)
downloadmpv-746666f0962b0ee332584c4d7aa2f8f9d453db1d.tar.bz2
mpv-746666f0962b0ee332584c4d7aa2f8f9d453db1d.tar.xz
command: add new property 'title'
This commit adds new property 'title' which indicates current playing title of disc. This property is useful when using a stream whose title can be changed during playback, e.g., dvdnav.
Diffstat (limited to 'player')
-rw-r--r--player/command.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/player/command.c b/player/command.c
index 843042165a..4325d78a5a 100644
--- a/player/command.c
+++ b/player/command.c
@@ -436,6 +436,25 @@ static int mp_property_playtime_remaining(m_option_t *prop, int action,
return property_time(prop, action, arg, remaining / speed);
}
+/// Current title (RO)
+static int mp_property_title(m_option_t *prop, int action, void *arg,
+ MPContext *mpctx)
+{
+ struct demuxer *demuxer = mpctx->master_demuxer;
+ if (!demuxer || !demuxer->stream)
+ return M_PROPERTY_UNAVAILABLE;
+ struct stream *stream = demuxer->stream;
+ unsigned int title = -1;
+ switch (action) {
+ case M_PROPERTY_GET:
+ if (stream_control(stream, STREAM_CTRL_GET_CURRENT_TITLE, &title) <= 0)
+ return M_PROPERTY_UNAVAILABLE;
+ return m_property_int_ro(prop, action, arg, title);
+ default:
+ return M_PROPERTY_NOT_IMPLEMENTED;
+ }
+}
+
/// Current chapter (RW)
static int mp_property_chapter(m_option_t *prop, int action, void *arg,
MPContext *mpctx)
@@ -2099,6 +2118,7 @@ static const m_option_t mp_properties[] = {
M_OPT_MIN, 0, 0, NULL },
{ "time-remaining", mp_property_remaining, CONF_TYPE_TIME },
{ "playtime-remaining", mp_property_playtime_remaining, CONF_TYPE_TIME },
+ { "title", mp_property_title, CONF_TYPE_INT, M_OPT_MIN, -1, 0, NULL },
{ "chapter", mp_property_chapter, CONF_TYPE_INT,
M_OPT_MIN, -1, 0, NULL },
M_OPTION_PROPERTY_CUSTOM("edition", mp_property_edition),