[MPlayer-dev-eng] Re: [PATCH] *UPDATED* percentage for progress bar and new osdlevel showing total time

seru seru at gmx.net
Tue Dec 24 15:23:35 CET 2002


El lun, 23 de dic de 2002, a las 07:40:15 +0100, seru dijo:
> This patch adds a new osdlevel (3) which shows progress bar, percentage and total time.
> Also percentage is added to existing osdlevel 2.
This patch is horrible :( 

Here's a new patch one that works per-fect! It shows not just the progressbar, but progressbar /and/ percentage for osd levels 2 and 3, and inaddition it adds a new osd level (3) which also shows total time.

> 
> It works for all formats with demux_control support (so asf, avi, mpg for now). 
> I'm going to have a look at other formats now :)

> [...]
-------------- next part --------------
Index: mplayer.c
===================================================================
RCS file: /cvsroot/mplayer/main/mplayer.c,v
retrieving revision 1.631
diff -u -r1.631 mplayer.c
--- mplayer.c	23 Dec 2002 01:54:58 -0000	1.631
+++ mplayer.c	24 Dec 2002 14:39:42 -0000
@@ -178,6 +178,7 @@
 float playback_speed=1.0;
 
 int use_gui=0;
+#define MAX_OSD_LEVEL 3
 
 int osd_level=1;
 int osd_level_saved=-1;
@@ -577,6 +578,7 @@
 int osd_show_sub_visibility = 0;
 int osd_show_sub_alignment = 0;
 int osd_show_vobsub_changed = 0;
+int osd_show_percentage = 0;
 
 int rtc_fd=-1;
 
@@ -2103,6 +2105,7 @@
     switch(cmd->id) {
     case MP_CMD_SEEK : {
       int v,abs;
+      osd_show_percentage = 25;
       if ( stream->type == STREAMTYPE_STREAM ) break;
       v = cmd->args[0].v.i;
       abs = (cmd->nargs > 1) ? cmd->args[1].v.i : 0;
@@ -2200,9 +2203,9 @@
       if(sh_video) {
 	int v = cmd->args[0].v.i;
 	if(v < 0)
-	  osd_level=(osd_level+1)%3;
+	  osd_level=(osd_level+1)%(MAX_OSD_LEVEL+1);
 	else
-	  osd_level= v > 2 ? 2 : v;
+	  osd_level= v > MAX_OSD_LEVEL ? MAX_OSD_LEVEL : v;
       } break;
     case MP_CMD_VOLUME :  {
       int v = cmd->args[0].v.i;
@@ -2941,9 +2944,23 @@
       if (osd_show_av_delay) {
 	  sprintf(osd_text_tmp, "A-V delay: %d ms",(int)(audio_delay*1000));
 	  osd_show_av_delay--;
-      } else if(osd_level>=2)
-          sprintf(osd_text_tmp,"%c %02d:%02d:%02d",osd_function,pts/3600,(pts/60)%60,pts%60);
-      else osd_text_tmp[0]=0;
+      } else if(osd_level>=2) {
+          int len = demuxer_get_time_length(demuxer);
+          int percentage = -1;
+          char percentage_text[50];
+          if (osd_show_percentage) {
+            percentage = demuxer_get_percent_pos(demuxer);
+            osd_show_percentage--;
+          }
+          if (percentage >= 0)
+            sprintf(percentage_text, " (%d%%)", percentage);
+          else
+            sprintf(percentage_text, "");
+          if (osd_level == 3) 
+            sprintf(osd_text_tmp,"%c %02d:%02d:%02d / %02d:%02d:%02d%s",osd_function,pts/3600,(pts/60)%60,pts%60,len/3600,(len/60)%60,len%60,percentage_text);
+          else
+            sprintf(osd_text_tmp,"%c %02d:%02d:%02d%s",osd_function,pts/3600,(pts/60)%60,pts%60,percentage_text);
+      } else osd_text_tmp[0]=0;
       
       if(strcmp(vo_osd_text, osd_text_tmp)) {
 	      strcpy(vo_osd_text, osd_text_tmp);


More information about the MPlayer-dev-eng mailing list