diff --git a/DOCS/interface-changes.rst b/DOCS/interface-changes.rst index 59e00130c4..e3f197ab33 100644 --- a/DOCS/interface-changes.rst +++ b/DOCS/interface-changes.rst @@ -62,6 +62,11 @@ Interface changes - remove old Apple Remote support, including --input-appleremote - add MediaPlayer support and remove the old Media Key event tap on macOS. this possibly also re-adds the Apple Remote support + - the "edition" property now strictly returns the value of the option, + instead of the runtime value. The new "current-edition" property needs to + be queried to read the runtime-chosen edition. This is a breaking change + for any users which expected "edition" to return the runtime-chosen + edition at default settings (--edition=auto). --- mpv 0.30.0 --- - add `--d3d11-output-format` to enable explicit selection of a D3D11 swap chain format. diff --git a/DOCS/man/input.rst b/DOCS/man/input.rst index 3d9263ee3f..fbfede5869 100644 --- a/DOCS/man/input.rst +++ b/DOCS/man/input.rst @@ -1525,6 +1525,18 @@ Property list Current MKV edition number. Setting this property to a different value will restart playback. The number of the first edition is 0. + Before mpv 0.31.0, this showed the actual edition selected at runtime, if + you didn't set the option or property manually. With mpv 0.31.0 and later, + this strictly returns the user-set option or property value, and the + ``current-edition`` property was added to return the runtime selected + edition (this matters with ``--edition=auto``, the default). + +``current-edition`` + Currently selected edition. This property is unavailable if no file is + loaded, or the file has no editions. (Matroska files make a difference + between having no editions and a single edition, which will be reflected by + the property, although in practice it does not matter.) + ``chapters`` Number of chapters. @@ -2714,11 +2726,6 @@ caveats with some properties (due to historical reasons): *iff* video (for ``vf``) or audio (for ``af``) was active. If playback was not active, the behavior was the same as the current behavior. -``edition`` - While a file is loaded, the property will always return the effective - edition, and setting the ``auto`` value will show somewhat strange behavior - (the property eventually switching to whatever is the default edition). - ``playlist`` The property is read-only and returns the current internal playlist. The option is for loading playlist during command line parsing. For client API diff --git a/player/command.c b/player/command.c index 1a7d5a6d20..901326b498 100644 --- a/player/command.c +++ b/player/command.c @@ -1040,24 +1040,32 @@ static int mp_property_list_chapters(void *ctx, struct m_property *prop, return m_property_read_list(action, arg, count, get_chapter_entry, mpctx); } +static int mp_property_current_edition(void *ctx, struct m_property *prop, + int action, void *arg) +{ + MPContext *mpctx = ctx; + struct demuxer *demuxer = mpctx->demuxer; + if (!demuxer || demuxer->num_editions <= 0) + return M_PROPERTY_UNAVAILABLE; + return m_property_int_ro(action, arg, demuxer->edition); +} + static int mp_property_edition(void *ctx, struct m_property *prop, int action, void *arg) { MPContext *mpctx = ctx; struct demuxer *demuxer = mpctx->demuxer; - if (!mpctx->playback_initialized || !demuxer || demuxer->num_editions <= 0) - return mp_property_generic_option(mpctx, prop, action, arg); - switch (action) { - case M_PROPERTY_GET: - *(int *)arg = demuxer->edition; + if (action == M_PROPERTY_GET_CONSTRICTED_TYPE && demuxer) { + *(struct m_option *)arg = (struct m_option){ + .type = CONF_TYPE_INT, + .flags = M_OPT_RANGE, + .min = 0, + .max = demuxer->num_editions - 1, + }; return M_PROPERTY_OK; - case M_PROPERTY_GET_CONSTRICTED_TYPE: { - int r = mp_property_generic_option(mpctx, prop, M_PROPERTY_GET_TYPE, arg); - ((struct m_option *)arg)->max = demuxer->num_editions - 1; - return r; - } } + return mp_property_generic_option(mpctx, prop, action, arg); } @@ -3273,6 +3281,7 @@ static const struct m_property mp_properties_base[] = { {"playback-time", mp_property_playback_time}, {"chapter", mp_property_chapter}, {"edition", mp_property_edition}, + {"current-edition", mp_property_current_edition}, {"chapters", mp_property_chapters}, {"editions", mp_property_editions}, {"metadata", mp_property_metadata},