updates for new API
authorThomas Vander Stichele <thomas@apestaart.org>
Thu, 18 Mar 2004 15:51:54 +0000 (15:51 +0000)
committerThomas Vander Stichele <thomas@apestaart.org>
Thu, 18 Mar 2004 15:51:54 +0000 (15:51 +0000)
Original commit message from CVS:
updates for new API

ChangeLog
examples/gst/player.py
examples/gst/vorbisplay.py

index 17ec4dd..4ff0b14 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,12 @@
 2004-03-18  Thomas Vander Stichele  <thomas at apestaart dot org>
 
+       * examples/gst/player.py:
+          update for new API.  Use Enter to pause pipeline.
+       * examples/gst/vorbisplay.py:
+          update for new API
+
+2004-03-18  Thomas Vander Stichele  <thomas at apestaart dot org>
+
        * configure.ac:
           subst GST_MAJORMINOR
        * docs/Makefile.am:
index 08b7bf6..eccbd24 100755 (executable)
@@ -1,3 +1,4 @@
+#!/usr/bin/env python
 import os
 import sys
 
@@ -5,31 +6,59 @@ import gst
 
 def found_tags(element, source, tags):
     for tag in tags.keys():
-        print gst.tag_get_nick(tag), tags[tag]
+        print "%s: %s" % (gst.tag_get_nick(tag), tags[tag])
+
+#def error(source, error, debug):
+
+def deep_notify(*args):
+    pass
+
+def error(*args):
+    print args
 
 def playfile(filename):
     bin = gst.Pipeline('player')
+    bin.connect('deep-notify', deep_notify)
+    bin.connect('error', error)
     
     source = gst.Element('filesrc', 'src')
     source.set_property('location', filename)
 
     spider = gst.Element('spider', 'spider')
     spider.connect('found-tag', found_tags)
-
+    
     sink = gst.Element('osssink', 'sink')
+    #sink.set_property('release-device', 1)
 
     bin.add_many(source, spider, sink)
-    gst.element_link_many(source, spider, sink)
+    if not gst.element_link_many(source, spider, sink):
+        print "ERROR: could not link"
+        sys.exit (1)
 
     print 'Playing:', os.path.basename(filename)
-    bin.set_state(gst.STATE_PLAYING)
+    if not bin.set_state(gst.STATE_PLAYING):
+        print "ERROR: could not set bin to playing"
+        sys.exit (1)
 
-    try:
-        while bin.iterate():
-            pass
-    except KeyboardInterrupt:
-        pass
-    
+    playing = 1
+    while playing:
+        try:
+             if not bin.iterate():
+                 playing = 0
+        except KeyboardInterrupt:
+            if not bin.set_state(gst.STATE_PAUSED):
+                print "ERROR: could not set bin to paused"
+                sys.exit (1)
+           print "Paused.  Press Enter to go back to playing."
+            try:
+                sys.stdin.readline ()
+                if not bin.set_state(gst.STATE_PLAYING):
+                    print "ERROR: could not set bin to playing"
+                    sys.exit (1)
+               print "Playing."
+            except KeyboardInterrupt:
+                playing = 0 
+    print "DONE playing"
     bin.set_state(gst.STATE_NULL)
 
 def main(args):
index acb9dd0..577a66c 100755 (executable)
@@ -22,7 +22,7 @@
 #
 
 import sys
-from gstreamer import *
+from gst import *
 
 def gst_props_debug_entry(entry, level=0):
     name = entry.get_name()