From d26803cba00f9ecfe7c1c0914f133e775638183b Mon Sep 17 00:00:00 2001 From: wm4 Date: Fri, 22 May 2015 20:02:47 +0200 Subject: [PATCH] command: deprecate the "length" property It collides with the --length option. --- DOCS/interface-changes.rst | 1 + DOCS/man/input.rst | 7 +++++-- player/command.c | 8 ++++---- player/lua/osc.lua | 10 +++++----- 4 files changed, 15 insertions(+), 11 deletions(-) diff --git a/DOCS/interface-changes.rst b/DOCS/interface-changes.rst index b91cfb8f00..cae71465e2 100644 --- a/DOCS/interface-changes.rst +++ b/DOCS/interface-changes.rst @@ -20,6 +20,7 @@ Interface changes :: --- mpv 0.10.0 will be released --- + - deprecate "length" property, replaced with "duration" - change volume property: - the value 100 is now always "unchanged volume" - with softvol, the range is 0 to --softvol-max, without it is 0-100 diff --git a/DOCS/man/input.rst b/DOCS/man/input.rst index d264b2703d..09cbe8b718 100644 --- a/DOCS/man/input.rst +++ b/DOCS/man/input.rst @@ -842,11 +842,14 @@ Property list ``stream-end`` Raw end position in bytes in source stream. -``length`` - Length of the current file in seconds. If the length is unknown, the +``duration`` + Duration of the current file in seconds. If the duration is unknown, the property is unavailable. Note that the file duration is not always exactly known, so this is an estimate. + This replaces the ``length`` property, which was deprecated after the + mpv 0.9 release. (The semantics are the same.) + ``avsync`` Last A/V synchronization difference. Unavailable if audio or video is disabled. diff --git a/player/command.c b/player/command.c index e849275547..168c1f8394 100644 --- a/player/command.c +++ b/player/command.c @@ -487,9 +487,8 @@ static int property_time(int action, void *arg, double time) return M_PROPERTY_NOT_IMPLEMENTED; } -/// Media length in seconds (RO) -static int mp_property_length(void *ctx, struct m_property *prop, - int action, void *arg) +static int mp_property_duration(void *ctx, struct m_property *prop, + int action, void *arg) { MPContext *mpctx = ctx; double len = get_time_length(mpctx); @@ -3287,7 +3286,8 @@ static const struct m_property mp_properties[] = { {"file-format", mp_property_file_format}, {"stream-pos", mp_property_stream_pos}, {"stream-end", mp_property_stream_end}, - {"length", mp_property_length}, + {"duration", mp_property_duration}, + M_PROPERTY_DEPRECATED_ALIAS("length", "duration"), {"avsync", mp_property_avsync}, {"total-avsync-change", mp_property_total_avsync_change}, {"drop-frame-count", mp_property_drop_frame_cnt}, diff --git a/player/lua/osc.lua b/player/lua/osc.lua index 4aade7c4b6..2064ba7e47 100644 --- a/player/lua/osc.lua +++ b/player/lua/osc.lua @@ -1482,7 +1482,7 @@ function osc_init() ne.enabled = not (mp.get_property("percent-pos") == nil) ne.slider.markerF = function () - local duration = mp.get_property_number("length", nil) + local duration = mp.get_property_number("duration", nil) if not (duration == nil) then local chapters = mp.get_property_native("chapter-list", {}) local markers = {} @@ -1497,7 +1497,7 @@ function osc_init() ne.slider.posF = function () return mp.get_property_number("percent-pos", nil) end ne.slider.tooltipF = function (pos) - local duration = mp.get_property_number("length", nil) + local duration = mp.get_property_number("duration", nil) if not ((duration == nil) or (pos == nil)) then possec = duration * (pos / 100) return mp.format_time(possec) @@ -1542,8 +1542,8 @@ function osc_init() -- tc_right (total/remaining time) ne = new_element("tc_right", "button") - ne.visible = (not (mp.get_property("length") == nil)) - and (mp.get_property_number("length") > 0) + ne.visible = (not (mp.get_property("duration") == nil)) + and (mp.get_property_number("duration") > 0) ne.content = function () if (state.rightTC_trem) then if state.tc_ms then @@ -1555,7 +1555,7 @@ function osc_init() if state.tc_ms then return (mp.get_property_osd("length/full")) else - return (mp.get_property_osd("length")) + return (mp.get_property_osd("duration")) end end end