Coding

Unmaintained

GNotify was experimental softare and is obsolete due to libnotify. I can't imagine anyone still using it.

Why GNotifyMuine?

Notification is really nice on random playlists or when you're not really sure what the song is in the first three notes. You can just say, "Skip it" within a second of the song starting. Basically, it's the same idea as having a little display on your Minidisk or MP3 player.

Requirements

  • Muine 8.2+
  • The GNotify Daemon (Running)

Installation

cd ~/.gnome2/muine/plugins
wget http://www.public.asu.edu/~bnickel/GNotifyMuine/GNotifyMuine.cs
mcs -target:library -out:GNotifyMuine.dll GNotifyMuine.cs -pkg:muine-plugin -pkg:gnome-sharp-2.0
[[Restart "muine"]]

Files

Why isn't it working?

Is GNotify Running?
The plugin will only work if the gnotify daemon is running. To check if it's running, run . If it doesn't list a pid, you can start gnotify with .
GNotify is running. Why isn't anything happening?
The plugin will only show a notification if the Muine window isn't visibile . This behavior is because the information contained in the notification is already contained in the window and the notification really isn't important in that case. The notifcation will appear if the window is A) hidden, B) minimised, C) covered up, or D) in another workspace.
It's still not working!
You can contact me of you have any further problems.

GNotifyMuine.cs Source

// GNotifyMuine.cs - Muine GNotify Plugin
// Copyright (C) 2005 Brian Nickel <kerrick@asu.edu>
// Licensed under GNU GPL V2.
// Requires : Running GNotify Daemon

using System;
using System.IO;
using System.Net.Sockets;
using System.Text;
using Muine.PluginLib;

public class GNotifyMuine : Plugin
{
	private IPlayer player;

	public override void Initialize(IPlayer player)
	{
		this.player = player;
		player.SongChangedEvent += new SongChangedEventHandler (OnSongChange);
		player.StateChangedEvent += new StateChangedEventHandler (OnStateChange);
	}
			
	public void OnSongChange(ISong song)
	{
		if(song == null || player.Playing == false || player.WindowVisible == true)
			return;
		
		Notify (song.Artists, song.Album, song.Title, song.CoverImage);
	}
	
	public void OnStateChange(bool playing)
	{
		if(player.PlayingSong == null || playing == false || player.WindowVisible == true)
			return;
		
		Notify (player.PlayingSong.Artists, player.PlayingSong.Album, player.PlayingSong.Title, 
     player.PlayingSong.CoverImage);
	}
	
	private void Notify (string [] artists, string album, string song_title, Gdk.Pixbuf cover_image)
	{
		try {
			TcpClient tcp_client = new TcpClient ();
			tcp_client.SendTimeout = 50;
			tcp_client.Connect ("127.0.0.1", 7206);
			NetworkStream network_stream = tcp_client.GetStream ();
			if (network_stream.CanWrite)
			{
				StreamWriter writer = new StreamWriter(network_stream);
				StreamReader reader = new StreamReader(network_stream);
				char [] buffer = new char[ 8 ];

				string merged_artists = "";
				for( int i = 0; i < artists.Length; i ++ )
				{
					if( i != 0 ) merged_artists += ", ";
					merged_artists += artists[ i ];
				}

				DirectoryInfo dinfo = new DirectoryInfo (Path.Combine (Gnome.User.DirGet (), "muine"));
				if (!dinfo.Exists) 
					dinfo.Create ();

				string filename = dinfo.FullName + "/gnotify.png";
				Gdk.Pixbuf buf;
				if (cover_image != null)
					buf = cover_image.ScaleSimple( 48, 48, Gdk.InterpType.Bilinear );
				else
				{
					/* Hack to get the GtkStyle .. */
					Gtk.Label label = new Gtk.Label ("");
					label.EnsureStyle ();
					buf = label.RenderIcon ("muine-default-cover", Gtk.IconSize.Dialog, null);
					label.Destroy ();
				}
				if(buf.Savev (filename, "png", null, null) == false)
					filename = "/usr/share/pixmaps/muine.png";

				writer.Write ("APP:Muine Music Player" );
				writer.Flush ();
				reader.Read ( buffer, 0, 8 );
				writer.Write ("ICON:" + filename);
				writer.Flush ();
				reader.Read ( buffer, 0, 8 );

				writer.Write (String.Format ("MSG:{0}\n{1}", song_title.Replace ("&", "&amp;").Replace 
             ("<", "&lt;"), merged_artists.Replace ("&", "&amp;").Replace ("<", "&lt;")));
				writer.Flush ();
			}
			tcp_client.Close ();
		} catch {
			return;
		}
	}
}