summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorEdward Hervey <bilboed@bilboed.com>2005-11-04 10:14:22 +0000
committerEdward Hervey <bilboed@bilboed.com>2005-11-04 10:14:22 +0000
commit6dd77f1aa42b8e279a923dc4556b1a946603ca94 (patch)
tree0fcea99e7f555c6000e9bcd2d673848693c6571b /examples
parent207d16443d227c3bade3ebc13043fbf4a5db3050 (diff)
examples/play.py: Fixed the play example to work with 0.9.4 API
Original commit message from CVS: * examples/play.py: Fixed the play example to work with 0.9.4 API
Diffstat (limited to 'examples')
-rw-r--r--examples/play.py29
1 files changed, 21 insertions, 8 deletions
diff --git a/examples/play.py b/examples/play.py
index 5d644d3..7563e81 100644
--- a/examples/play.py
+++ b/examples/play.py
@@ -4,6 +4,9 @@ pygtk.require('2.0')
import sys
import gobject
+
+import pygst
+pygst.require('0.9')
import gst
import gst.interfaces
import gtk
@@ -21,11 +24,21 @@ class GstPlayer:
def query_position(self):
"Returns a (position, duration) tuple"
- ret = self.player.query_position(gst.FORMAT_TIME)
- if not ret:
- return (gst.CLOCK_TIME_NONE, gst.CLOCK_TIME_NONE, gst.FORMAT_TIME)
+ try:
+ ret = self.player.query_position(gst.FORMAT_TIME)
+ except:
+ position = gst.CLOCK_TIME_NONE
+ else:
+ position = ret[0]
+
+ try:
+ ret = self.player.query_duration(gst.FORMAT_TIME)
+ except:
+ duration = gst.CLOCK_TIME_NONE
+ else:
+ duration = ret[0]
- return ret
+ return (position, duration, ret[1])
def seek(self, location):
"""
@@ -57,12 +70,12 @@ class GstPlayer:
self.player.set_state(gst.STATE_READY)
gst.info("stopped player")
- def get_state(self, timeout=0.050):
+ def get_state(self, timeout=1):
return self.player.get_state(timeout=timeout)
def is_in_state(self, state):
gst.debug("checking if player is in state %r" % state)
- cur, pen, final = self.get_state(timeout=0.0)
+ cur, pen, final = self.get_state(timeout=0)
gst.debug("checked if player is in state %r" % state)
if pen == gst.STATE_VOID_PENDING and cure == state:
return True
@@ -127,7 +140,7 @@ class PlayerWindow(gtk.Window):
vbox.pack_start(self.videowidget)
hbox = gtk.HBox()
- vbox.pack_start(hbox)
+ vbox.pack_start(hbox, fill=False, expand=False)
button = gtk.Button('play')
button.connect('clicked', self.play_clicked_cb)
@@ -184,7 +197,7 @@ class PlayerWindow(gtk.Window):
gst.debug('value changed, perform seek to %r' % real)
self.player.seek(real)
# allow for a preroll
- self.player.get_state(timeout=0.050) # 50 ms
+ self.player.get_state(timeout=50) # 50 ms
def scale_button_release_cb(self, widget, event):
# see seek.cstop_seek