[gst-devel] playing a playlist without stopping the sink

Sander Marechal s.marechal at jejik.com
Wed Sep 12 01:14:27 CEST 2007

Hello all,

I have been trying for a long time now to get a simple player working
that can play through a playlist and obey a simple "next" command,
without setting the pipeline to STATE_NULL (because in the final
version, the output will be a shout2send sink[1])

I've written a simplified, minimal version of my player, but I can't
even get that to work :-( I always get gstreamer errors when I switch to
the next song, and usually output stops alltogether. Or it hangs.

I have attached my minimal player below. When you run it, simply typing
"next" and hitting return should start playing the next song. I'm
probably doing something fundamentally wrong here.

I haven't been able to find any examples online that implement something
similar. It's either gstreamer tutorials that do "set STATE_NULL, change
location on filesrc, set STATE_PLAYING" or trying to comprehend the
source of advanced players/managers that do quite complicated stuff with
pipelines that I really don't understand.

Could someone point out to me what I'm doing wrong?

Thanks in advance,

Sander Marechal

[1] When a pipeline goes to STATE_NULL, the shout2send will unmount the
stream from icecast and all the icecast listeners get disconnected.

#!/usr/bin/env python

import pygst, gobject, time, sys
import gst

class AudioPlayer:
	def __init__(self):
		self.songs = [
			'music/Ozzy/Mr. Tinkertrain.mp3',
			'music/Ozzy/I Don\'t Want to Change the World.mp3',
			'music/Ozzy/Mama, I\'m Coming Home.mp3 ',
			'music/Ozzy/No More Tears.mp3 ',
		# create a new gstreamer pipeline
		self.pipeline = gst.Pipeline("mypipeline")
		# add a file source to the pipeline
		self.filesrc = gst.element_factory_make("filesrc", "source")
		# add a generic decoder to the pipeline and link it to the source
		self.decode = gst.element_factory_make("decodebin", "decode")
		self.decode.connect("new-decoded-pad", self.decode_link)
		# add a convertor to the pipeline
		self.convert = gst.element_factory_make("audioconvert", "convert")
		# add an alsa sink to the pipeline and link it to the convertor
		self.sink = gst.element_factory_make("alsasink", "sink")
		# start playing
		self.filesrc.set_property("location", self.songs.pop(0))

	def decode_link(self, dbin, pad, islast):
	def next(self):
		self.filesrc.set_property("location", self.songs.pop(0))
		return True

player = AudioPlayer()
loop = gobject.MainLoop()
context = loop.get_context()

while 1:
	value = sys.stdin.readline()
	if value == "next\n":

More information about the gstreamer-devel mailing list