[Alsaplayer-devel]Re: patch to loop songs.

Patrick Shirkey pshirkey@boosthardware.com
Wed, 20 Jun 2001 04:52:48 -0400


> I will work on giving it some
>options like at the end of the song or at the end of the playlist.

1/2 done


>Also I would like to  put something in the black screen to tell the user that
>it is looping.
>To start with I will put in the word "Loop" but it would
>be nicer to have an image.

Not done

>Also I will try to get it to do what the pause
>button does. ie if it is looping then it should stop looping if it is
>not then it should start looping.

Done.

So I'll keep working on those other things. They will probably take me a
couple more days though. Anyway for now here's the patch to allow you to
loop a song. If anyone has any probs with it let me know.

---------------
diff -u -r alsaplayer-0.99.33-pre3/app/CorePlayer.cpp
alsa/alsaplayer-0.99.33-pre3/app/CorePlayer.cpp
--- alsaplayer-0.99.33-pre3/app/CorePlayer.cpp	Tue Dec 28 22:59:02 1999
+++ alsa/alsaplayer-0.99.33-pre3/app/CorePlayer.cpp	Tue Jun 19 01:49:12
2001
@@ -262,7 +262,6 @@
 	if (read_buf && plugin && the_object) {
 		if (read_buf->start < 0)
 			return 0;		
-
 		int frame_size = plugin->frame_size(the_object);
 		if (frame_size) 
 			return (read_buf->start + (read_buf->buf->GetReadIndex() * 4) /
frame_size);
Only in alsa/alsaplayer-0.99.33-pre3/app: CorePlayer.cpp~
diff -u -r alsaplayer-0.99.33-pre3/app/Playlist.cpp
alsa/alsaplayer-0.99.33-pre3/app/Playlist.cpp
--- alsaplayer-0.99.33-pre3/app/Playlist.cpp	Fri Apr 14 12:31:58 2000
+++ alsa/alsaplayer-0.99.33-pre3/app/Playlist.cpp	Wed Jun 20 04:38:02
2001
@@ -51,7 +51,12 @@
 
 	while(pl->active) {
 		if (!coreplayer->IsActive() && global_playing) {
-			pl->Next();
+		      if (global_playing == 3){
+		      coreplayer->Start(0);
+		      }	      
+		      else{
+		      pl->Next();
+		      }
 		}
 		dosleep(50000);
 	}
Only in alsa/alsaplayer-0.99.33-pre3/app: Playlist.cpp~
diff -u -r alsaplayer-0.99.33-pre3/app/gladesrc.cpp
alsa/alsaplayer-0.99.33-pre3/app/gladesrc.cpp
--- alsaplayer-0.99.33-pre3/app/gladesrc.cpp	Wed Sep 29 19:39:08 1999
+++ alsa/alsaplayer-0.99.33-pre3/app/gladesrc.cpp	Sat Jun 16 15:11:20
2001
@@ -173,6 +173,7 @@
   GtkWidget *audio_control_box;
   GtkWidget *hbox34;
   GtkWidget *hbox36;
+  GtkWidget *loop_button;
   GtkWidget *pause_button;
   GtkWidget *reverse_button;
   GtkWidget *forward_button;
@@ -281,6 +282,12 @@
   gtk_object_set_data (GTK_OBJECT (main_window), "hbox36", hbox36);
   gtk_widget_show (hbox36);
   gtk_box_pack_start (GTK_BOX (hbox34), hbox36, FALSE, FALSE, 0);
+
+  loop_button = gtk_button_new ();
+  gtk_object_set_data (GTK_OBJECT (main_window), "loop_button",
loop_button);
+  gtk_widget_show (loop_button);
+  gtk_box_pack_start (GTK_BOX (hbox36), loop_button, TRUE, TRUE, 0);
+  gtk_widget_set_usize (loop_button, 22, 20);
 
   pause_button = gtk_button_new ();
   gtk_object_set_data (GTK_OBJECT (main_window), "pause_button",
pause_button);
Only in alsa/alsaplayer-0.99.33-pre3/app: gladesrc.cpp~
diff -u -r alsaplayer-0.99.33-pre3/app/gtk_interface.cpp
alsa/alsaplayer-0.99.33-pre3/app/gtk_interface.cpp
--- alsaplayer-0.99.33-pre3/app/gtk_interface.cpp	Sun Dec 10 20:46:36
2000
+++ alsa/alsaplayer-0.99.33-pre3/app/gtk_interface.cpp	Wed Jun 20
04:41:02 2001
@@ -39,6 +39,7 @@
 #include "pixmaps/next.xpm"
 #include "pixmaps/prev.xpm"
 #include "pixmaps/stop.xpm"
+#include "pixmaps/loop.xpm"
 #include "pixmaps/volume_icon.xpm"
 #include "pixmaps/balance_icon.xpm"
 #if 0
@@ -474,7 +475,6 @@
 #endif
 }
 
-
 void pause_cb(GtkWidget *widget, gpointer data)
 {
 	GtkAdjustment *adj;
@@ -514,11 +514,68 @@
 	if (p) {
 		global_playing = 1;
 		eject_cb(widget, data);
-	}	
+	}      	
+}
+
+// Implemented by Patrick Shirkey - pshirkey@boosthardware.com
+void loop_cb(GtkWidget *widget, gpointer data)
+{
+      stream_info info;
+      CorePlayer *p = (CorePlayer *)data;
+      int g;
+
+      // Stops CorePlayer from searching for
+      // a plugin if not playing
+
+       	if (!p->IsPlaying()) {
+	  global_playing = 0; 
+       	} 
+
+	// Sets global_playing to 3 if not already set
+	// Playlist_looper uses this to decide what to do
+
+	if (p && global_playing == 1) {
+		g = 3;	  
+	} else {
+	        g = 1;
+	}
+            global_playing = g;
+
+	    // 	while (g == 3){
+	//	sprintf(info.loop,  "Loop" );
+       	//	draw_loop(info.loop, "Loop" );
+	    //	}
 }
