diff options
| author | David Vazgenovich Shakaryan <dvshakaryan@gmail.com> | 2026-01-18 00:00:24 -0800 |
|---|---|---|
| committer | David Vazgenovich Shakaryan <dvshakaryan@gmail.com> | 2026-01-18 00:00:24 -0800 |
| commit | b3665cc09ea0363beafc05a867c057e5c122985a (patch) | |
| tree | 162299bf2515205c83202083016ec2337271dd26 /main.lua | |
| parent | b3ec50d92451b99dd08b6030b08854c8cc77524b (diff) | |
| download | mpv-iptv-menu-b3665cc09ea0363beafc05a867c057e5c122985a.tar.gz mpv-iptv-menu-b3665cc09ea0363beafc05a867c057e5c122985a.tar.xz | |
support timed status/error messages
To support this, render() has been pulled out of redraw(), allowing
updating the actual OSD without having to pass in the 'state' object,
avoiding complexity and unnecessary computation.
Diffstat (limited to 'main.lua')
| -rw-r--r-- | main.lua | 22 |
1 files changed, 17 insertions, 5 deletions
@@ -13,7 +13,6 @@ local _xc = require('xc') local mp_utils = require('mp.utils') local script_name = mp.get_script_name() -local script_dir = mp.get_script_directory() local state = _state.new() local binding_state = {mappings = {}, active = {}} @@ -45,19 +44,32 @@ xc = cacher.wrap(xc, { local catalogue = _catalogue.new() local epg = _epg.new() -local osd = _osd.new({ + +local osd +local function dl_img(url, path, cb) + downloader:schedule(url, path, function(success, _, path) + if success then + cb(path) + else + osd:flash_error('Image download failed') + end + end) + +end +osd = _osd.new({ img_path_func = function(url, cb) local path = mp_utils.join_path( config.img_dir, url:gsub('%W', '_')) if not mp_utils.file_info(path) and cb then - downloader:schedule(url, path, function(_, path) - cb(path) - end) + dl_img(url, path, cb) end return path end, + img_fail_cb = function() + osd:flash_error('Image load failed') + end }) local function cache_miss_status_msg(str) |
