1
0
mirror of https://github.com/mpv-player/mpv synced 2025-04-25 12:50:18 +00:00
mpv/TOOLS/python/ontop-playback.py
8lurry fea5db26bb
python: optimize source, add feature
- lint
- better error message through check_error when mpv api(s) return with an error
- add function hook_add
- add function hook_continue
- add event handler for MPV_EVENT_HOOK
2025-04-09 13:43:16 +06:00

22 lines
597 B
Python

# makes mpv disable ontop when pausing and re-enable it again when resuming playback
# please note that this won't do anything if ontop was not enabled before pausing
from mpvclient import mpv # type: ignore
was_ontop = False
@mpv.observe_property("pause", mpv.MPV_FORMAT_FLAG)
def func(value):
ontop = mpv.get_property_node("ontop")
global was_ontop
if value:
if ontop:
mpv.set_property_node("ontop", False)
was_ontop = True
else:
if was_ontop and not ontop:
mpv.set_property_node("ontop", True)
was_ontop = False