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()
|
function auto_loop()
|
||||||
|
local max = 5
|
||||||
local file_duration = mp.get_property_number("duration", 0)
|
local file_duration = mp.get_property_number("duration", 0)
|
||||||
|
print(file_duration)
|
||||||
-- Images have a duration of 0, so don’t loop and use
|
-- Images have a duration of 0, so don’t loop and use
|
||||||
-- image-display-duration instead
|
-- image-display-duration instead
|
||||||
if file_duration == 0 then
|
if file_duration == 0 then
|
||||||
mp.set_property("loop-file", "no")
|
mp.set_property("loop-file", "no")
|
||||||
-- If a GIF or video have duration shorter than 30 seconds
|
-- If a GIF or video have duration shorter than <max> seconds
|
||||||
-- make it loop for at least 30 seconds
|
-- make it loop for at least <max> seconds
|
||||||
elseif file_duration < 30 then
|
elseif file_duration < max then
|
||||||
mp.set_property("loop-file", math.floor(30 / file_duration))
|
mp.set_property("loop-file", math.floor(max / file_duration))
|
||||||
-- For longer file, play it only once
|
-- For longer file, play it only once
|
||||||
else
|
else
|
||||||
mp.set_property("loop-file", "no")
|
mp.set_property("loop-file", "no")
|
||||||
end
|
end
|
||||||
|
print(mp.get_property("loop-file"))
|
||||||
end
|
end
|
||||||
|
|
||||||
mp.register_event("file-loaded", auto_loop)
|
mp.register_event("file-loaded", auto_loop)
|
|
@ -29,18 +29,19 @@ do
|
||||||
# le chemin.
|
# le chemin.
|
||||||
[[ -f "/${title}" ]] && title="$(basename "$title")"
|
[[ -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
|
# Si aucune information n’est retournée, c’est que la lecture
|
||||||
# s’est arrêtée.
|
# s’est arrêtée.
|
||||||
if [[ "${#infos[@]}" -eq 0 ]]
|
if [[ "${#infos[@]}" -eq 0 ]]
|
||||||
then
|
then
|
||||||
title="<i>Arrêt</i>"
|
title="<i>Arrêt</i>"
|
||||||
unset artist title album length
|
unset artist title album length file
|
||||||
fi
|
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
|
# Notification du morceau
|
||||||
dunstify -i mpd -r "$DUNST_ID" "MPD" "${artist:+${artist}$'\n'}${title}"$'\n'"${album}"
|
dunstify -i mpd -r "$DUNST_ID" "MPD" "${artist:+${artist}$'\n'}${title}"$'\n'"${album}"
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue