[MPlayer-dev-eng] [PATCH] showing total time for new osdlevel 3 and percentage for 2 and 3

seru seru at gmx.net
Mon Dec 23 19:40:15 CET 2002


This patch adds a new osdlevel (3) which shows progress bar, percentage and total time.
Also percentage is added to existing osdlevel 2.

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	23 Dec 2002 18:53:21 -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;
@@ -2200,9 +2201,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 +2942,21 @@
       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 = demuxer_get_percent_pos(demuxer);
+          char percentage_text[50];
+              if (percent >= 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