From 1211d68dcbc510f1296d6a5fa4da3171ee79cc1e Mon Sep 17 00:00:00 2001 From: "ksyasuda@umich.edu" Date: Wed, 2 Aug 2023 14:06:33 -0700 Subject: [PATCH] account for 0 based indexing in playlists --- mpv-youtube-queue.lua | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/mpv-youtube-queue.lua b/mpv-youtube-queue.lua index c476af4..441e0b3 100644 --- a/mpv-youtube-queue.lua +++ b/mpv-youtube-queue.lua @@ -133,8 +133,8 @@ function YouTubeQueue.play_video_at(idx) end index = idx current_video = video_queue[index] - mp.commandv("loadfile", current_video.url, "append-play") - mp.set_property_number("playlist-pos", index) + mp.msg.log("info", "Playing video at index " .. index) + mp.set_property_number("playlist-pos", index - 1) -- zero-based index return current_video end @@ -244,8 +244,7 @@ local function play_next_in_queue() local next_video_url = next_video.url print_video_name(next_video) if YouTubeQueue.size() > 1 then - mp.commandv("loadfile", next_video_url, "append-play") - mp.set_property_number("playlist-pos", YouTubeQueue.get_current_index()) + mp.set_property_number("playlist-pos", YouTubeQueue.get_current_index() - 1) else mp.commandv("loadfile", next_video_url, "replace") end @@ -279,10 +278,8 @@ local function play_previous_video() mp.osd_message("No previous video available.") return end - local previous_video_url = previous_video.url print_video_name(previous_video) - mp.commandv("loadfile", previous_video_url, "append-play") - mp.set_property_number("playlist-pos", YouTubeQueue.get_current_index()) + mp.set_property_number("playlist-pos", YouTubeQueue.get_current_index() - 1) end local function open_url_in_browser(url)