[MPlayer-dev-eng] [PATCH] dis-/enable playlist advancement

Mark Pustjens pustjens at dds.nl
Thu Apr 27 13:37:40 CEST 2006


Hello,

This patch adds commandline options to dis- or enable playlist 
advancement. It also add a new command which can be bound to a key.

You might want to be able to disable playlist advancement if you are 
particulairy fond of a song. It is also usefull if mplayer is used in a 
kiosk type application.

I have modified the manpage to include the commandline options. Please let 
me know if there is any other documentation i should update.

Greetings,

Mark Pustjens

-- 
The class was learning about some revolt in which some peasants had wanted
to stop being peasants and, since the nobles had won, had stopped being
peasants *really quickly*.
   (Soul Music)
-------------- next part --------------
diff -Naur main/DOCS/man/en/mplayer.1 main-new/DOCS/man/en/mplayer.1
--- main/DOCS/man/en/mplayer.1	2006-04-26 09:48:26.000000000 +0200
+++ main-new/DOCS/man/en/mplayer.1	2006-04-27 13:23:28.000000000 +0200
@@ -915,6 +915,10 @@
 Play files in random order.
 .
 .TP
+.B \-noadvance, -advance
+Disable or enable playlist advancement.
+.
+.TP
 .B \-skin <name> (GUI only)
 Loads a skin from the directory given as parameter below the default skin
 directories, /usr/\:local/\:share/\:mplayer/\:skins/\: and ~/.mplayer/\:skins/.
diff -Naur main/input/input.c main-new/input/input.c
--- main/input/input.c	2006-04-23 16:48:15.000000000 +0200
+++ main-new/input/input.c	2006-04-27 13:09:44.000000000 +0200
@@ -117,6 +117,7 @@
   { MP_CMD_LOADLIST, "loadlist", 1, { {MP_CMD_ARG_STRING, {0}}, {MP_CMD_ARG_INT,{0}}, {-1,{0}} } },
   { MP_CMD_RUN, "run", 1, { {MP_CMD_ARG_STRING,{0}}, {-1,{0}} } },
   { MP_CMD_VF_CHANGE_RECTANGLE, "change_rectangle", 2, { {MP_CMD_ARG_INT,{0}}, {MP_CMD_ARG_INT,{0}}, {-1,{0}}}},
+  { MP_CMD_PLAYLIST_ADVANCE, "playlist_advance", 1, { {MP_CMD_ARG_INT,{0}}, {-1,{0}}}},
 
 #ifdef HAVE_NEW_GUI  
   { MP_CMD_GUI_LOADFILE, "gui_loadfile", 0, { {-1,{0}} } },
diff -Naur main/input/input.h main-new/input/input.h
--- main/input/input.h	2006-04-23 16:31:54.000000000 +0200
+++ main-new/input/input.h	2006-04-27 13:10:49.000000000 +0200
@@ -72,6 +72,7 @@
 #define MP_CMD_SET_PROPERTY 68
 #define MP_CMD_GET_PROPERTY 69
 #define MP_CMD_OSD_SHOW_PROPERTY_TEXT 70
+#define MP_CMD_PLAYLIST_ADVANCE 71
 
 #define MP_CMD_GUI_EVENTS       5000
 #define MP_CMD_GUI_LOADFILE     5001
diff -Naur main/mplayer.c main-new/mplayer.c
--- main/mplayer.c	2006-04-26 00:34:40.000000000 +0200
+++ main-new/mplayer.c	2006-04-27 13:09:44.000000000 +0200
@@ -4583,6 +4583,10 @@
 	set_rectangle(sh_video, cmd->args[0].v.i, cmd->args[1].v.i);
 	break;
 	
+    case MP_CMD_PLAYLIST_ADVANCE: {
+    	set_playlist_advance(playtree_iter, cmd->args[0].v.i);
+    } break;
+	
     case MP_CMD_GET_TIME_LENGTH : {
 	mp_msg(MSGT_GLOBAL,MSGL_INFO, "ANS_LENGTH=%.2lf\n", demuxer_get_time_length(demuxer));
     } break;
diff -Naur main/parser-mpcmd.c main-new/parser-mpcmd.c
--- main/parser-mpcmd.c	2006-04-25 03:26:10.000000000 +0200
+++ main-new/parser-mpcmd.c	2006-04-27 13:09:44.000000000 +0200
@@ -168,6 +168,16 @@
 	    last_entry->flags &= ~PLAY_TREE_RND;
 	  else
 	    last_parent->flags &= ~PLAY_TREE_RND;
