[MPlayer-dev-eng] -loop patch for MPlayer 0.50

Pascal Haakmat a.haakmat at chello.nl
Tue Oct 23 01:37:36 CEST 2001


Hello,

MPlayer rocks :)

Attached is a patch against MPlayer 0.50 that adds looping support by
rewinding the movie upon EOF. The patch adds a '-loop' option to mplayer
which can be either -1 (to not loop, default behaviour), 0 (to loop forever)
or a number between 1-10000 to loop that number of times (i.e. -loop 1 plays
the movie twice). This is not a general solution because some demuxers (e.g.
mpeg-ps and mp3 audio?) don't seem to like seeking after EOF, but it works
for me.

Thanks for MPlayer.


--- snip


diff -rbu2 MPlayer-0.50.orig/help_mp-en.h MPlayer-0.50/help_mp-en.h
--- MPlayer-0.50.orig/help_mp-en.h	Fri Sep 28 20:32:22 2001
+++ MPlayer-0.50/help_mp-en.h	Mon Oct 22 08:44:57 2001
@@ -30,4 +30,5 @@
 #endif
 " -ss <timepos>   seek to given (seconds or hh:mm:ss) position\n"
+" -loop <n>       loop n times (0=forever, -1=don't loop)\n"
 " -nosound        don't play sound\n"
 #ifdef USE_FAKE_MONO


diff -rbu2 MPlayer-0.50.orig/cfg-mplayer.h MPlayer-0.50/cfg-mplayer.h
--- MPlayer-0.50.orig/cfg-mplayer.h	Wed Oct  3 16:41:39 2001
+++ MPlayer-0.50/cfg-mplayer.h	Mon Oct 22 07:51:11 2001
@@ -136,4 +136,5 @@
 	{"sb", &seek_to_byte, CONF_TYPE_INT, CONF_MIN, 0, 0},
 	{"ss", &seek_to_sec, CONF_TYPE_STRING, CONF_MIN, 0, 0},
+	{"loop", &loop_times, CONF_TYPE_INT, CONF_RANGE, -1, 10000},
 	{"sound", &has_audio, CONF_TYPE_FLAG, 0, 0, 1},
 	{"nosound", &has_audio, CONF_TYPE_FLAG, 0, 1, 0},


diff -rbu2 MPlayer-0.50.orig/mplayer.c MPlayer-0.50/mplayer.c
--- MPlayer-0.50.orig/mplayer.c	Sun Oct  7 02:57:28 2001
+++ MPlayer-0.50/mplayer.c	Mon Oct 22 08:15:28 2001
@@ -205,4 +205,5 @@
 off_t seek_to_byte=0;
 int has_audio=1;
+int loop_times=-1;
 
 char *audio_codec=NULL; // override audio codec
@@ -1834,4 +1835,23 @@
   }
   
+  /* Looping. */
+  if(eof && loop_times>-1) {
+
+    if(loop_times!=0) {
+      
+      loop_times--;
+      
+      if(loop_times==0)
+        loop_times=-1;
+      
+    }
+    
+    eof=0;
+    abs_seek_pos=1;
+
+    mp_msg(MSGT_CPLAYER,MSGL_V,"loop_times = %d, eof = 0\n", loop_times);
+    
+  }
+
 if(rel_seek_secs || abs_seek_pos){
   current_module="seek";



More information about the MPlayer-dev-eng mailing list