+// Implemented by Patrick Shirkey - pshirkey@boosthardware.com
+void loop_Playlist_cb(GtkWidget *widget, gpointer data)
+{
+      stream_info info;
+      CorePlayer *p = (CorePlayer *)data;
+      int g;
+
+      // Stops CorePlayer from searching for
+      // a plugin if not playing
+
+       	if (!p->IsPlaying()) {
+	  global_playing = 0; 
+       	} 
 
+	// Sets global_playing to 3 if not already set
+	// Playlist_looper uses this to decide what to do
 
-void eject_cb(GtkWidget *wdiget, gpointer data)
+	if (p && global_playing == 1) {
+		g = 4;	  
+	} else {
+	        g = 1;
+	}
+            global_playing = g;
+
+	    // 	while (g == 3){
+	//	sprintf(info.loop,  "Loop" );
+       	//	draw_loop(info.loop, "Loop" );
+	    //	}
+}
+void eject_cb(GtkWidget *widget, gpointer data)
 {
 	CorePlayer *p = (CorePlayer *)data;
 	if (p) {
@@ -956,7 +1013,7 @@
 
 void init_main_window(CorePlayer *p)
 {
-	GtkWidget *root_menu;
+	GtkWidget *root_menu; 
 	GtkWidget *menu_item;
 	GtkWidget *main_window;
 	GtkWidget *effects_window;
@@ -1048,6 +1105,15 @@
 	gtk_button_set_relief(GTK_BUTTON(working), 
 						  global_rb ? GTK_RELIEF_NONE : GTK_RELIEF_NORMAL);
 
+	working = get_widget(main_window, "loop_button");
+	pix = xpm_label_box(loop_xpm, main_window);
+	gtk_widget_show(pix);
+	gtk_container_add(GTK_CONTAINER(working), pix);
+	gtk_signal_connect(GTK_OBJECT(working), "clicked",
+					   GTK_SIGNAL_FUNC(loop_cb), p);
+	gtk_button_set_relief(GTK_BUTTON(working), 
+						  global_rb ? GTK_RELIEF_NONE : GTK_RELIEF_NORMAL);
+
 	working = get_widget(main_window, "pause_button");
 	pix = xpm_label_box(pause_xpm, main_window);
 	gtk_widget_show(pix);
@@ -1234,6 +1300,24 @@
 	gtk_widget_show(menu_item);
 	gtk_widget_set_sensitive(menu_item, false);
 
+	// Separator
+	menu_item = gtk_menu_item_new();
+	gtk_menu_append(GTK_MENU(root_menu), menu_item);
+	gtk_widget_show(menu_item);
+
+	// loop song
+	menu_item = gtk_menu_item_new_with_label("Loop song");
+	gtk_menu_append(GTK_MENU(root_menu), menu_item);
+	gtk_signal_connect(GTK_OBJECT(menu_item), "activate",
+					   GTK_SIGNAL_FUNC(loop_cb), p);
+	gtk_widget_show(menu_item);
+	// loop playlist
+	menu_item = gtk_menu_item_new_with_label("Loop playlist");
+	gtk_menu_append(GTK_MENU(root_menu), menu_item);
+	gtk_signal_connect(GTK_OBJECT(menu_item), "activate",
+					   GTK_SIGNAL_FUNC(loop_cb), p);
+	gtk_widget_show(menu_item);
+       	gtk_widget_set_sensitive(menu_item, false);
 #if 1	
 	// Separator
 	menu_item = gtk_menu_item_new();
@@ -1256,7 +1340,6 @@
 					   GTK_SIGNAL_FUNC(cd_cb), p);
 #endif
 
-
 	// Separator
 	menu_item = gtk_menu_item_new();
 	gtk_menu_append(GTK_MENU(root_menu), menu_item);
@@ -1267,6 +1350,7 @@
 	gtk_signal_connect(GTK_OBJECT(menu_item), "activate",
 					   GTK_SIGNAL_FUNC(exit_cb), NULL);
 	gtk_widget_show(menu_item);
+
 #if 0	
 	// Connect popup menu
 	working = get_widget(main_window, "scope_button");
@@ -1281,6 +1365,7 @@
 	gtk_menu_append(GTK_MENU(cd_menu), menu_item);
 	gtk_signal_connect(GTK_OBJECT(menu_item), "activate",
 					   GTK_SIGNAL_FUNC(cd_cb), p);
+
 #ifdef HAVE_SOCKMON
 	menu_item = gtk_menu_item_new_with_label("Monitor TCP socket
(experimental)");
 	gtk_widget_show(menu_item);
Only in alsa/alsaplayer-0.99.33-pre3/app: gtk_interface.cpp~
Only in alsa/alsaplayer-0.99.33-pre3/app/pixmaps: loop.xpm
Only in alsa/alsaplayer-0.99.33-pre3: core
----------



-- 
Patrick Shirkey - Manager Boost Hardware.
Importing Korean Computer Hardware to New Zealand.

Http://www.boosthardware.com for cool toys to fufill every geeks
fantasy.