There are a number of ways to play an audio using Python and GStreamer. Let's start with a simple one. In this section, we will use a command string, similar to what you would specify using the command-line version of GStreamer. This string will be used to construct a gst.Pipeline
instance in a Python program.
So, here we go!
Start by creating an
AudioPlayer
class in a Python source file. Just define the empty methods illustrated in the following code snippet. We will expand those in the later steps.1 import thread 2 import gobject 3 import pygst 4 pygst.require("0.10") 5 import gst 6 7 class AudioPlayer: 8 def __init__(self): 9 pass 10 def constructPipeline(self): 11 pass 12 def connectSignals(self): 13 pass 14 def play(self): 15 pass 16 def message_handler(self): 17 pass 18 19 # Now run the program 20 player = AudioPlayer() 21 thread.start_new_thread(player.play, ()) 22 gobject.threads_init() 23 evt_loop = gobject.MainLoop...