1
0
mirror of https://github.com/mpv-player/mpv synced 2025-02-23 08:26:56 +00:00

player: add --osd-playing-msg option

This commit is contained in:
wm4 2014-09-02 00:09:03 +02:00
parent 291d986810
commit 2da246b9f7
4 changed files with 22 additions and 5 deletions

View File

@ -2190,6 +2190,13 @@ OSD
non-default cases when seeking. Expands properties. See
`Property Expansion`_.
``--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
message ``file:`` followed by a space and the currently played filename.
See `Property Expansion`_.
``--osd-bar-align-x=<-1-1>``
Position of the OSD bar. -1 is far left, 0 is centered, 1 is far right.
Fractional values (like 0.5) are allowed.

View File

@ -515,6 +515,7 @@ const m_option_t mp_opts[] = {
OPT_STRING("term-osd-bar-chars", term_osd_bar_chars, 0),
OPT_STRING("term-playing-msg", playing_msg, 0),
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),

View File

@ -143,6 +143,7 @@ typedef struct MPOpts {
int term_osd_bar;
char *term_osd_bar_chars;
char *playing_msg;
char *osd_playing_msg;
char *status_msg;
char *osd_status_msg;
char *heartbeat_cmd;

View File

@ -871,11 +871,19 @@ void run_playloop(struct MPContext *mpctx)
mpctx->hrseek_active = false;
mp_notify(mpctx, MPV_EVENT_PLAYBACK_RESTART, NULL);
mpctx->restart_complete = true;
if (opts->playing_msg && !mpctx->playing_msg_shown) {
char *msg =
mp_property_expand_escaped_string(mpctx, opts->playing_msg);
MP_INFO(mpctx, "%s\n", msg);
talloc_free(msg);
if (!mpctx->playing_msg_shown) {
if (opts->playing_msg) {
char *msg =
mp_property_expand_escaped_string(mpctx, opts->playing_msg);
MP_INFO(mpctx, "%s\n", msg);
talloc_free(msg);
}
if (opts->osd_playing_msg) {
char *msg =
mp_property_expand_escaped_string(mpctx, opts->osd_playing_msg);
set_osd_msg(mpctx, 1, opts->osd_duration, "%s", msg);
talloc_free(msg);
}
}
mpctx->playing_msg_shown = true;
}