[Muine] [PATCH]: support for multiple files



	Hi! I love the 0.6.3 feature to play external files from the
command line. As I was used to do "xmms *.mp3" in a directory, I made a
patch adding parsing of multiple files in the command line. If it is a song
it plays the first one and enqueues the rest. But I'm not sure about the
correct behavoiur for opening multiple playlists: concatenate them? open
only first? open only last?

Salu2

-- 
Fernando Herrera de las Heras
Onírica: análisis, diseño e implantación de soluciones informáticas
http://www.onirica.com
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/muine/ChangeLog,v
retrieving revision 1.321
diff -u -u -r1.321 ChangeLog
--- ChangeLog	18 Jun 2004 19:42:35 -0000	1.321
+++ ChangeLog	19 Jun 2004 18:27:19 -0000
@@ -1,3 +1,11 @@
+2004-06-19  Fernando Herrera  <fherrera onirica com>
+
+	* src/Muine.cs:
+	* src/PlaylistWindow.cs:
+
+	Support for multiple files in the command line (play the first, enqueue
+	the rest)
+
 2004-06-18  Jorn Baayen  <jbaayen gnome org>
 
 	* configure.in:
Index: src/Muine.cs
===================================================================
RCS file: /cvs/gnome/muine/src/Muine.cs,v
retrieving revision 1.30
diff -u -u -r1.30 Muine.cs
--- src/Muine.cs	13 Jun 2004 14:06:31 -0000	1.30
+++ src/Muine.cs	19 Jun 2004 18:27:24 -0000
@@ -129,25 +129,31 @@
 	private void ProcessCommandLine (string [] args, bool use_conn)
 	{
 		if (args.Length > 0) {
-			/* try to load first argument as a playlist or music file */
-			System.IO.FileInfo finfo = new System.IO.FileInfo (args [0]);
+			for (int i = 0; i < args.Length; i++) {
+				System.IO.FileInfo finfo = new System.IO.FileInfo (args [i]);
 			
-			if (finfo.Exists) {
-				if (FileUtils.IsPlaylist (args [0])) {
-					/* load as playlist */
-					if (use_conn)
-						conn.Send ("LoadPlaylist " + finfo.FullName);
-					else
-						playlist.OpenPlaylist (finfo.FullName);
-				} else {
-					/* load as music file */
-					if (use_conn)
-						conn.Send ("PlayFile " + finfo.FullName);
-					else
-						playlist.PlayFile (finfo.FullName);
+				if (finfo.Exists) {
+					if (FileUtils.IsPlaylist (args [i])) {
+						/* load as playlist */
+						if (use_conn)
+							conn.Send ("LoadPlaylist " + finfo.FullName);
+						else
+							playlist.OpenPlaylist (finfo.FullName);
+					} else {
+						/* load as music file */
+						if (use_conn)
+							if (i == 0)
+								conn.Send ("PlayFile " + finfo.FullName);
+							else
+								conn.Send ("AddFile " + finfo.FullName);
+						else
+							if (i == 0)
+								playlist.PlayFile (finfo.FullName);
+							else
+								playlist.AddFile (finfo.FullName);
+					}
+					opened_playlist = true;
 				}
-
-				opened_playlist = true;
 			}
 		} else if (use_conn)
 			conn.Send ("ShowWindow");
@@ -169,6 +175,8 @@
 			playlist.OpenPlaylist (message.Substring (13));
 		else if (message.StartsWith ("PlayFile "))
 			playlist.PlayFile (message.Substring (9));
+		else if (message.StartsWith ("AddFile "))
+			playlist.AddFile (message.Substring (8));
 	}
 
 	private void HandleCoversDoneLoading ()
Index: src/PlaylistWindow.cs
===================================================================
RCS file: /cvs/gnome/muine/src/PlaylistWindow.cs,v
retrieving revision 1.125
diff -u -u -r1.125 PlaylistWindow.cs
--- src/PlaylistWindow.cs	13 Jun 2004 14:02:33 -0000	1.125
+++ src/PlaylistWindow.cs	19 Jun 2004 18:27:32 -0000
@@ -1012,6 +1012,30 @@
 		NSongsChanged ();
 	}
 
+	public void AddFile (string file)
+	{
+		Song song = (Song) Muine.DB.Songs [file];
+
+		if (song == null) {
+			/* try to create a new song object */
+			try {
+				song = new Song (file);
+			} catch {
+				return;
+			}
+
+			song.Orphan = true;
+		}
+
+		if (song == null)
+			return;
+
+		IntPtr p = AddSong (song);
+
+		NSongsChanged ();
+	}
+
+
 	private void HandlePlaySongsEvent (List songs)
 	{
 		bool first = true;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]