Skip to content

Instantly share code, notes, and snippets.

@WimRoose
Created October 3, 2016 06:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save WimRoose/dd47d7af06083bfa73c8d3d51c0ed70d to your computer and use it in GitHub Desktop.
Save WimRoose/dd47d7af06083bfa73c8d3d51c0ed70d to your computer and use it in GitHub Desktop.
class Player:
def __init__(self, _uri):
self.mainloop = GObject.MainLoop()
#Creating the gst pipeline we're going to add elements to and use to play the file
self.pipeline = Gst.Pipeline.new("mypipeline")
#creating the filesrc element, and adding it to the pipeline
self.filesrc = Gst.ElementFactory.make("playbin", "stream")
#self.filesrc.set_property("uri", "http://audio.22tracks.com/128/1413474600-543fe9280ea4a.mp3?st=-BMDl94yWpACmDvv_w88-Q&e=1475094638")
self.filesrc.set_property("uri", _uri)
self.pipeline.add(self.filesrc)
#handler taking care of linking the decoder's newly created source pad to the sink
def decode_src_created(self, element, pad):
pad.link(self.sink.get_static_pad("sink"))
#running the shit
def run(self):
print "starting to run"
self.pipeline.set_state(Gst.State.PLAYING)
self.mainloop.run()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment