Script de boucle automatique pour MPV
This commit is contained in:
parent
478ed2756f
commit
337a89b88e
1 changed files with 17 additions and 0 deletions
17
.config/mpv/scripts/auto-loop.lua
Normal file
17
.config/mpv/scripts/auto-loop.lua
Normal file
|
@ -0,0 +1,17 @@
|
|||
function auto_loop()
|
||||
local file_duration = mp.get_property_number("duration", 0)
|
||||
-- Images have a duration of 0, so don’t 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)
|
Loading…
Reference in a new issue