[Muine] [Patch] Generalize Dashboard interface
- From: Edd Dumbill <edd usefulinc com>
- To: muine-list gnome org
- Subject: [Muine] [Patch] Generalize Dashboard interface
- Date: Mon, 24 May 2004 22:05:57 +0100
There are many reasons that other 'plugins' might want to get notified
when the playing song changes, not just Dashboard. The one I had in
mind was to write an interface to AudioScrobbler
(www.audioscrobbler.com), a playlist based recommendations engine.
Something like the attached patch would do that. I daresay you could do
it neater, this is just a suggestion.
-- Edd
Index: src/DashboardFrontend.cs
===================================================================
RCS file: /cvs/gnome/muine/src/DashboardFrontend.cs,v
retrieving revision 1.2
diff -u -r1.2 DashboardFrontend.cs
--- src/DashboardFrontend.cs 26 Feb 2004 10:46:10 -0000 1.2
+++ src/DashboardFrontend.cs 24 May 2004 21:01:21 -0000
@@ -26,6 +26,11 @@
public class DashboardFrontend
{
+ public static void PlayerChangedSong (Song song, bool HasToplevelFocus)
+ {
+ SendClue (song.Artists, song.Album, song.Title, HasToplevelFocus);
+ }
+
public static void SendClue (string [] artists, string album, string song_title, bool has_focus)
{
TcpClient tcp_client = new TcpClient ();
Index: src/PlaylistWindow.cs
===================================================================
RCS file: /cvs/gnome/muine/src/PlaylistWindow.cs,v
retrieving revision 1.120
diff -u -r1.120 PlaylistWindow.cs
--- src/PlaylistWindow.cs 9 May 2004 20:16:49 -0000 1.120
+++ src/PlaylistWindow.cs 24 May 2004 21:01:21 -0000
@@ -90,6 +90,12 @@
/* Multimedia Key handler */
private MmKeys mmkeys;
+ public delegate void PlayerChangedSongHandler (Song song, bool hasfocus);
+
+ /* Event to notify when song changed: plugins like
+ Dashboard can use this. */
+ public event PlayerChangedSongHandler PlayerChangedSong;
+
public PlaylistWindow () : base (WindowType.Toplevel)
{
/* build the interface */
@@ -125,6 +131,9 @@
mmkeys.PlayPause += new EventHandler (HandlePlayPauseCommand);
mmkeys.Stop += new EventHandler (HandleStopCommand);
+ /* Add Dashboard support */
+ PlayerChangedSong += DashboardFrontend.PlayerChangedSong;
+
/* load last playlist */
playlist_filename = Gnome.User.DirGet () + "/muine/playlist.m3u";
System.IO.FileInfo finfo = new System.IO.FileInfo (playlist_filename);
@@ -603,8 +612,10 @@
if (player.Playing)
icon.Tooltip = artist_label.Text + " - " + title_label.Text;
- if (restart)
- DashboardFrontend.SendClue (song.Artists, song.Album, song.Title, HasToplevelFocus);
+ if (restart) {
+ PlayerChangedSong (song, HasToplevelFocus);
+ }
+
} else {
cover_image.Song = null;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]