gnome.sound_play method do not work on Ubuntu Gutsy

Posted on November 9, 2007
Filed Under cGmail, gnome, python |

I’ve noticed that the sound_play method from the gnome python package no longer work on Gutsy release and this is a bad thing. As you probabily have read I’ve released the 0.4 version of cGmail. cGmail by default prefer this method to play sounds on new incoming messages (that worked fine in feisty and before) and since this method no more work you will not have sounds :(

The bug is known and filed on launchpad https://bugs.launchpad.net/ubuntu/+bug/153704 (I’ve added my comment too)

For now to play sounds on gnome with python I suggest gstreamer.

Here an example on how to do. This play a file in async mode:

Python code

  1.  
  2. class __GstPlayThread(threading.Thread):
  3.         def __init__(self, ply):
  4.                 self.ply = ply
  5.                 threading.Thread.__init__(self)
  6.         def run(self):
  7.                 self.ply.set_state(gst.STATE_PLAYING)
  8.                 def bus_event(bus, message):
  9.                         t = message.type
  10.                         if t == gst.MESSAGE_EOS:
  11.                                 self.ply.set_state(gst.STATE_NULL)
  12.                         return True
  13.                 self.ply.get_bus().add_watch(bus_event)
  14.  
  15. def gstplay(file_path):
  16.         ply = gst.element_factory_make("playbin", "player")
  17.         ply.set_property("uri", "file://" + file_path)
  18.         pt = __GstPlayThread(ply)
  19.         pt.start()

Comments

One Response to “gnome.sound_play method do not work on Ubuntu Gutsy”

  1. cGmail 0.4.1 released : Open Source Works on November 28th, 2007 6:28 pm

    […] No sound bug (Now it should work well) […]

Leave a Reply