[vlc-devel] commit: python-ctypes: give running example (Olivier Aubert )

git version control git at videolan.org
Mon Aug 3 17:20:00 CEST 2009


vlc | branch: master | Olivier Aubert <olivier.aubert at liris.cnrs.fr> | Mon Aug  3 17:18:53 2009 +0200| [91f06acc35696e479c441dc6e69c166659a74435] | committer: Olivier Aubert 

python-ctypes: give running example

Invoking
python vlc.py filename.avi
will play the given movie.

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=91f06acc35696e479c441dc6e69c166659a74435
---

 bindings/python-ctypes/footer.py |   18 +++++++++++++++---
 bindings/python-ctypes/header.py |    2 ++
 2 files changed, 17 insertions(+), 3 deletions(-)

diff --git a/bindings/python-ctypes/footer.py b/bindings/python-ctypes/footer.py
index 6c0d788..9847e30 100644
--- a/bindings/python-ctypes/footer.py
+++ b/bindings/python-ctypes/footer.py
@@ -40,14 +40,26 @@ callbackmethod=ctypes.CFUNCTYPE(None, Event, ctypes.c_void_p)
 @callbackmethod
 def debug_callback(event, data):
     print "Debug callback method"
-    print "Event:", event
+    print "Event:", event.type
     print "Data", data
 
 if __name__ == '__main__':
     import sys
+    import gobject
+
+    @callbackmethod
+    def end_callback(event, data):
+        print "End of stream"
+        sys.exit(0)
+
     if sys.argv[1:]:
-        i=vlc.Instance()
+        i=Instance()
         m=i.media_new(sys.argv[1])
-        p=MediaPlayer()
+        p=i.media_player_new()
         p.set_media(m)
         p.play()
+        # Loop
+        e=p.event_manager()
+        e.event_attach(EventType.MediaPlayerPaused, end_callback, None)
+        gobject.MainLoop().run()
+
diff --git a/bindings/python-ctypes/header.py b/bindings/python-ctypes/header.py
index 840bb33..6d63da7 100755
--- a/bindings/python-ctypes/header.py
+++ b/bindings/python-ctypes/header.py
@@ -154,3 +154,5 @@ def check_vlc_exception(result, func, args):
     if c:
         raise Exception(args[-1].message)
     return result
+
+### End of header.py ###




More information about the vlc-devel mailing list