summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLaserEyess <lasereyess@lasereyess.net>2020-04-12 18:18:04 -0400
committerwm4 <1387750+wm4@users.noreply.github.com>2020-04-13 01:04:32 +0200
commite796fe4bfc46282965e9e3d09519bf4d3306bb42 (patch)
tree1fcdb56026dfc10af0740c518b4d0465d00f2498
parent6e82f36f9230d242cc9b54e8638c743235516b1a (diff)
downloadmpv-e796fe4bfc46282965e9e3d09519bf4d3306bb42.tar.bz2
mpv-e796fe4bfc46282965e9e3d09519bf4d3306bb42.tar.xz
command: print edition title to OSD when cycling
Edition title is already exposed in demux_edition, it was just never added to the display. If no edition title exists it will fall back to the edition number.
-rw-r--r--player/command.c31
1 files changed, 26 insertions, 5 deletions
diff --git a/player/command.c b/player/command.c
index ff4d95ccd8..8c383a930b 100644
--- a/player/command.c
+++ b/player/command.c
@@ -1042,10 +1042,18 @@ static int mp_property_edition(void *ctx, struct m_property *prop,
{
MPContext *mpctx = ctx;
struct demuxer *demuxer = mpctx->demuxer;
+ char *name = NULL;
- if (action == M_PROPERTY_GET_CONSTRICTED_TYPE && demuxer) {
- if (demuxer->num_editions <= 1)
- return M_PROPERTY_UNAVAILABLE;
+ if (!demuxer)
+ return mp_property_generic_option(mpctx, prop, action, arg);
+
+ int ed = demuxer->edition;
+
+ if (demuxer->num_editions <= 1)
+ return M_PROPERTY_UNAVAILABLE;
+
+ switch (action) {
+ case M_PROPERTY_GET_CONSTRICTED_TYPE: {
*(struct m_option *)arg = (struct m_option){
.type = CONF_TYPE_INT,
.min = 0,
@@ -1053,8 +1061,20 @@ static int mp_property_edition(void *ctx, struct m_property *prop,
};
return M_PROPERTY_OK;
}
-
- return mp_property_generic_option(mpctx, prop, action, arg);
+ case M_PROPERTY_PRINT: {
+ if (ed < 0)
+ return M_PROPERTY_UNAVAILABLE;
+ name = mp_tags_get_str(demuxer->editions[ed].metadata, "title");
+ if (name) {
+ *(char **) arg = talloc_strdup(NULL, name);
+ } else {
+ *(char **) arg = talloc_asprintf(NULL, "%d", ed + 1);
+ }
+ return M_PROPERTY_OK;
+ }
+ default:
+ return mp_property_generic_option(mpctx, prop, action, arg);
+ }
}
static int get_edition_entry(int item, int action, void *arg, void *ctx)
@@ -3734,6 +3754,7 @@ static const struct property_osd_display {
{"hr-seek", "hr-seek"},
{"speed", "Speed"},
{"clock", "Clock"},
+ {"edition", "Edition"},
// audio
{"volume", "Volume",
.msg = "Volume: ${?volume:${volume}% ${?mute==yes:(Muted)}}${!volume:${volume}}",