Fix script auto-loop
This commit is contained in:
parent
337a89b88e
commit
a247b31c91
2 changed files with 13 additions and 9 deletions
|
@ -1,17 +1,20 @@
|
|||
function auto_loop()
|
||||
local max = 5
|
||||
local file_duration = mp.get_property_number("duration", 0)
|
||||
print(file_duration)
|
||||
-- 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))
|
||||
-- If a GIF or video have duration shorter than <max> seconds
|
||||
-- make it loop for at least <max> seconds
|
||||
elseif file_duration < max then
|
||||
mp.set_property("loop-file", math.floor(max / file_duration))
|
||||
-- For longer file, play it only once
|
||||
else
|
||||
mp.set_property("loop-file", "no")
|
||||
end
|
||||
print(mp.get_property("loop-file"))
|
||||
end
|
||||
|
||||
mp.register_event("file-loaded", auto_loop)
|
|
@ -29,18 +29,19 @@ do
|
|||
# le chemin.
|
||||
[[ -f "/${title}" ]] && title="$(basename "$title")"
|
||||
|
||||
# Si ce n’est pas un fichier sur le disque, c’est probablement
|
||||
# un stream, donc on ne remplace l’URL que pour les locaux.
|
||||
[[ -f "$HOME/Musique/${file}" ]] && file="https://fichiers.breizh.pm/Musique/${file}"
|
||||
|
||||
|
||||
# Si aucune information n’est retournée, c’est que la lecture
|
||||
# s’est arrêtée.
|
||||
if [[ "${#infos[@]}" -eq 0 ]]
|
||||
then
|
||||
title="<i>Arrêt</i>"
|
||||
unset artist title album length
|
||||
unset artist title album length file
|
||||
fi
|
||||
|
||||
# Si ce n’est pas un fichier sur le disque, c’est probablement
|
||||
# un stream, donc on ne remplace l’URL que pour les locaux.
|
||||
[[ -f "$HOME/Musique/${file}" ]] && file="https://fichiers.breizh.pm/Musique/${file}"
|
||||
|
||||
# Notification du morceau
|
||||
dunstify -i mpd -r "$DUNST_ID" "MPD" "${artist:+${artist}$'\n'}${title}"$'\n'"${album}"
|
||||
|
||||
|
|
Loading…
Reference in a new issue