[Gtk-sharp-list] Simple Audio Test - Gnome.Sound.Play method?

Michael Hutchinson m.j.hutchinson at gmail.com
Mon Apr 21 15:15:45 EDT 2008


On Sun, Apr 20, 2008 at 5:20 PM, Brian Gryder <bgryderclock at gmail.com> wrote:
> I am an novice C# programmer. I am experimenting with GTK# and am trying to
> play audio on a button click with the Gnome.Sound.Play method. It will
> compile but not play audio. What is correct usage of the Gnome.Sound.Play
> method?
>
> -------------------------------------------------------------------------------------
> using Glade;
> using Gtk;
> using System;
> using Gnome;
>
> class myWindow
> {  // start class
>     public myWindow ()
>
>         { // start mywindow
>         Glade.XML gui = new Glade.XML ("./test2/test2.glade","window1","");
>         gui.Autoconnect (this);
>         } // end mywindow
>
>      void on_button_clicked (object o,EventArgs e)
>         { //start click event
>             Console.WriteLine ("button clicked")
>             Gnome.Sound.Init ("/home/user/test.wav"); //<--------is this
> correct?
>              Gnome.Sound.Play ("/home/user/test.wav"); //<--------is this
> correct?
>         } //end click event
>
> } // End class
>
> class theotherpart
>
> {  // start class
>  static void Main ()
>      { //start main
>         Gtk.Application.Init ();
>         myWindow W = new myWindow ();
>         Gtk.Application.Run ();
>     } //End main
> } // End class
>
> _______________________________________________
>  Gtk-sharp-list maillist  -  Gtk-sharp-list at lists.ximian.com
>  http://lists.ximian.com/mailman/listinfo/gtk-sharp-list
>
>

As far as I can tell from the GNOME docs
(http://library.gnome.org/devel/libgnome/stable/libgnome-gnome-sound.html)
and the parameter names in the GNOME# API
(http://www.go-mono.com/docs/monodoc.ashx?tlink=4@ecma%3a535%23Sound%2fM%2f3),
this GNOME sound API works by connecting to an ESD sound player
daemon. The Init method takes the hostname of this daemon. Normally
I'd expect that you'd use "localhost" for the local machine, unless
you want to play sound over the network :-)

Hence the following probably works:

Gnome.Sound.Init ("localhost");
Gnome.Sound.Play ("/home/user/test.wav");

-- 
Michael Hutchinson
http://mjhutchinson.com


More information about the Gtk-sharp-list mailing list