fix selected index not updating with current index

This commit is contained in:
ksyasuda@umich.edu 2023-08-02 16:54:02 -07:00
parent b8ef352bf5
commit e1e033f37d

View File

@ -112,6 +112,7 @@ function YouTubeQueue.add_to_queue(video) table.insert(video_queue, video) end
function YouTubeQueue.next_in_queue() function YouTubeQueue.next_in_queue()
if index < #video_queue then if index < #video_queue then
index = index + 1 index = index + 1
selected_index = index
current_video = video_queue[index] current_video = video_queue[index]
return current_video return current_video
end end
@ -120,6 +121,7 @@ end
function YouTubeQueue.prev_in_queue() function YouTubeQueue.prev_in_queue()
if index > 1 then if index > 1 then
index = index - 1 index = index - 1
selected_index = index
current_video = video_queue[index] current_video = video_queue[index]
else else
current_video = video_queue[1] current_video = video_queue[1]
@ -133,6 +135,7 @@ function YouTubeQueue.play_video_at(idx)
return nil return nil
end end
index = idx index = idx
selected_index = index
current_video = video_queue[index] current_video = video_queue[index]
mp.set_property_number("playlist-pos", index - 1) -- zero-based index mp.set_property_number("playlist-pos", index - 1) -- zero-based index
return current_video return current_video
@ -154,6 +157,7 @@ function YouTubeQueue.update_current_index()
end end
-- if not found, reset the index -- if not found, reset the index
index = 0 index = 0
selected_index = index
current_video = YouTubeQueue.get_video_at(index) current_video = YouTubeQueue.get_video_at(index)
end end