Improve event handling, add message handling, add key binding foo
This commit is contained in:
parent
de7b671103
commit
ab8b8b5477
3 changed files with 73 additions and 12 deletions
|
|
@ -30,7 +30,7 @@ import mpv
|
|||
def my_log(loglevel, component, message):
|
||||
print('[{}] {}: {}'.format(loglevel, component, message))
|
||||
|
||||
player = mpv.MPV(log_handler=my_log, ytdl=True)
|
||||
player = mpv.MPV(log_handler=my_log, ytdl=True, input_default_bindings=True, input_vo_keyboard=True)
|
||||
|
||||
# Property access, these can be changed at runtime
|
||||
player.observe_property('time-pos', lambda _property, pos: print('Now playing at {:.2f}s'.format(pos)))
|
||||
|
|
@ -39,6 +39,11 @@ player.loop = 'inf'
|
|||
# Option access, in general these require the core to reinitialize
|
||||
player['vo'] = 'opengl'
|
||||
|
||||
def my_q_binding(state, key):
|
||||
if state[0] == 'd':
|
||||
print('THERE IS NO ESCAPE')
|
||||
player.register_key_binding('q', my_q_binding)
|
||||
|
||||
player.play('https://youtu.be/DLzxrzFCyOs')
|
||||
player.wait_for_playback()
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue