playback controls

This commit is contained in:
2025-09-05 14:57:14 +02:00
parent 60f7426709
commit e9fafe278f
4 changed files with 108 additions and 13 deletions

View File

@@ -22,6 +22,11 @@ mpv_playlist_position() {
__mpv_get '${playlist-pos}'
}
mpv_playlist_move() {
debug "moving $1 -> $2"
__mpv_command_with_args2 "playlist-move" "$1" "$2" >>/tmp/foo 2>/dev/stdout
}
mpv_quit() {
__mpv_command "quit"
}
@@ -47,6 +52,22 @@ mpv_queue_list() {
rm -f "$t"
}
mpv_queue_next_list() {
t=$(mktemp)
cat >"$t"
pos=$(mpv_playlist_position)
cnt1=$(mpv_playlist_count)
__mpv_command_with_args2 "loadlist" "$t" "append-play"
rm -f "$t"
cnt2=$(mpv_playlist_count)
diff=$((cnt2 - cnt1))
[ "$diff" -gt 0 ] || return
# Move added items right after current item (numbers are 0 based)
for i in $(seq "$diff"); do
mpv_playlist_move $((cnt1 + i - 1)) $((pos + i))
done
}
mpv_next() {
__mpv_command "playlist-next"
}