From c94ff7dcf2766a6e74166bcd340d3cdc7342374c Mon Sep 17 00:00:00 2001 From: "ksyasuda@umich.edu" Date: Sat, 5 Aug 2023 18:08:48 -0700 Subject: [PATCH] fix first video not playing when opening video though app Fix mpv not switching to and playing first video in queue when adding from the dekstop application --- mpv-youtube-queue.lua | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/mpv-youtube-queue.lua b/mpv-youtube-queue.lua index 0acc52b..c4e1472 100644 --- a/mpv-youtube-queue.lua +++ b/mpv-youtube-queue.lua @@ -383,6 +383,11 @@ function YouTubeQueue.play_next_in_queue() local current_index = YouTubeQueue.get_current_index() if YouTubeQueue.size() > 1 then mp.set_property_number("playlist-pos", current_index - 1) + else + local state = mp.get_property("core-idle") + if state == "yes" then + mp.commandv("loadfile", next_video.video_url, "replace") + end end print_current_video() selected_index = current_index @@ -503,10 +508,12 @@ local function on_track_changed() YouTubeQueue.update_current_index() end -- Function to be called when the playback-restart event is triggered local function on_playback_restart() local playlist_size = mp.get_property_number("playlist-count", 0) + local state = mp.get_property("core-idle") if playlist_size > 1 then YouTubeQueue.update_current_index() - else + elseif state == "yes" then -- 1 item in playlist and not currently playing local url = mp.get_property("path") + print_osd_message("CHECKING URL: " .. url, MSG_DURATION) YouTubeQueue.add_to_queue(url, false) end end