├── README.md └── on_top_only_while_playing.lua /README.md: -------------------------------------------------------------------------------- 1 | # mpv-ontop-only-while-playing-lua 2 | 3 | changes the behavior of ontop mode to only 4 | stay on top only while playing, and only if 5 | if ontop is currently enabled 6 | -------------------------------------------------------------------------------- /on_top_only_while_playing.lua: -------------------------------------------------------------------------------- 1 | -- ============================================= 2 | -- Ontop Only When Playing v1.0 | 3 | -- Author: David Gomez | 4 | -- ============================================= 5 | -- changes the behavior of ontop mode to only | 6 | -- stay on top only while playing, and only if | 7 | -- if ontop is currently enabled | 8 | -- ============================================= 9 | 10 | was_ontop = mp.get_property_native("ontop") 11 | 12 | function f_load(event) 13 | if was_ontop then 14 | mp.set_property_native("ontop", true) 15 | end 16 | end 17 | 18 | mp.register_event("file-loaded", f_load) 19 | 20 | mp.observe_property("pause", "bool", function(name, value) 21 | 22 | local ontop = mp.get_property_native("ontop") 23 | local is_idle = mp.get_property_native("playback-abort") 24 | 25 | if value then 26 | mp.set_property_native("ontop", false) 27 | was_ontop = ontop 28 | else 29 | if is_idle then 30 | mp.set_property_native("ontop", false) 31 | was_ontop = ontop 32 | else 33 | if was_ontop then 34 | mp.set_property_native("ontop", true) 35 | end 36 | end 37 | end 38 | end) 39 | --------------------------------------------------------------------------------