summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--DOCS/man/en/options.rst4
-rw-r--r--cfg-mplayer.h1
-rw-r--r--mplayer.c57
-rw-r--r--options.h1
4 files changed, 41 insertions, 22 deletions
diff --git a/DOCS/man/en/options.rst b/DOCS/man/en/options.rst
index 453c8e052f..875b9c4b4a 100644
--- a/DOCS/man/en/options.rst
+++ b/DOCS/man/en/options.rst
@@ -1354,6 +1354,10 @@
Disable property expansion and special handling of ``$`` for the rest
of the string.
+--status-msg=<string>
+ Print out a custom string during playback instead of the standard status
+ line. Expands properties. See ``--playing-msg``.
+
--playlist=<filename>
Play files according to a playlist file (ASX, Winamp, SMIL, or
one-file-per-line format).
diff --git a/cfg-mplayer.h b/cfg-mplayer.h
index db99b1da28..daf3c5d42e 100644
--- a/cfg-mplayer.h
+++ b/cfg-mplayer.h
@@ -727,6 +727,7 @@ const m_option_t mplayer_opts[]={
OPT_STRING("term-osd-esc", term_osd_esc, 0, OPTDEF_STR("\x1b[A\r\x1b[K")),
OPT_STRING("playing-msg", playing_msg, 0),
+ OPT_STRING("status-msg", status_msg, 0),
{"slave-broken", &slave_mode, CONF_TYPE_FLAG,CONF_GLOBAL , 0, 1, NULL},
OPT_MAKE_FLAGS("idle", player_idle_mode, CONF_GLOBAL),
diff --git a/mplayer.c b/mplayer.c
index ab78276a87..52316a8aa8 100644
--- a/mplayer.c
+++ b/mplayer.c
@@ -1042,6 +1042,30 @@ static void sadd_percentage(char *buf, int len, int percent) {
saddf(buf, len, " (%d%%)", percent);
}
+static int get_term_width(void)
+{
+ get_screen_size();
+ int width = screen_width > 0 ? screen_width : 80;
+#if defined(__MINGW32__) || defined(__CYGWIN__)
+ /* Windows command line is broken (MinGW's rxvt works, but we
+ * should not depend on that). */
+ width--;
+#endif
+ return width;
+}
+
+static void write_status_line(struct MPContext *mpctx, const char *line)
+{
+ if (erase_to_end_of_line) {
+ mp_msg(MSGT_STATUSLINE, MSGL_STATUS,
+ "%s%s\r", line, erase_to_end_of_line);
+ } else {
+ int pos = strlen(line);
+ int width = get_term_width() - pos;
+ mp_msg(MSGT_STATUSLINE, MSGL_STATUS, "%s%*s\r", line, width, "");
+ }
+}
+
static void print_status(struct MPContext *mpctx, double a_pos, bool at_frame)
{
struct MPOpts *opts = &mpctx->opts;
@@ -1065,19 +1089,16 @@ static void print_status(struct MPContext *mpctx, double a_pos, bool at_frame)
if (opts->quiet)
return;
- int width;
- char *line;
- get_screen_size();
- if (screen_width > 0)
- width = screen_width;
- else
- width = 80;
-#if defined(__MINGW32__) || defined(__CYGWIN__)
- /* Windows command line is broken (MinGW's rxvt works, but we
- * should not depend on that). */
- width--;
-#endif
- line = malloc(width + 1); // one additional char for the terminating null
+ if (opts->status_msg) {
+ char *r = mp_property_expand_string(mpctx, opts->status_msg);
+ write_status_line(mpctx, r);
+ talloc_free(r);
+ return;
+ }
+
+ // one additional char for the terminating null
+ int width = get_term_width() + 1;
+ char *line = malloc(width);
line[0] = '\0';
// Playback status
@@ -1156,15 +1177,7 @@ static void print_status(struct MPContext *mpctx, double a_pos, bool at_frame)
#endif
// end
- if (erase_to_end_of_line) {
- mp_msg(MSGT_STATUSLINE, MSGL_STATUS,
- "%s%s\r", line, erase_to_end_of_line);
- } else {
- int pos = strlen(line);
- memset(&line[pos], ' ', width - pos);
- line[width] = 0;
- mp_msg(MSGT_STATUSLINE, MSGL_STATUS, "%s\r", line);
- }
+ write_status_line(mpctx, line);
free(line);
}
diff --git a/options.h b/options.h
index 1297b67b04..5c8f8c0aab 100644
--- a/options.h
+++ b/options.h
@@ -64,6 +64,7 @@ typedef struct MPOpts {
int term_osd;
char *term_osd_esc;
char *playing_msg;
+ char *status_msg;
int player_idle_mode;
int consolecontrols;
int doubleclick_time;