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
-
-
class __GstPlayThread(threading.Thread):
-
def __init__(self, ply):
-
self.ply = ply
-
threading.Thread.__init__(self)
-
def run(self):
-
self.ply.set_state(gst.STATE_PLAYING)
-
def bus_event(bus, message):
-
t = message.type
-
if t == gst.MESSAGE_EOS:
-
self.ply.set_state(gst.STATE_NULL)
-
return True
-
self.ply.get_bus().add_watch(bus_event)
-
-
def gstplay(file_path):
-
ply = gst.element_factory_make("playbin", "player")
-
ply.set_property("uri", "file://" + file_path)
-
pt = __GstPlayThread(ply)
-
pt.start()
Comments
One Response to “gnome.sound_play method do not work on Ubuntu Gutsy”
Leave a Reply
[…] No sound bug (Now it should work well) […]