<?xml version="1.0" encoding="iso-8859-1"?>
<rdf:RDF xmlns="http://purl.org/rss/1.0/"
         xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" 
         xmlns:dc="http://purl.org/dc/elements/1.1/"
         xmlns:content="http://purl.org/rss/1.0/modules/content/">

<channel rdf:about="http://base-art.net/Articles/67/">
<description>&lt;p&gt;Gstreamer based python audio player in no time&lt;/p&gt;
&lt;p&gt;I'm learning to develop with &lt;a class="reference" href="http://gstreamer.net/"&gt;Gstreamer&lt;/a&gt; 0.10 framework, which natively
comes with Python binding, which is rare enough to notice for a project.&lt;/p&gt;
&lt;p&gt;So, starting an audio player is quite simple:&lt;/p&gt;
&lt;ul class="simple"&gt;
&lt;li&gt;create a player from the GstElement factory&lt;/li&gt;
&lt;li&gt;give your file uri to the player and set it to play&lt;/li&gt;
&lt;li&gt;start a loop (i used gobject here, but it should work 
with gtk.main() or a while-true loop)&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Here is the code:&lt;/p&gt;
&lt;pre class="literal-block"&gt;
import pygst
pygst.require('0.10')
import gst
import gobject, sys

def play_uri(uri):
    &amp;quot; play an uri like file:///home/foo/bar.mp3 &amp;quot;

    mainloop = gobject.MainLoop()
    player = gst.element_factory_make(&amp;quot;playbin&amp;quot;, &amp;quot;player&amp;quot;)
  
    print 'Playing:', uri
    player.set_property('uri', uri)
    player.set_state(gst.STATE_PLAYING)

    mainloop.run()
&lt;/pre&gt;
&lt;p&gt;Ok, this is a start, now i need to:&lt;/p&gt;
&lt;ul class="simple"&gt;
&lt;li&gt;get status information&lt;/li&gt;
&lt;li&gt;seek + / -&lt;/li&gt;
&lt;li&gt;play/pause/stop&lt;/li&gt;
&lt;li&gt;manage a playing queue&lt;/li&gt;
&lt;li&gt;manage video playing&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;So things will be a bit more complicated in a moment ;)&lt;/p&gt;
</description>
<link>http://base-art.net/Articles/67/</link>
<title>Comments on article "Gstreamer based python audio player in no time"</title>



<items>
<rdf:seq>

<rdf:li rdf:resource="http://base-art.net/Comments/195/"/>

<rdf:li rdf:resource="http://base-art.net/Comments/194/"/>

<rdf:li rdf:resource="http://base-art.net/Comments/193/"/>

<rdf:li rdf:resource="http://base-art.net/Comments/192/"/>

<rdf:li rdf:resource="http://base-art.net/Comments/191/"/>

<rdf:li rdf:resource="http://base-art.net/Comments/190/"/>

</rdf:seq>
</items>


</channel>


<item rdf:about="http://base-art.net/Comments/195/">
<dc:date>2006-02-24T20:46:42.000004+01:00</dc:date>
<title>patrickkidd on Gstreamer based python audio player in no time</title>
<link>http://base-art.net/Comments/195/</link>
<author>patrickkidd</author>
<description>
&lt;p&gt;The examples in gst-python are for 0.8, which had a completely different threading model. Everything happens in the background now, and as John said, you only need the main loop if you want to get gobject messages from the bus. Check here for an example: &lt;a class="reference" href="https://svn.patrickkidd.com/pk/trac/wiki/QGObjectLoop"&gt;https://svn.patrickkidd.com/pk/trac/wiki/QGObjectLoop&lt;/a&gt;&lt;/p&gt;

</description>
</item>

<item rdf:about="http://base-art.net/Comments/194/">
<dc:date>2006-02-24T16:59:25.000004+01:00</dc:date>
<title>Johan Dahlin on Gstreamer based python audio player in no time</title>
<link>http://base-art.net/Comments/194/</link>
<author>Johan Dahlin</author>
<description>
&lt;p&gt;You'll only need a mainloop if you want to send messages via the bus. You can use a GObject mainloop or a Gtk+ one depending on the application you're writing. 
Eg, if you're not writing a graphical gtk+ application, the gobject one is recommended. (You could also write your own mainloop, since in 0.10 the only thing it's used for is to send messages)&lt;/p&gt;

</description>
</item>

<item rdf:about="http://base-art.net/Comments/193/">
<dc:date>2006-02-24T16:07:47.000004+01:00</dc:date>
<title>phil on Gstreamer based python audio player in no time</title>
<link>http://base-art.net/Comments/193/</link>
<author>phil</author>
<description>
&lt;p&gt;From what i understood, Gstreamer has its own &amp;quot;playing thread&amp;quot;, and to keep it alive from your code, you have to perform a long task (like time.sleep(song_duration) for instance)&lt;/p&gt;

</description>
</item>

<item rdf:about="http://base-art.net/Comments/192/">
<dc:date>2006-02-24T15:37:16.000004+01:00</dc:date>
<title>zgoda on Gstreamer based python audio player in no time</title>
<link>http://base-art.net/Comments/192/</link>
<author>zgoda</author>
<description>
All of examples from gst-python distribution use some kind of &lt;code&gt;while&lt;/code&gt; loop. Seems that GStreamer has no own loop itself.
</description>
</item>

<item rdf:about="http://base-art.net/Comments/191/">
<dc:date>2006-02-24T13:14:26.000004+01:00</dc:date>
<title>Jkx on Gstreamer based python audio player in no time</title>
<link>http://base-art.net/Comments/191/</link>
<author>Jkx</author>
<description>
&lt;p&gt;s/with polling/without polling/g&lt;/p&gt;

</description>
</item>

<item rdf:about="http://base-art.net/Comments/190/">
<dc:date>2006-02-24T13:13:25.000004+01:00</dc:date>
<title>Jkx on Gstreamer based python audio player in no time</title>
<link>http://base-art.net/Comments/190/</link>
<author>Jkx</author>
<description>
&lt;p&gt;Does this mean you need to play w/ the mainloop nightmare (ala Gtk) ? The sound doesn't play in background ?&lt;/p&gt;
&lt;p&gt;This is kind of stuff, that is pretty easy to do in plain Old C fashion w/ thread and other stuff, but that became a pain in the ass in python. From want I know (little experience w/ that kind of stuff), this should play the music in background with polling a loop. (Not even talking the wrong effec this can have when you have to deal w/ a bunch of mainloop() .. gtk + gstream + twisted .. )&lt;/p&gt;

</description>
</item>


</rdf:RDF>
