jaseg / python-mpv

Python interface to the awesome mpv media player
https://git.jaseg.de/python-mpv.git
Other
547 stars 68 forks source link

input_default_bindings not working on macOS #63

Closed kpj closed 6 years ago

kpj commented 6 years ago

Hello,

Time for another macOS related issue ( :-[ ). As explained in #61, an extra QT-Window needs to be created for python-mpv to work on macOS.

If I now take the PyQT embedding example from the README and add input_default_bindings=True, input_vo_keyboard=True to the MPV instantiation, I would expect mpv-commands such as space (for pausing) or o (for time-display) to work. On linux, it does indeed work. On macOS however, nothing happens.

Do you have a suggestion why this might be happening? (PyQT not forwarding keypress-events, ...)

jaseg commented 6 years ago

Sorry, I have no idea. Maybe focus order, in that on mac your window is not in focus?

kpj commented 6 years ago

I investigated this using a custom keyPressEvent method in the QMainWindow and it does receive the key-events. I also added custom @player.on_key_press bindings to my MPV class, but they were never triggered.

Is there a way of simulating keypresses using python-mpv? That way I could catch key-events in PyQT's keyPressEvent method and propagate them manually. This is of course a very dirty solution, but the best I could think of so far.

Frechdachs commented 6 years ago

Is there a way of simulating keypresses using python-mpv?

For example: mpvobject.command('keypress', 'ctrl+a')

kpj commented 6 years ago

That works nicely, thanks a lot! For now I'll stick to this workaround.