diff options
-rw-r--r-- | DOCS/man/options.rst | 24 | ||||
-rw-r--r-- | options/options.c | 3 | ||||
-rw-r--r-- | options/options.h | 1 | ||||
-rw-r--r-- | player/osd.c | 43 |
4 files changed, 54 insertions, 17 deletions
diff --git a/DOCS/man/options.rst b/DOCS/man/options.rst index 2a1bf8ded1..a0e5f59a41 100644 --- a/DOCS/man/options.rst +++ b/DOCS/man/options.rst @@ -2197,6 +2197,26 @@ OSD Default: 45. +``--osd-msg1=<string>`` + Show this string as message on OSD with OSD level 1 (visible by default). + The message will be visible by default, and as long no other message + covers it, and the OSD level isn't changed (see ``--osd-level``). + Expands properties; see `Property Expansion`_. + +``--osd-msg2=<string>`` + Similar as ``--osd-msg1``, but for OSD level 2. If this is an empty string + (default), then the playback time is shown. + +``--osd-msg3=<string>`` + Similar as ``--osd-msg1``, but for OSD level 3. If this is an empty string + (default), then the playback time, duration, and some more information is + shown. + + This is also used for the ``show_progress`` command (by default mapped to + ``P``), or in some non-default cases when seeking. + + ``--osd-status-msg`` is a legacy equivalent (but with a minor difference). + ``--osd-status-msg=<string>`` Show a custom string during playback instead of the standard status text. This overrides the status text used for ``--osd-level=3``, when using the @@ -2204,6 +2224,10 @@ OSD non-default cases when seeking. Expands properties. See `Property Expansion`_. + This option has been replaced with ``--osd-msg3``. The only difference is + that this option implicitly includes ``${osd-sym-cc}``. This option is + ignored if ``--osd-msg3`` is not empty. + ``--osd-playing-msg=<string>`` Show a message on OSD when playback starts. The string is expanded for properties, e.g. ``--osd-playing-msg='file: ${filename}'`` will show the diff --git a/options/options.c b/options/options.c index a57b5fffb4..e245434052 100644 --- a/options/options.c +++ b/options/options.c @@ -521,6 +521,9 @@ const m_option_t mp_opts[] = { OPT_STRING("osd-playing-msg", osd_playing_msg, 0), OPT_STRING("term-status-msg", status_msg, 0), OPT_STRING("osd-status-msg", osd_status_msg, 0), + OPT_STRING("osd-msg1", osd_msg[0], 0), + OPT_STRING("osd-msg2", osd_msg[1], 0), + OPT_STRING("osd-msg3", osd_msg[2], 0), OPT_FLAG("idle", player_idle_mode, M_OPT_GLOBAL), OPT_FLAG("input-terminal", consolecontrols, CONF_GLOBAL), diff --git a/options/options.h b/options/options.h index 967982ea5c..aeb404ecfe 100644 --- a/options/options.h +++ b/options/options.h @@ -148,6 +148,7 @@ typedef struct MPOpts { char *osd_playing_msg; char *status_msg; char *osd_status_msg; + char *osd_msg[3]; char *heartbeat_cmd; float heartbeat_interval; int player_idle_mode; diff --git a/player/osd.c b/player/osd.c index 04b21a22f2..810e3f5514 100644 --- a/player/osd.c +++ b/player/osd.c @@ -458,23 +458,34 @@ void get_current_osd_sym(struct MPContext *mpctx, char *buf, size_t buf_size) osd_get_function_sym(buf, buf_size, sym); } -static void sadd_osd_status(char **buffer, struct MPContext *mpctx, bool full) +static void sadd_osd_status(char **buffer, struct MPContext *mpctx, int level) { - bool fractions = mpctx->opts->osd_fractions; - char sym[10]; - get_current_osd_sym(mpctx, sym, sizeof(sym)); - saddf(buffer, "%s ", sym); - char *custom_msg = mpctx->opts->osd_status_msg; - if (custom_msg && full) { - char *text = mp_property_expand_escaped_string(mpctx, custom_msg); + assert(level >= 0 && level <= 3); + if (level == 0) + return; + char *msg = mpctx->opts->osd_msg[level - 1]; + + if (msg && msg[0]) { + char *text = mp_property_expand_escaped_string(mpctx, msg); *buffer = talloc_strdup_append(*buffer, text); talloc_free(text); - } else { - sadd_hhmmssff(buffer, get_playback_time(mpctx), fractions); - if (full) { - saddf(buffer, " / "); - sadd_hhmmssff(buffer, get_time_length(mpctx), fractions); - sadd_percentage(buffer, get_percent_pos(mpctx)); + } else if (level >= 2) { + bool fractions = mpctx->opts->osd_fractions; + char sym[10]; + get_current_osd_sym(mpctx, sym, sizeof(sym)); + saddf(buffer, "%s ", sym); + char *custom_msg = mpctx->opts->osd_status_msg; + if (custom_msg && level == 3) { + char *text = mp_property_expand_escaped_string(mpctx, custom_msg); + *buffer = talloc_strdup_append(*buffer, text); + talloc_free(text); + } else { + sadd_hhmmssff(buffer, get_playback_time(mpctx), fractions); + if (level == 3) { + saddf(buffer, " / "); + sadd_hhmmssff(buffer, get_time_length(mpctx), fractions); + sadd_percentage(buffer, get_percent_pos(mpctx)); + } } } } @@ -547,9 +558,7 @@ void update_osd_msg(struct MPContext *mpctx) // clear, or if OSD level demands it, show the status char *text = NULL; - - if (osd_level >= 2) - sadd_osd_status(&text, mpctx, osd_level == 3); + sadd_osd_status(&text, mpctx, osd_level); osd_set_text(osd, OSDTYPE_OSD, text); talloc_free(text); |