Last active
May 27, 2017 05:54
-
-
Save myfreeer/fdf4b0b9ec2850dad29feb15c5fe7a17 to your computer and use it in GitHub Desktop.
mpv userscript to make mpv play videos on top when playing and playback window height larger then screen height (needed to be specified in script)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- mpv userscript to make mpv play videos on top when playing and playback window height larger then screen height | |
local was_ontop = true | |
-- specify screen height here | |
local screen_height = 768 | |
function playbackEventListener(name, value) | |
local ontop = mp.get_property_native("ontop") | |
local dheight = mp.get_property_native("dheight",0)*mp.get_property_native("window-scale",0) | |
if value or mp.get_property_native("filename","") == "" or mp.get_property_native("pause") or (dheight < screen_height - 80) then | |
mp.set_property_native("ontop", false) | |
was_ontop = true | |
-- mp.msg.info("not on top"..dheight) | |
else | |
mp.set_property_native("ontop", true) | |
was_ontop = false | |
end | |
end | |
mp.observe_property("pause", "bool", playbackEventListener) | |
mp.register_event("file-loaded", function (event) | |
mp.add_timeout(0.3, playbackEventListener) | |
end) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment