Closed S0yKaf closed 2 years ago
So I did some more digging. cloned the repo and ran the tests. all green.
inside my code I found a couple things.
using the on_key_press(event)
decorator will throw the AttributeError
but using register_key_binding()
will work.
# Will throw Attribute Error
@player.on_key_press('down')
def my_down_binding(key_state, key_name, key_char):
value = player._get_property('playback-time')
time_ms = int(value * 1000)
print(time_ms)
sync_play(time_ms, 'true')
# Will Work
def my_down_binding(key_state, key_name, key_char):
value = player._get_property('playback-time')
time_ms = int(value * 1000)
print(time_ms)
sync_play(time_ms, 'true')
player.register_key_binding("down", my_down_binding)
The same is true for event callbacks:
# AttributeError: type object 'MpvEventID' has no attribute 'PAUSE'
@player.event_callback('pause')
def video_pause(event):
sync_play(0, 'false')
# Works
def on_event(event):
e = event.as_dict(decoder=mpv.lazy_decoder)["event"]
match e:
case "pause":
video_pause(event)
player.register_event_callback(on_event)
I ended up fixing my code, but there was a lot of changes needed. on last thing I found was that
mpv.quit()
stopped working but calling mpv.command("quit")
works as intended.
so I'm definitely thinking things changed in the libmpv or something is very wrong with my setup.
Line 278 or thereabouts of recent releases of mpv.py seems to be in the middle of a class definition yet your error seems to point to it being in the middle of the event logic:
File "/home/kiniamaro/.local/lib/python3.10/site-packages/mpv.py", line 278, in mpv_event_extractor for event in _event_generator(self.handle):
Nor is there any current method called 'mpv_event_extractor'.
Do you perhaps have some older version of the mpv.py installed by your package manager rather than pip?
Line 278 or thereabouts of recent releases of mpv.py seems to be in the middle of a class definition yet your error seems to point to it being in the middle of the event logic:
File "/home/kiniamaro/.local/lib/python3.10/site-packages/mpv.py", line 278, in mpv_event_extractor for event in _event_generator(self.handle):
Nor is there any current method called 'mpv_event_extractor'.
Do you perhaps have some older version of the mpv.py installed by your package manager rather than pip?
Seems like you're right, I just re-tested my example and now it works. no idea how this happened. I think what was happening was that I have a bash script to run my app and activate the venv. but the part that activate the venv wasn't actually working so it was grabbing my none pip version of the lib which was indeed not 1.0.1.
I'll be closing the issue. Thanks for looking into this.
After I upgraded my system, I started getting these errors.
They happen as far as I call tell, on every function call that use the
mpv.MPV
object. suspecting something is broken with the libmpv bindings.python version:
3.10.4
libmpv version:libmpv.so.1.109.0
mpv version:1:0.34.1-4
kernel:5.17.9-arch1-1
Minimal Reproduction
Trackback:
Let me know if you need any more info from me. On my side I'll do some more digging tomorrow.