Commit 91f06acc authored by Olivier Aubert's avatar Olivier Aubert

python-ctypes: give running example

Invoking
python vlc.py filename.avi
will play the given movie.
parent cdb7b4af
...@@ -40,14 +40,26 @@ callbackmethod=ctypes.CFUNCTYPE(None, Event, ctypes.c_void_p) ...@@ -40,14 +40,26 @@ callbackmethod=ctypes.CFUNCTYPE(None, Event, ctypes.c_void_p)
@callbackmethod @callbackmethod
def debug_callback(event, data): def debug_callback(event, data):
print "Debug callback method" print "Debug callback method"
print "Event:", event print "Event:", event.type
print "Data", data print "Data", data
if __name__ == '__main__': if __name__ == '__main__':
import sys import sys
import gobject
@callbackmethod
def end_callback(event, data):
print "End of stream"
sys.exit(0)
if sys.argv[1:]: if sys.argv[1:]:
i=vlc.Instance() i=Instance()
m=i.media_new(sys.argv[1]) m=i.media_new(sys.argv[1])
p=MediaPlayer() p=i.media_player_new()
p.set_media(m) p.set_media(m)
p.play() p.play()
# Loop
e=p.event_manager()
e.event_attach(EventType.MediaPlayerPaused, end_callback, None)
gobject.MainLoop().run()
...@@ -154,3 +154,5 @@ def check_vlc_exception(result, func, args): ...@@ -154,3 +154,5 @@ def check_vlc_exception(result, func, args):
if c: if c:
raise Exception(args[-1].message) raise Exception(args[-1].message)
return result return result
### End of header.py ###
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment