@@ -41,6 +41,10 @@ function Thumbnailer:on_thumb_ready(index)
4141 end
4242end
4343
44+ function Thumbnailer :on_thumb_progress (index )
45+ self .state .thumbnails [index ] = self .state .thumbnails [index ] or false
46+ end
47+
4448function Thumbnailer :on_video_change (params )
4549 self :clear_state ()
4650 if params ~= nil then
@@ -172,7 +176,7 @@ function Thumbnailer:get_closest(thumbnail_index)
172176
173177 for index , value in pairs (self .state .thumbnails ) do
174178 local distance = math.abs (index - thumbnail_index )
175- if distance < min_distance then
179+ if distance < min_distance and value then
176180 min_distance = distance
177181 closest = index
178182 end
@@ -193,9 +197,14 @@ function Thumbnailer:get_thumbnail_path(time_position)
193197end
194198
195199function Thumbnailer :register_client ()
196- mp .register_script_message (" mpv_thumbnail_script-ready" , function (index , path ) self :on_thumb_ready (tonumber (index ), path ) end )
197200 -- Wait for server to tell us we're live
198201 mp .register_script_message (" mpv_thumbnail_script-enabled" , function () self .state .enabled = true end )
202+ mp .register_script_message (" mpv_thumbnail_script-ready" , function (index , path )
203+ self :on_thumb_ready (tonumber (index ), path )
204+ end )
205+ mp .register_script_message (" mpv_thumbnail_script-progress" , function (index , path )
206+ self :on_thumb_progress (tonumber (index ), path )
207+ end )
199208
200209 -- Notify server to generate thumbnails when video loads/changes
201210 mp .observe_property (" video-dec-params" , " native" , function ()
0 commit comments