+	} else if(strcasecmp(opt,"advance") == 0) {
+	  if(last_entry && last_entry->child)
+	    last_entry->flags &= ~PLAY_TREE_NO_ADV;
+	  else
+	    last_parent->flags &= ~PLAY_TREE_NO_ADV;
+	} else if(strcasecmp(opt,"noadvance") == 0) {
+	  if(last_entry && last_entry->child)
+	    last_entry->flags |= PLAY_TREE_NO_ADV;
+	  else
+	    last_parent->flags |= PLAY_TREE_NO_ADV;
 	} else {
 	  m_option_t* mp_opt = NULL;
 	  play_tree_t* entry = NULL;
diff -Naur main/playtree.c main-new/playtree.c
--- main/playtree.c	2006-04-25 03:26:10.000000000 +0200
+++ main-new/playtree.c	2006-04-27 13:09:44.000000000 +0200
@@ -402,6 +402,8 @@
     play_tree_set_param(dest,src->params[i].name,src->params[i].value);
   if(src->flags & PLAY_TREE_RND) // pass the random flag too
     dest->flags |= PLAY_TREE_RND;
+  if(src->flags & PLAY_TREE_NO_ADV)
+    dest->flags |= PLAY_TREE_NO_ADV;
 
 }
 
@@ -563,13 +565,21 @@
     m_config_pop(iter->config);
   }
 
-  if(iter->tree->parent && (iter->tree->parent->flags & PLAY_TREE_RND))
-    iter->mode = PLAY_TREE_ITER_RND;
-  else
+  if(iter->tree->parent) {
+    if (iter->mode != PLAY_TREE_ITER_NO_ADV) {
+      if (iter->tree->parent->flags & PLAY_TREE_NO_ADV) {
+        iter->mode = PLAY_TREE_ITER_NO_ADV;
+      } else if(iter->tree->parent->flags & PLAY_TREE_RND) {
+        iter->mode = PLAY_TREE_ITER_RND;
+      }
+    }
+  } else
     iter->mode = PLAY_TREE_ITER_NORMAL;
 
   iter->file = -1;
-  if(iter->mode == PLAY_TREE_ITER_RND)
+  if(iter->mode == PLAY_TREE_ITER_NO_ADV)
+    pt = iter->tree;
+  else if(iter->mode == PLAY_TREE_ITER_RND)
     pt = play_tree_rnd_step(iter->tree);
   else if( d > 0 ) {
     int i;
@@ -964,3 +974,25 @@
   iter->tree=iter->root;
   play_tree_iter_step(iter, 0, 0);
 }
+
+void set_playlist_advance(play_tree_iter_t* iter, int i)
+{
+  switch (i) {
+    case -1: 
+        iter->tree->parent->flags |= PLAY_TREE_ITER_NO_ADV;
+        iter->mode = PLAY_TREE_ITER_NO_ADV;
+	break;
+    case 1:
+        iter->tree->parent->flags &= ~PLAY_TREE_ITER_NO_ADV;
+        iter->mode = PLAY_TREE_ITER_NORMAL;
+    	break;
+    case 0:
+      if (iter->tree->parent->flags & PLAY_TREE_ITER_NO_ADV) {
+        iter->tree->parent->flags &= ~PLAY_TREE_ITER_NO_ADV;
+        iter->mode = PLAY_TREE_ITER_NORMAL;
+      } else {
+        iter->tree->parent->flags |= PLAY_TREE_ITER_NO_ADV;
+        iter->mode = PLAY_TREE_ITER_NO_ADV;
+      }
+    }
+}
diff -Naur main/playtree.h main-new/playtree.h
--- main/playtree.h	2006-04-25 03:26:10.000000000 +0200
+++ main-new/playtree.h	2006-04-27 13:13:03.000000000 +0200
@@ -33,6 +33,8 @@
 ///@{
 /// Play the item childs in random order.
 #define PLAY_TREE_RND  (1<<0)
+/// Disable playlist advancement.
+#define PLAY_TREE_NO_ADV  (1<<1)
 /// Playtree flags used by the iterator to mark items already "randomly" played.
 #define PLAY_TREE_RND_PLAYED  (1<<8)
 ///@}
@@ -42,6 +44,7 @@
 ///@{
 #define PLAY_TREE_ITER_NORMAL 0
 #define PLAY_TREE_ITER_RND 1
+#define PLAY_TREE_ITER_NO_ADV 2
 ///@}
 
 /// \defgroup Playtree
@@ -282,6 +285,9 @@
 
 ///@}
 
+// Set playlist advancement
+extern void set_playlist_advance(play_tree_iter_t* iter, int i);
+
 #endif
 
 ///@}


More information about the MPlayer-dev-eng mailing list