Hi,<br><br>Here's an interesting one, possibly o/t for this list, but I'll be cheeky and ask anyway. :)<br><br>I'm writing a meditation timer program in Python, it waits for 'n' minutes then plays an ogg encoded bell sound. Everything is great, got the GUI and it plays the sound via a GStreamer playbin.
<br><br>My problem is that there is a slight delay between the end of the time period and the sound playing as playbin loads it. So I think I need to read the file into memory during my program initialisation and play it from there rather than the disk.
<br><br>I was playing with the code below, but when I try to add the buffer into the pipeline with "gst.element_link_many(buffer, decode)", it complains it's not a gstreamer object.<br><br>My question is, can anyone give me any guidance on how to pre-buffer / pre-decode the ogg sound, or what I'm doing wrong with this buffer please?
<br><br>Thanks,<br>
<br>
Rich.<br><br>-----SOF<br>#!/usr/bin/python<br><br>import os<br>import pygst<br>pygst.require("0.10")<br>import gst<br><br>class playit:<br> def main(self):<br> size = os.path.getsize("./test.ogg")
<br> file = open("./test.ogg","r")<br> # Construct the GStreamer pipeline <br> player = gst.Pipeline("testplayer")<br> #Buffer source<br> buffer = gst.buffer_new_and_alloc
(size)<br> buffer = file.read<br> <br> #Binary decoder<br> decode = gst.element_factory_make("decodebin", "decode")<br> decode.connect("new-decoded-pad", self.OnDynamicPad
)<br> player.add(decode)<br> <br> #Audio converter<br> converter = gst.element_factory_make("audioconvert","converter")<br> player.add(converter)<br> #ALSA Sink
<br> sink = gst.element_factory_make("alsasink","sink")<br> player.add(sink)<br> #Link them up<br> gst.element_link_many(buffer, decode)<br> gst.element_link_many(converter, sink)
<br> #Play<br> player.set_state(gst.STATE_PLAYING)<br> <br> def OnDynamicPad(self, dbin, pad, islast):<br> pad.link(self.converter.get_pad("sink"))<br> <br>if __name__ == "__main__":
<br> gsttest = playit()<br> gsttest.main()<br><br>------EOF<br><br>-- <br><a href="http://quietwatercourse.wordpress.com">http://quietwatercourse.wordpress.com</a> <br><a href="http://www.myspace.com/quietwatercourse">
http://www.myspace.com/quietwatercourse</a><br><br>Visit my sites, I don't bite unless you're in fishnets!