Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

i have this code :

import pygst 
import st, pygtk
player_name = gst.element_make_factory("playbin", "Multimedia Player")
player_name.set_property("uri", "../media/alert.mp3")

it keeps throwing me the following error :

 player_name = gst.element_make_factory("playbin", "Multimedia Player")
 AttributeError: 'module' object has no attribute 'element_make_factory'

nay way to solve this and why is this happening ?

if i print gst i get the following : <module 'gst' from '/usr/lib/python2.7/dist-packages/gst-0.10/gst/__init__.pyc'>

so it is a module !

share|improve this question
is there a reason you're using the old gst bindings and not the pygi ones? – hbdgaf Oct 5 '12 at 16:40
what are the new ones ? i am new to python and am trying to play a sound using 'quickly' ; many examples ? – Ronan Dejhero Oct 5 '12 at 16:42
this should help you out:… it's not an answer by any means, but if you start with the old examples and go through the porting stuff you may arrive at a question that would be a bit more useful. (quickly == pygi and old gobject is not compat with new gobject) – hbdgaf Oct 5 '12 at 16:44
after lots of searches i fixed it thank you :) but it doesn't play twice if i close the app and start it again :s – Ronan Dejhero Oct 5 '12 at 17:31

The error is actually very simple: the gst module has no element_make_factory method. Have a look at my following interactive session for some more info:

>>> import gst
>>> gst.element_make_factory
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'module' object has no attribute 'element_make_factory'
>>> gst.some_none_existent_method
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'module' object has no attribute 'some_none_existent_method'
>>> dir(gst)

#### Snipping out lots of results...

'warnings', 'xml_make_element', 'xml_write', 'xml_write_file']
>>> 'element_make_factory' in dir(gst)
>>> 'element_factory_make' in dir(gst)
>>> gst.element_factory_make
<built-in function element_factory_make>
share|improve this answer
ok , and why is that ? – Ronan Dejhero Oct 8 '12 at 12:31
See the difference in method names? You mixed something up apparently and should try gst.element_factory_make() – Timo Oct 8 '12 at 13:28

Here's some working's still in progress(but it works). It should have a glade file and some button callbacks implemented. The pygi Gst part works though.

Example multimedia player

gir and GdkX11

adapted from here:

#use gir if you're using quickly...or just use it anyway
from gi.repository import GObject, Gst, Gtk, GdkX11, GstVideo

import os, base64

class DemoFiles:
    Smashing our .glade file and our mp3 into our py
    def __init__(self, root):
        self.root = root = '' +\
        self.testaudio = '' +\

    def drop_files(self):

class Settings:
    Using our home directory
    def __init__(self, root):
        self.root = root
        home = os.environ['HOME']
        working = os.path.join(home, 'com.example.pygi.gst')
        uri = os.path.join(working, 'makeitbetter.mp3')
        glade = os.path.join(working, '')

        self.params = {
                       'HOME': home,
                       'WORKING': working,
                       'DEMOFILE': uri,
                       'GLADE': glade

    def __call__(self, param):
        return self.params[param]

    def set_param(self, param, data):
        self.params[param] = data
        return True

class Handler:
    Callbacks for Glade
    def __init__(self, root):
        self.root = root

    def on_file_button_clicked(self, *args):

    def on_file_ok_button_clicked(self, *args):
        print args[0]
        self.root.ui.gst.playbin.set_property('uri', 'file://' + args[0])

    def on_file_cancel_button_clicked(self, *args):

    def on_main_win_delete_event(self, *args):
        #clean up our pipeline

class GstreamerStuff:
    All the gstreamer stuff
    def __init__(self, root):             
        self.root = root

        #Threading init

        # GStreamer init
        self.pipeline = Gst.Pipeline()
        self.bus = self.pipeline.get_bus()
        self.bus.connect('message::eos', self.on_eos)
        self.bus.connect('message::error', self.on_error)

        # This is needed to make the video output in our DrawingArea:
        self.bus.connect('sync-message::element', self.on_sync_message)

        # Create GStreamer elements
        self.playbin = Gst.ElementFactory.make('playbin', None)

        # Add playbin to the pipeline

        self.xid = ''

    def on_sync_message(self, bus, msg):
        if msg.get_structure().get_name() == 'prepare-window-handle':

    def on_eos(self, bus, msg):
        self.root.ui.update_status('Seeking to start of video')
            Gst.SeekFlags.FLUSH | Gst.SeekFlags.KEY_UNIT,

    def on_error(self, bus, msg):

    def set_xid(self, xid):
        self.xid = xid

class UI:
    User interface code
    def __init__(self, root):
        self.root = root

        #Handle Gtk setup
        self.builder = Gtk.Builder()
        self.handler = Handler(root)
        #Load the glade file
        #Connect callbacks

        #Handle Gst setup
        self.gst = GstreamerStuff(root)

    def init(self):

    def show_main(self):

    def update_status(self, status):
        print('Status bar update')

class SamplePlayer:
    def __init__(self):
        #Settings instance
        self.settings = Settings(self)

        #Dump demo files
        demo = DemoFiles(self)

        #UI Init - I put gstreamer in here
        self.ui = UI(self)

    def run(self):
        print('Trying with: ' + self.settings('DEMOFILE'))

if __name__ == '__main__':
    player = SamplePlayer()
share|improve this answer
note that it works for audio, but fails to "embed" the video in to the drawing area spawns a child window :/ a little puzzling, but it gets your audio working – hbdgaf Oct 9 '12 at 2:33

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.