From ea2b19f64673a975a6bafe3292d26eab51142a5f Mon Sep 17 00:00:00 2001 From: wm4 Date: Thu, 18 Sep 2014 01:19:27 +0200 Subject: player: allow overriding OSD message for all OSD levels Until now, you could override only level 3 with --osd-status-msg. Extend this, add add --osd-msg1 to --osd-msg3 (one for each OSD level). OSD level 0 always means disable OSD, so that isn't included. --osd-msg3 corresponds to --osd-status-msg, but they're not exactly the same. To allow more customization, --osd-msgN do not include the OSD symbol. The symbol can be manually added with "${osd-sym-cc}". We keep the "old" option for some short-term compatibility. --osd-msg1 should be particularly useful; for example you could do: --osd-msg1='${?pause==yes:${osd-sym-cc}}' to display a "paused" symbol when paused, and nothing during normal playback. (Although admittedly, the syntax is quite a bit of work.) --- player/osd.c | 43 ++++++++++++++++++++++++++----------------- 1 file changed, 26 insertions(+), 17 deletions(-) (limited to 'player/osd.c') 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); -- cgit v1.2.3