diff options
-rw-r--r-- | main.lua | 27 |
1 files changed, 20 insertions, 7 deletions
@@ -21,6 +21,7 @@ osd_bg.data = '{\\alpha&H50&\\c&H&\\pos(0,0)}' .. local categories = {} local streams = {} +local playing_stream_id local depth = 0 local menus = {} @@ -78,10 +79,12 @@ local function update_osd() if opt.type == 'category' then str = '[' .. str .. ']' + elseif opt.stream_id == playing_stream_id then + str = '▶ ' .. str end if i == menu.cursor_pos and not menu.search_active then - str = '{\\c&HFF00&}* ' .. str .. '{\\c}' + str = '{\\c&HFF00&}› ' .. str .. '{\\c}' elseif opt.type == 'category' then str = '{\\c&H99DDFF&}' .. str .. '{\\c}' end @@ -186,8 +189,10 @@ local function add_category_menu(category_id, category_name) end local function play_stream(stream_id) - local url = stream_prefix .. stream_id - mp.commandv('loadfile', url) + -- add a per-file option containing the stream_id, allowing it to be + -- retrieved when a start-file event is received + mp.commandv('loadfile', stream_prefix .. stream_id, 'replace', -1, + 'script-opt=iptv_menu.tmp.stream_id=' .. stream_id) end local function select_option() @@ -223,8 +228,7 @@ end local function split_search_text() local menu = menus[depth] - return menu.search_text:sub(1, - math.max(0, menu.search_text_cursor_pos - 1)), + return menu.search_text:sub(1, menu.search_text_cursor_pos - 1), menu.search_text:sub(menu.search_text_cursor_pos) end @@ -268,7 +272,7 @@ local function search_update() local matches = {} for _, v in ipairs(menu.search_options) do - if string.find(v.name, menu.search_text, 0, true) then + if v.name:find(menu.search_text, 0, true) then matches[#matches+1] = v end end @@ -421,8 +425,17 @@ local function toggle_menu() end end +mp.register_event('start-file', function() + playing_stream_id = tonumber(mp.get_opt('iptv_menu.tmp.stream_id')) + update_osd() +end) + +mp.register_event('end-file', function() + playing_stream_id = nil + update_osd() +end) + mp.add_forced_key_binding('TAB', 'toggle-menu', toggle_menu) bind_menu_keys() load_data() add_category_menu('0') -update_osd() |