mimobe 0 Newbie Poster

Hello everybody,
I'm trying to improve an application i found at this link Click Here which can load and play a video file .avi or .ogg. My problem is as follows: I'm unable to load another video file though i have access to the dialog box. In addition to that, i have created and setup a Scale Widget that allows me to vary the playback speed but once the video is running it's impossible to modify the speedness of the video. Can someone help me out to sort out this issue?
For your information, I use the modules pygst, Tkinter under Linux.
Thanks

from Tkinter import *
import tkFileDialog
import gtk
import pygst
pygst.require("0.10")
import gst

#
# service routines
#
def onMove():
   global rate
   rate = float(var.get()))

def on_message(bus, message):
    print 'got message:', message.structure.get_name()
    t = message.type
    if t == gst.MESSAGE_EOS:
        player.set_state(gst.STATE_NULL)
    elif t == gst.MESSAGE_ERROR:
        player.set_state(gst.STATE_NULL)
        err, debug = message.parse_error()
        print "Error: %s" % err, debug

def on_sync_message(bus, message):
    print 'got sync'
    if message.structure is None:
        return
    message_name = message.structure.get_name()
    print 'got sync message:', message_name
    if message_name == "prepare-xwindow-id":
        imagesink = message.src
        imagesink.set_property("force-aspect-ratio", True)
        # comment out the next line to have video pop up in it's own window
        imagesink.set_xwindow_id(field_video.winfo_id())

def get_file():
    file = tkFileDialog.askopenfilename(parent=widget_master,title='Choose a file')
    field_file.delete(0,END)
    field_file.insert(0,file)
    player.set_property("uri", "file://" +str(file))
    player.set_state(gst.STATE_PLAYING)
        #player.set_state(gst.STATE_PLAYING, rate) ne fonctionne pas
    print 'playing...'

#
# tkinter widgets
#
widget_master= Tk()

#
# file frame
#
frame_file= LabelFrame(widget_master, text= " File ")
frame_file.grid(sticky= NW)
field_file= Entry(frame_file, width= 128)
field_file.grid()
button_select= Button(frame_file, text= 'Select File', command=get_file)
button_select.grid(pady= 8)

#
# video frame
#
frame_video= LabelFrame(widget_master, text= " Video ")
frame_video.grid(row= 1, column= 0, sticky= NW)
field_video= Canvas(frame_video, width= 512, height= 384, bg= 'black')
field_video.grid()
print 'video window id:', field_video.winfo_id()

#Scale
var = DoubleVar()
myscale = Scale( frame_file, from_=0.0, to=2.0, variable = var, length=200, 
                                     command=onMove,
                                     tickinterval=0.2,
                                     showvalue=YES,
                                    resolution=2.0
                                    orient=HORIZONTAL) )
myscale.pack(anchor=CENTER)

#
# gstreamer setup
#
player = gst.element_factory_make("playbin", "player")
bus = player.get_bus()
bus.add_signal_watch()
bus.enable_sync_message_emission()
bus.connect("message", on_message)
bus.connect("sync-message::element", on_sync_message)
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.