diff --git a/scripts/uosc.lua b/scripts/uosc.lua index 7adac550..a3e623a7 100644 --- a/scripts/uosc.lua +++ b/scripts/uosc.lua @@ -541,8 +541,16 @@ function update_mouse_pos(_, mouse, ignore_hover) end mp.observe_property('mouse-pos', 'native', update_mouse_pos) mp.observe_property('osc', 'bool', function(name, value) if value == true then mp.set_property('osc', 'no') end end) + +function clear_thumbnail() + if not thumbnail_state.render.thumbnail then return end + mp.commandv('script-message-to', 'thumbfast', 'clear') + thumbnail_state.render.thumbnail = false + thumbnail_state.updated = true +end mp.register_event('file-loaded', function() set_state('path', normalize_path(mp.get_property_native('path'))) + clear_thumbnail() end) mp.register_event('end-file', function(event) if event.reason == 'eof' then diff --git a/scripts/uosc_shared/elements/Timeline.lua b/scripts/uosc_shared/elements/Timeline.lua index 0ce7a66e..3f57da1f 100644 --- a/scripts/uosc_shared/elements/Timeline.lua +++ b/scripts/uosc_shared/elements/Timeline.lua @@ -84,11 +84,6 @@ function Timeline:set_from_cursor(fast) mp.commandv('seek', self:get_time_at_x(cursor.x), fast and 'absolute+keyframes' or 'absolute+exact') end end -function Timeline:clear_thumbnail() - mp.commandv('script-message-to', 'thumbfast', 'clear') - thumbnail_state.render.thumbnail = false - thumbnail_state.updated = true -end function Timeline:on_mbtn_left_down() self.pressed = true @@ -101,17 +96,14 @@ function Timeline:on_prop_time() self:decide_enabled() end function Timeline:on_prop_border() self:update_dimensions() end function Timeline:on_prop_fullormaxed() self:update_dimensions() end function Timeline:on_display() self:update_dimensions() end -function Timeline:on_mouse_leave() self:clear_thumbnail() end function Timeline:on_global_mbtn_left_up() if self.pressed then mp.set_property_native('pause', self.pressed_pause) self.pressed = false end - self:clear_thumbnail() end function Timeline:on_global_mouse_leave() self.pressed = false - self:clear_thumbnail() end Timeline.seek_timer = mp.add_timeout(0.05, function() Elements.timeline:set_from_cursor() end) @@ -135,7 +127,10 @@ function Timeline:render() local size = self:get_effective_size() local visibility = self:get_visibility() - if size < 1 then return end + if size < 1 then + clear_thumbnail() + return + end local ass = assdraw.ass_new() @@ -340,6 +335,8 @@ function Timeline:render() }) end end + else + clear_thumbnail() end return ass