[MPlayer-dev-eng] [Patch] info command: show progress bar and elapsed/total time

Hugo Chargois hugo.chargois at free.fr
Wed Mar 24 06:19:40 CET 2010


Hi,

The command shows the progress bar and time elapsed/total time.
I missed it a lot because there were only two ways to know where you
were in a movie (well, to my knowledge at least): either seek back
then forward (or the other way round) to catch a glance at the
progress bar, or press 'o' to go through osd modes, one of them
displaying the elapsed/total info.
This is of course not optimal at all, the seek method is very
disruptive, and the other one requires to press o multiple times.
Moreover, they don't show the same info, and I think both the progress
bar and times are useful.
With this patch a unique command shows both progress bar and times.

I called it 'info' and not 'progression' because maybe it could evolve
into something that would show some other useful info (filename,
etc.), and because 'p' is bound to pause and 'i' to nothing by
default, and I like easy to remember bindings :) But maybe you could
find a more appropriate name.

This is my first time playing with mplayer's code so maybe there are
more elegant ways to do that, but that works like a charm with me.
I hope you find it useful.

Hugo.

Index: input/input.c
===================================================================
--- input/input.c	(revision 30955)
+++ input/input.c	(working copy)
@@ -94,6 +94,7 @@
   { MP_CMD_OSD, "osd",0, { {MP_CMD_ARG_INT,{-1}}, {-1,{0}} } },
   { MP_CMD_OSD_SHOW_TEXT, "osd_show_text", 1, { {MP_CMD_ARG_STRING,
{0}}, {MP_CMD_ARG_INT,{-1}}, {MP_CMD_ARG_INT,{0}}, {-1,{0}} } },
   { MP_CMD_OSD_SHOW_PROPERTY_TEXT, "osd_show_property_text",1, {
{MP_CMD_ARG_STRING, {0}}, {MP_CMD_ARG_INT,{-1}}, {MP_CMD_ARG_INT,{0}},
{-1,{0}} } },
+  { MP_CMD_INFO, "info", 0, { {-1,{0}} } },
   { MP_CMD_VOLUME, "volume", 1, { { MP_CMD_ARG_FLOAT,{0} },
{MP_CMD_ARG_INT,{0}}, {-1,{0}} } },
   { MP_CMD_BALANCE, "balance", 1, { { MP_CMD_ARG_FLOAT,{0} },
{MP_CMD_ARG_INT,{0}}, {-1,{0}} } },
   { MP_CMD_MIXER_USEMASTER, "use_master", 0, { {-1,{0}} } },
Index: input/input.h
===================================================================
--- input/input.h	(revision 30955)
+++ input/input.h	(working copy)
@@ -131,6 +131,7 @@
   MP_CMD_ASS_USE_MARGINS,
   MP_CMD_SWITCH_TITLE,
   MP_CMD_STOP,
+  MP_CMD_INFO,

   /// DVDNAV commands
   MP_CMD_DVDNAV_UP = 1000,
Index: command.c
===================================================================
--- command.c	(revision 30955)
+++ command.c	(working copy)
@@ -2763,6 +2763,17 @@
 	    brk_cmd = 1;
 	    break;

+	case MP_CMD_INFO:{
+		    int len = demuxer_get_time_length(mpctx->demuxer);
+		    int pts = demuxer_get_current_time(mpctx->demuxer);
+		    set_osd_bar(0,"Position",0,100,demuxer_get_percent_pos(mpctx->demuxer));
+		    set_osd_msg(OSD_MSG_TEXT, 1, osd_duration,
+			    "%c %02d:%02d:%02d / %02d:%02d:%02d",
+	                     mpctx->osd_function,pts/3600,(pts/60)%60,pts%60,
+                             len/3600,(len/60)%60,len%60);
+	    }
+	    break;
+
 #ifdef CONFIG_RADIO
 	case MP_CMD_RADIO_STEP_CHANNEL:
 	    if (mpctx->demuxer->stream->type == STREAMTYPE_RADIO) {
Index: etc/input.conf
===================================================================
--- etc/input.conf	(revision 30955)
+++ etc/input.conf	(working copy)
@@ -40,6 +40,7 @@
 INS alt_src_step 1
 DEL alt_src_step -1
 o osd
+i info
 I osd_show_property_text "${filename}"     # display filename in osd
 z sub_delay -0.1        # subtract 100 ms delay from subs
 x sub_delay +0.1        # add



More information about the MPlayer-dev-eng mailing list