Script de boucle automatique pour MPV

This commit is contained in:
Breizh 2024-08-05 22:09:12 +02:00
parent 478ed2756f
commit 337a89b88e

View file

@ -0,0 +1,17 @@
function auto_loop()
local file_duration = mp.get_property_number("duration", 0)
-- Images have a duration of 0, so dont loop and use
-- image-display-duration instead
if file_duration == 0 then
mp.set_property("loop-file", "no")
-- If a GIF or video have duration shorter than 30 seconds
-- make it loop for at least 30 seconds
elseif file_duration < 30 then
mp.set_property("loop-file", math.floor(30 / file_duration))
-- For longer file, play it only once
else
mp.set_property("loop-file", "no")
end
end
mp.register_event("file-loaded", auto_loop)