search instagram arrow-down




Command Line Audio Player using Python

Gstreamer  is the Opensource  multimedia Framework. The applications it supports range from simple Ogg/Vorbis playback, audio/video streaming to complex audio (mixing) and video (non-linear editing) processing.

Here, we use the gstreamer through Python to play the audio file. (mp3,wav etc). —usage ptyhon <File to Play>

import pygst,sys
import gst
import pygtk
import gtk

class Main:
def __init__(self):
# Create the pipeline.
self.pipeline = gst.Pipeline("mypipeline")
self.filesrc = gst.element_factory_make("filesrc", "source")

self.filesrc.set_property("location", sys.argv[1])
self.decode = gst.element_factory_make("decodebin", "decode")
self.decode.connect("new-decoded-pad", self.OnDynamicPad)
self.convert = gst.element_factory_make("audioconvert", "convert")
self.sink = gst.element_factory_make("alsasink", "sink")
# add the elements to the pipeline.
# Link them.
# state in Playing mode.

def OnDynamicPad(self, dbin, pad, islast):
print "OnDynamicPad Called!""sink"))

Leave a Reply
Your email address will not be published. Required fields are marked *

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: