#!/usr/bin/python
import gobject; gobject.threads_init()
import pygst; pygst.require('0.10')
import gst



pb2 = gst.element_factory_make("playbin2", "playbin2")

# uncomment to hear something
# pb2 = gst.element_factory_make("playbin", "playbin")

pb2.set_property('audio_sink', gst.element_factory_make('alsasink', 'as') )
pb2.set_property('uri', 'file:///tmp/03.flac')

ml = gobject.MainLoop()

def player(): pb2.set_state(gst.STATE_PLAYING)
gobject.timeout_add(500, player)

# The occasionally-effective workaround of seeking to 0 doesn't work here, as
# you may see when this does absolutely nothing when playbin2 is used
def seeker(): pb2.seek_simple(gst.FORMAT_TIME, gst.SEEK_FLAG_FLUSH, 0)
gobject.timeout_add(2000, seeker)

ml.run()

