1 ### Start of footer.py ###
3 class MediaEvent(ctypes.Structure):
5 ('media_name', ctypes.c_char_p),
6 ('instance_name', ctypes.c_char_p),
9 class EventUnion(ctypes.Union):
11 ('meta_type', ctypes.c_uint),
12 ('new_child', ctypes.c_uint),
13 ('new_duration', ctypes.c_longlong),
14 ('new_status', ctypes.c_int),
15 ('media', ctypes.c_void_p),
16 ('new_state', ctypes.c_uint),
18 ('new_position', ctypes.c_float),
19 ('new_time', ctypes.c_longlong),
20 ('new_title', ctypes.c_int),
21 ('new_seekable', ctypes.c_longlong),
22 ('new_pausable', ctypes.c_longlong),
23 # FIXME: Skipped MediaList and MediaListView...
24 ('filename', ctypes.c_char_p),
25 ('new_length', ctypes.c_longlong),
26 ('media_event', MediaEvent),
29 class Event(ctypes.Structure):
32 ('object', ctypes.c_void_p),
36 # Decorator for callback methods
37 callbackmethod=ctypes.CFUNCTYPE(None, Event, ctypes.c_void_p)
39 # Example callback method
41 def debug_callback(event, data):
42 print "Debug callback method"
43 print "Event:", event.type
46 if __name__ == '__main__':
49 from msvcrt import getch
55 old_settings=termios.tcgetattr(fd)
60 termios.tcsetattr(fd, termios.TCSADRAIN, old_settings)
64 def end_callback(event, data):
69 if sys.platform == 'win32' and plugin_path is not None:
70 i=Instance('--plugin-path', plugin_path)
73 m=i.media_new(sys.argv[1])
74 p=i.media_player_new()
79 e.event_attach(EventType.MediaPlayerEndReached, end_callback, None)
82 """Print information about the media."""
84 print "State:", p.get_state()
85 print "Media:", m.get_mrl()
87 print "Current time:", p.get_time(), "/", m.get_duration()
88 print "Position:", p.get_position()
89 print "FPS:", p.get_fps()
90 print "Rate:", p.get_rate()
91 print "Video size: (%d, %d)" % (p.video_get_width(), p.video_get_height())
97 p.set_time(p.get_time() + 1000)
99 def one_frame_forward():
100 """Go forward one frame"""
101 p.set_time(p.get_time() + long(1000 / (p.get_fps() or 25)))
103 def one_frame_backward():
104 """Go backward one frame"""
105 p.set_time(p.get_time() - long(1000 / (p.get_fps() or 25)))
109 p.set_time(p.get_time() - 1000)
115 for k, m in keybindings.iteritems():
116 print " %s: %s" % (k, (m.__doc__ or m.__name__).splitlines()[0])
117 print " 1-9: go to the given fraction of the movie"
124 'f': p.toggle_fullscreen,
128 '.': one_frame_forward,
129 ',': one_frame_backward,
135 print "Press q to quit, ? to get help."
139 method=keybindings.get(k, None)
140 if method is not None:
142 elif o >= 49 and o <= 57:
143 # Numeric value. Jump to a fraction of the movie.