mpv: Update gui interface

This commit is contained in:
Marty Oehme 2023-05-23 15:31:17 +02:00
parent 8a0fd53647
commit 01ca98aa4b
Signed by: Marty
GPG key ID: EDBF2ED917B2EF6A
29 changed files with 6886 additions and 3569 deletions

View file

@ -0,0 +1,37 @@
local Element = require('uosc_shared/elements/Element')
---@class BufferingIndicator : Element
local BufferingIndicator = class(Element)
function BufferingIndicator:new() return Class.new(self) --[[@as BufferingIndicator]] end
function BufferingIndicator:init()
Element.init(self, 'buffer_indicator')
self.ignores_menu = true
self.enabled = false
end
function BufferingIndicator:decide_enabled()
local cache = state.cache_underrun or state.cache_buffering and state.cache_buffering < 100
local player = state.core_idle and not state.eof_reached
if self.enabled then
if not player or (state.pause and not cache) then self.enabled = false end
elseif player and cache and state.uncached_ranges then self.enabled = true end
end
function BufferingIndicator:on_prop_pause() self:decide_enabled() end
function BufferingIndicator:on_prop_core_idle() self:decide_enabled() end
function BufferingIndicator:on_prop_eof_reached() self:decide_enabled() end
function BufferingIndicator:on_prop_uncached_ranges() self:decide_enabled() end
function BufferingIndicator:on_prop_cache_buffering() self:decide_enabled() end
function BufferingIndicator:on_prop_cache_underrun() self:decide_enabled() end
function BufferingIndicator:render()
local ass = assdraw.ass_new()
ass:rect(0, 0, display.width, display.height, {color = bg, opacity = 0.3})
local size = round(30 + math.min(display.width, display.height) / 10)
local opacity = (Elements.menu and not Elements.menu.is_closing) and 0.3 or 0.8
ass:spinner(display.width / 2, display.height / 2, size, {color = fg, opacity = opacity})
return ass
end
return BufferingIndicator