diff --git a/modern.lua b/modern.lua index 0bab2e5..675f359 100644 --- a/modern.lua +++ b/modern.lua @@ -1,6 +1,6 @@ -- by maoiscat -- email:valarmor@163.com --- https://github.com/maoiscat/mpv-osc-modern +-- https://github.com/maoiscat/mpv-osc-morden local assdraw = require 'mp.assdraw' local msg = require 'mp.msg' @@ -28,52 +28,53 @@ local user_opts = { iamaprogrammer = false, -- use native mpv values and disable OSC -- internal track list management (and some -- functions that depend on it) - font = 'mpv-osd-symbols', -- default osc font - seekbarhandlesize = 1.0, -- size ratio of the slider handle, range 0 ~ 1 - seekrange = true, -- show seekrange overlay - seekrangealpha = 128, -- transparency of seekranges + font = 'mpv-osd-symbols', -- default osc font + seekbarhandlesize = 1.0, -- size ratio of the slider handle, range 0 ~ 1 + seekrange = true, -- show seekrange overlay + seekrangealpha = 128, -- transparency of seekranges seekbarkeyframes = true, -- use keyframes when dragging the seekbar title = '${media-title}', -- string compatible with property-expansion -- to be shown as OSC title - showtitle = true, -- show title and no hide timeout on pause - timetotal = true, -- display total time instead of remaining time? + showtitle = true, -- show title and no hide timeout on pause + timetotal = true, -- display total time instead of remaining time? visibility = 'auto', -- only used at init to set visibility_mode(...) windowcontrols = 'auto', -- whether to show window controls - language = 'eng', -- eng=English, chs=Chinese + volumecontrol = true, -- whether to show mute button and volumne slider + language = 'eng', -- eng=English, chs=Chinese } -- Localization local language = { - ['eng'] = { - welcome = '{\\fs24\\1c&H0&\\3c&HFFFFFF&}Drop files or URLs to play here.', -- this text appears when mpv starts - off = 'OFF', - na = 'n/a', - none = 'none', - video = 'Video', - audio = 'Audio', - subtitle = 'Subtitle', - available = 'Available ', - track = ' Tracks:', - playlist = 'Playlist', - nolist = 'Empty playlist.', - chapter = 'Chapter', - nochapter = 'No chapters.', - }, - ['chs'] = { - welcome = '{\\1c&H00\\bord0\\fs30\\fn微软雅黑 light\\fscx125}MPV{\\fscx100} 播放器', -- this text appears when mpv starts - off = '关闭', - na = 'n/a', - none = '无', - video = '视频', - audio = '音频', - subtitle = '字幕', - available = '可选', - track = ':', - playlist = '播放列表', - nolist = '无列表信息', - chapter = '章节', - nochapter = '无章节信息', - } + ['eng'] = { + welcome = '{\\fs24\\1c&H0&\\3c&HFFFFFF&}Drop files or URLs to play here.', -- this text appears when mpv starts + off = 'OFF', + na = 'n/a', + none = 'none', + video = 'Video', + audio = 'Audio', + subtitle = 'Subtitle', + available = 'Available ', + track = ' Tracks:', + playlist = 'Playlist', + nolist = 'Empty playlist.', + chapter = 'Chapter', + nochapter = 'No chapters.', + }, + ['chs'] = { + welcome = '{\\1c&H00\\bord0\\fs30\\fn微软雅黑 light\\fscx125}MPV{\\fscx100} 播放器', -- this text appears when mpv starts + off = '关闭', + na = 'n/a', + none = '无', + video = '视频', + audio = '音频', + subtitle = '字幕', + available = '可选', + track = ':', + playlist = '播放列表', + nolist = '无列表信息', + chapter = '章节', + nochapter = '无章节信息', + } } -- read options from config and command-line opt.read_options(user_opts, 'osc', function(list) update_options(list) end) @@ -88,15 +89,17 @@ local osc_param = { -- calculated by osc_init() } local osc_styles = { - TransBg = '{\\blur100\\bord140\\1c&H000000&\\3c&H000000&}', - SeekbarBg = '{\\blur0\\bord0\\1c&HFFFFFF&}', - SeekbarFg = '{\\blur1\\bord1\\1c&HE39C42&}', + TransBg = '{\\blur100\\bord140\\1c&H000000&\\3c&H000000&}', + SeekbarBg = '{\\blur0\\bord0\\1c&HFFFFFF&}', + SeekbarFg = '{\\blur1\\bord1\\1c&HE39C42&}', + VolumebarBg = '{\\blur0\\bord0\\1c&H999999&}', + VolumebarFg = '{\\blur1\\bord1\\1c&HFFFFFF&}', Ctrl1 = '{\\blur0\\bord0\\1c&HFFFFFF&\\3c&HFFFFFF&\\fs36\\fnmaterial-design-iconic-font}', Ctrl2 = '{\\blur0\\bord0\\1c&HFFFFFF&\\3c&HFFFFFF&\\fs24\\fnmaterial-design-iconic-font}', Ctrl3 = '{\\blur0\\bord0\\1c&HFFFFFF&\\3c&HFFFFFF&\\fs24\\fnmaterial-design-iconic-font}', Time = '{\\blur0\\bord0\\1c&HFFFFFF&\\3c&H000000&\\fs17\\fn' .. user_opts.font .. '}', Tooltip = '{\\blur1\\bord0.5\\1c&HFFFFFF&\\3c&H000000&\\fs18\\fn' .. user_opts.font .. '}', - Title = '{\\blur1\\bord0.5\\1c&HFFFFFF&\\3c&H0\\fs48\\q2\\fn' .. user_opts.font .. '}', + Title = '{\\blur1\\bord0.5\\1c&HFFFFFF&\\3c&H0\\fs48\\q2\\fn' .. user_opts.font .. '}', WinCtrl = '{\\blur1\\bord0.5\\1c&HFFFFFF&\\3c&H0\\fs20\\fnmpv-osd-symbols}', elementDown = '{\\1c&H999999&}', } @@ -131,7 +134,8 @@ local state = { border = true, maximized = false, osd = mp.create_osd_overlay('ass-events'), - lastvisibility = user_opts.visibility, -- save last visibility on pause if showtitle + mute = false, + lastvisibility = user_opts.visibility, -- save last visibility on pause if showtitle } local window_control_box_width = 138 @@ -301,7 +305,7 @@ function ass_append_alpha(ass, alpha, modifier) end function ass_draw_cir_cw(ass, x, y, r) - ass:round_rect_cw(x-r, y-r, x+r, y+r, r) + ass:round_rect_cw(x-r, y-r, x+r, y+r, r) end function ass_draw_rr_h_cw(ass, x0, y0, x1, y1, r1, hexagon, r2) @@ -392,7 +396,7 @@ function set_track(type, next) mp.commandv('set', type, new_track_mpv) --- if (new_track_osc == 0) then +-- if (new_track_osc == 0) then -- show_message(nicetypes[type] .. ' Track: none') -- else -- show_message(nicetypes[type] .. ' Track: ' @@ -481,15 +485,15 @@ function prepare_elements() --draw static slider parts local slider_lo = element.layout.slider -- calculate positions of min and max points - element.slider.min.ele_pos = user_opts.seekbarhandlesize * elem_geo.h / 2 - element.slider.max.ele_pos = elem_geo.w - element.slider.min.ele_pos + element.slider.min.ele_pos = user_opts.seekbarhandlesize * elem_geo.h / 2 + element.slider.max.ele_pos = elem_geo.w - element.slider.min.ele_pos element.slider.min.glob_pos = element.hitbox.x1 + element.slider.min.ele_pos element.slider.max.glob_pos = element.hitbox.x1 + element.slider.max.ele_pos static_ass:draw_start() - -- a hack which prepares the whole slider area to allow center placements such like an=5 - static_ass:rect_cw(0, 0, elem_geo.w, elem_geo.h) - static_ass:rect_ccw(0, 0, elem_geo.w, elem_geo.h) + -- a hack which prepares the whole slider area to allow center placements such like an=5 + static_ass:rect_cw(0, 0, elem_geo.w, elem_geo.h) + static_ass:rect_ccw(0, 0, elem_geo.w, elem_geo.h) -- marker nibbles if not (element.slider.markerF == nil) and (slider_lo.gap > 0) then local markers = element.slider.markerF() @@ -506,7 +510,7 @@ function prepare_elements() --bottom if (slider_lo.nibbles_bottom) then static_ass:move_to(s - 3, elem_geo.h - slider_lo.gap + 5) - static_ass:line_to(s, elem_geo.h - slider_lo.gap + 1) + static_ass:line_to(s, elem_geo.h - slider_lo.gap + 1) static_ass:line_to(s + 3, elem_geo.h - slider_lo.gap + 5) end else -- draw 2x1px nibbles @@ -581,25 +585,25 @@ function render_elements(master_ass) -- draw pos marker local pos = element.slider.posF() local seekRanges = element.slider.seekRangesF() - local rh = user_opts.seekbarhandlesize * elem_geo.h / 2 -- Handle radius + local rh = user_opts.seekbarhandlesize * elem_geo.h / 2 -- Handle radius local xp if pos then xp = get_slider_ele_pos_for(element, pos) - ass_draw_cir_cw(elem_ass, xp, elem_geo.h/2, rh) - elem_ass:rect_cw(0, slider_lo.gap, xp, elem_geo.h - slider_lo.gap) + ass_draw_cir_cw(elem_ass, xp, elem_geo.h/2, rh) + elem_ass:rect_cw(0, slider_lo.gap, xp, elem_geo.h - slider_lo.gap) end if seekRanges then - elem_ass:draw_stop() - elem_ass:merge(element.style_ass) - ass_append_alpha(elem_ass, element.layout.alpha, user_opts.seekrangealpha) - elem_ass:merge(element.static_ass) + elem_ass:draw_stop() + elem_ass:merge(element.style_ass) + ass_append_alpha(elem_ass, element.layout.alpha, user_opts.seekrangealpha) + elem_ass:merge(element.static_ass) for _,range in pairs(seekRanges) do local pstart = get_slider_ele_pos_for(element, range['start']) local pend = get_slider_ele_pos_for(element, range['end']) - elem_ass:rect_cw(pstart - rh, slider_lo.gap, pend + rh, elem_geo.h - slider_lo.gap) + elem_ass:rect_cw(pstart - rh, slider_lo.gap, pend + rh, elem_geo.h - slider_lo.gap) end end @@ -653,19 +657,18 @@ function render_elements(master_ass) elseif not (element.content == nil) then buttontext = element.content -- text objects end - - buttontext = buttontext:gsub(':%((.?.?.?)%) unknown ', ':%(%1%)') --gsub('%) unknown %(\'', '') + + buttontext = buttontext:gsub(':%((.?.?.?)%) unknown ', ':%(%1%)') --gsub('%) unknown %(\'', '') local maxchars = element.layout.button.maxchars -- 认为1个中文字符约等于1.5个英文字符 - -- local charcount = buttontext:len()- (buttontext:len()-select(2, buttontext:gsub('[^\128-\193]', '')))/1.5 local charcount = (buttontext:len() + select(2, buttontext:gsub('[^\128-\193]', ''))*2) / 3 if not (maxchars == nil) and (charcount > maxchars) then local limit = math.max(0, maxchars - 3) if (charcount > limit) then while (charcount > limit) do buttontext = buttontext:gsub('.[\128-\191]*$', '') - charcount = (buttontext:len() + select(2, buttontext:gsub('[^\128-\193]', ''))*2) / 3 + charcount = (buttontext:len() + select(2, buttontext:gsub('[^\128-\193]', ''))*2) / 3 end buttontext = buttontext .. '...' end @@ -674,7 +677,7 @@ function render_elements(master_ass) elem_ass:append(buttontext) -- add tooltip - if not (element.tooltipF == nil) and element.enabled then + if not (element.tooltipF == nil) and element.enabled then if mouse_hit(element) then local tooltiplabel = element.tooltipF local an = 1 @@ -682,23 +685,23 @@ function render_elements(master_ass) local tx = get_virt_mouse_pos() if ty < osc_param.playresy / 2 then - ty = element.hitbox.y2 - an = 7 - end + ty = element.hitbox.y2 + an = 7 + end -- tooltip label if type(element.tooltipF) == 'function' then - tooltiplabel = element.tooltipF() - else - tooltiplabel = element.tooltipF - end + tooltiplabel = element.tooltipF() + else + tooltiplabel = element.tooltipF + end elem_ass:new_event() elem_ass:pos(tx, ty) elem_ass:an(an) elem_ass:append(element.tooltip_style) elem_ass:append(tooltiplabel) end - end + end end master_ass:merge(elem_ass) @@ -975,8 +978,8 @@ layouts = function () local osc_geo = {w, h} - osc_geo.w = osc_param.playresx - osc_geo.h = 180 + osc_geo.w = osc_param.playresx + osc_geo.h = 180 -- origin of the controllers, left/bottom corner local posX = 0 @@ -994,30 +997,30 @@ layouts = function () local osc_w, osc_h= osc_geo.w, osc_geo.h - -- + -- -- Controller Background -- - local lo - - new_element('TransBg', 'box') - lo = add_layout('TransBg') - lo.geometry = {x = posX, y = posY, an = 7, w = osc_w, h = 1} - lo.style = osc_styles.TransBg - lo.layer = 10 - lo.alpha[3] = 0 - + local lo + + new_element('TransBg', 'box') + lo = add_layout('TransBg') + lo.geometry = {x = posX, y = posY, an = 7, w = osc_w, h = 1} + lo.style = osc_styles.TransBg + lo.layer = 10 + lo.alpha[3] = 0 + -- -- Alignment -- - local refX = osc_w / 2 - local refY = posY - local geo - + local refX = osc_w / 2 + local refY = posY + local geo + -- -- Seekbar -- - new_element('bgbar1', 'box') - lo = add_layout('bgbar1') + new_element('seekbarbg', 'box') + lo = add_layout('seekbarbg') lo.geometry = {x = refX , y = refY - 96 , an = 5, w = osc_geo.w - 50, h = 2} lo.layer = 13 lo.style = osc_styles.SeekbarBg @@ -1026,66 +1029,93 @@ layouts = function () lo = add_layout('seekbar') lo.geometry = {x = refX, y = refY - 96 , an = 5, w = osc_geo.w - 50, h = 16} - lo.style = osc_styles.SeekbarFg + lo.style = osc_styles.SeekbarFg lo.slider.gap = 7 lo.slider.tooltip_style = osc_styles.Tooltip lo.slider.tooltip_an = 2 + -- + -- Volumebar + -- + lo = new_element('volumebarbg', 'box') + lo.visible = (osc_param.playresx >= 750) and user_opts.volumecontrol + lo = add_layout('volumebarbg') + lo.geometry = {x = 155, y = refY - 40, an = 4, w = 80, h = 2} + lo.layer = 13 + lo.style = osc_styles.VolumebarBg + - -- buttons + lo = add_layout('volumebar') + lo.geometry = {x = 155, y = refY - 40, an = 4, w = 80, h = 8} + lo.style = osc_styles.VolumebarFg + lo.slider.gap = 3 + lo.slider.tooltip_style = osc_styles.Tooltip + lo.slider.tooltip_an = 2 + + -- buttons lo = add_layout('pl_prev') lo.geometry = {x = refX - 120, y = refY - 40 , an = 5, w = 30, h = 24} lo.style = osc_styles.Ctrl2 - lo = add_layout('skipback') + lo = add_layout('skipback') lo.geometry = {x = refX - 60, y = refY - 40 , an = 5, w = 30, h = 24} lo.style = osc_styles.Ctrl2 - + lo = add_layout('playpause') lo.geometry = {x = refX, y = refY - 40 , an = 5, w = 45, h = 45} - lo.style = osc_styles.Ctrl1 + lo.style = osc_styles.Ctrl1 lo = add_layout('skipfrwd') lo.geometry = {x = refX + 60, y = refY - 40 , an = 5, w = 30, h = 24} - lo.style = osc_styles.Ctrl2 + lo.style = osc_styles.Ctrl2 lo = add_layout('pl_next') lo.geometry = {x = refX + 120, y = refY - 40 , an = 5, w = 30, h = 24} lo.style = osc_styles.Ctrl2 - -- Time + -- Time lo = add_layout('tc_left') lo.geometry = {x = 25, y = refY - 84, an = 7, w = 64, h = 20} - lo.style = osc_styles.Time - + lo.style = osc_styles.Time + lo = add_layout('tc_right') lo.geometry = {x = osc_geo.w - 25 , y = refY -84, an = 9, w = 64, h = 20} - lo.style = osc_styles.Time + lo.style = osc_styles.Time lo = add_layout('cy_audio') - lo.geometry = {x = 37, y = refY - 40, an = 5, w = 24, h = 24} - lo.style = osc_styles.Ctrl3 - + lo.geometry = {x = 37, y = refY - 40, an = 5, w = 24, h = 24} + lo.style = osc_styles.Ctrl3 + lo.visible = (osc_param.playresx >= 540) + lo = add_layout('cy_sub') lo.geometry = {x = 87, y = refY - 40, an = 5, w = 24, h = 24} lo.style = osc_styles.Ctrl3 + lo.visible = (osc_param.playresx >= 600) - lo = add_layout('tog_fs') + lo = add_layout('vol_ctrl') + lo.geometry = {x = 137, y = refY - 40, an = 5, w = 24, h = 24} + lo.style = osc_styles.Ctrl3 + lo.visible = (osc_param.playresx >= 650) + + lo = add_layout('tog_fs') lo.geometry = {x = osc_geo.w - 37, y = refY - 40, an = 5, w = 24, h = 24} - lo.style = osc_styles.Ctrl3 + lo.style = osc_styles.Ctrl3 + lo.visible = (osc_param.playresx >= 540) - lo = add_layout('tog_info') + lo = add_layout('tog_info') lo.geometry = {x = osc_geo.w - 87, y = refY - 40, an = 5, w = 24, h = 24} lo.style = osc_styles.Ctrl3 + lo.visible = (osc_param.playresx >= 600) geo = { x = 25, y = refY - 132, an = 1, w = osc_geo.w - 50, h = 48 } lo = add_layout('title') lo.geometry = geo lo.style = string.format('%s{\\clip(%f,%f,%f,%f)}', osc_styles.Title, - geo.x, geo.y - geo.h, geo.x + geo.w , geo.y) - lo.alpha[3] = 0 + geo.x, geo.y - geo.h, geo.x + geo.w , geo.y) + lo.alpha[3] = 0 + lo.button.maxchars = geo.w / 23 end -- Validate string type user options @@ -1221,26 +1251,26 @@ function osc_init() -- update_tracklist() - --cy_audio + --cy_audio ne = new_element('cy_audio', 'button') ne.enabled = (#tracks_osc.audio > 0) ne.visible = (osc_param.playresx >= 540) ne.content = '\xEF\x8E\xB7' ne.tooltip_style = osc_styles.Tooltip ne.tooltipF = function () - local msg = texts.off + local msg = texts.off if not (get_track('audio') == 0) then msg = (texts.audio .. ' [' .. get_track('audio') .. ' ∕ ' .. #tracks_osc.audio .. '] ') local prop = mp.get_property('current-tracks/audio/lang') if not prop then - prop = texts.na - end - msg = msg .. '[' .. prop .. ']' - prop = mp.get_property('current-tracks/audio/title') - if prop then - msg = msg .. ' ' .. prop - end - return msg + prop = texts.na + end + msg = msg .. '[' .. prop .. ']' + prop = mp.get_property('current-tracks/audio/title') + if prop then + msg = msg .. ' ' .. prop + end + return msg end return msg end @@ -1258,19 +1288,19 @@ function osc_init() ne.content = '\xEF\x8F\x93' ne.tooltip_style = osc_styles.Tooltip ne.tooltipF = function () - local msg = texts.off + local msg = texts.off if not (get_track('sub') == 0) then msg = (texts.subtitle .. ' [' .. get_track('sub') .. ' ∕ ' .. #tracks_osc.sub .. '] ') local prop = mp.get_property('current-tracks/sub/lang') if not prop then - prop = texts.na - end - msg = msg .. '[' .. prop .. ']' - prop = mp.get_property('current-tracks/sub/title') - if prop then - msg = msg .. ' ' .. prop - end - return msg + prop = texts.na + end + msg = msg .. '[' .. prop .. ']' + prop = mp.get_property('current-tracks/sub/title') + if prop then + msg = msg .. ' ' .. prop + end + return msg end return msg end @@ -1281,6 +1311,20 @@ function osc_init() ne.eventresponder['mbtn_mid_up'] = function () show_message(get_tracklist('sub')) end + -- vol_ctrl + ne = new_element('vol_ctrl', 'button') + ne.enabled = (get_track('audio')>0) + ne.visible = (osc_param.playresx >= 650) and user_opts.volumecontrol + ne.content = function () + if (state.mute) then + return ('\xEF\x8E\xBB') + else + return ('\xEF\x8E\xBC') + end + end + ne.eventresponder['mbtn_left_up'] = + function () mp.commandv('cycle', 'mute') end + --tog_fs ne = new_element('tog_fs', 'button') ne.content = function () @@ -1304,12 +1348,12 @@ function osc_init() -- title ne = new_element('title', 'button') ne.content = function () - local title = mp.command_native({'expand-text', user_opts.title}) + local title = mp.command_native({'expand-text', user_opts.title}) if state.paused then - title = title:gsub('\\n', ' '):gsub('\\$', ''):gsub('{','\\{') - else - title = ' ' - end + title = title:gsub('\\n', ' '):gsub('\\$', ''):gsub('{','\\{') + else + title = ' ' + end return not (title == '') and title or ' ' end ne.visible = osc_param.playresy >= 320 and user_opts.showtitle @@ -1369,7 +1413,7 @@ function osc_init() end ne.eventresponder['mouse_move'] = --keyframe seeking when mouse is dragged function (element) - if not element.state.mbtnleft then return end -- allow drag for mbtnleft only! + if not element.state.mbtnleft then return end -- allow drag for mbtnleft only! -- mouse move events may pile up during seeking and may still get -- sent when the user is done seeking, so we need to throw away -- identical seeks @@ -1387,33 +1431,68 @@ function osc_init() end ne.eventresponder['mbtn_left_down'] = --exact seeks on single clicks function (element) - mp.commandv('seek', get_slider_value(element), 'absolute-percent', 'exact') - element.state.mbtnleft = true - end - ne.eventresponder['mbtn_left_up'] = - function (element) element.state.mbtnleft = false end + mp.commandv('seek', get_slider_value(element), 'absolute-percent', 'exact') + element.state.mbtnleft = true + end + ne.eventresponder['mbtn_left_up'] = + function (element) element.state.mbtnleft = false end ne.eventresponder['mbtn_right_down'] = --seeks to chapter start function (element) - local duration = mp.get_property_number('duration', nil) - if not (duration == nil) then - local chapters = mp.get_property_native('chapter-list', {}) - if #chapters > 0 then - local pos = get_slider_value(element) - local ch = #chapters - for n = 1, ch do - if chapters[n].time / duration * 100 >= pos then - ch = n - 1 - break - end - end - mp.commandv('set', 'chapter', ch - 1) - --if chapters[ch].title then show_message(chapters[ch].time) end - end - end - end + local duration = mp.get_property_number('duration', nil) + if not (duration == nil) then + local chapters = mp.get_property_native('chapter-list', {}) + if #chapters > 0 then + local pos = get_slider_value(element) + local ch = #chapters + for n = 1, ch do + if chapters[n].time / duration * 100 >= pos then + ch = n - 1 + break + end + end + mp.commandv('set', 'chapter', ch - 1) + --if chapters[ch].title then show_message(chapters[ch].time) end + end + end + end ne.eventresponder['reset'] = function (element) element.state.lastseek = nil end + --volumebar + ne = new_element('volumebar', 'slider') + ne.visible = (osc_param.playresx >= 700) and user_opts.volumecontrol + ne.enabled = (get_track('audio')>0) + ne.slider.markerF = function () + return {} + end + ne.slider.seekRangesF = function() + return nil + end + ne.slider.posF = + function () + local val = mp.get_property_number('volume', nil) + return val*val/100 + end + ne.eventresponder['mouse_move'] = + function (element) + if not element.state.mbtnleft then return end -- allow drag for mbtnleft only! + local seekto = get_slider_value(element) + if (element.state.lastseek == nil) or + (not (element.state.lastseek == seekto)) then + mp.commandv('set', 'volume', 10*math.sqrt(seekto)) + element.state.lastseek = seekto + end + end + ne.eventresponder['mbtn_left_down'] = --exact seeks on single clicks + function (element) + local seekto = get_slider_value(element) + mp.commandv('set', 'volume', 10*math.sqrt(seekto)) + element.state.mbtnleft = true + end + ne.eventresponder['mbtn_left_up'] = + function (element) element.state.mbtnleft = false end + ne.eventresponder['reset'] = + function (element) element.state.lastseek = nil end -- tc_left (current pos) ne = new_element('tc_left', 'button') @@ -1424,14 +1503,14 @@ function osc_init() ne.content = function () if (mp.get_property_number('duration', 0) <= 0) then return '--:--:--' end if (state.rightTC_trem) then - return ('-'..mp.get_property_osd('playtime-remaining')) + return ('-'..mp.get_property_osd('playtime-remaining')) else - return (mp.get_property_osd('duration')) + return (mp.get_property_osd('duration')) end end ne.eventresponder['mbtn_left_up'] = function () state.rightTC_trem = not state.rightTC_trem end - + -- load layout layouts() @@ -1495,14 +1574,14 @@ end function pause_state(name, enabled) state.paused = enabled if user_opts.showtitle then - if enabled then - state.lastvisibility = user_opts.visibility - visibility_mode("always", true) - show_osc() - else - visibility_mode(state.lastvisibility, true) - end - end + if enabled then + state.lastvisibility = user_opts.visibility + visibility_mode("always", true) + show_osc() + else + visibility_mode(state.lastvisibility, true) + end + end request_tick() end @@ -1796,44 +1875,44 @@ function process_event(source, what) end function show_logo() - local osd_w, osd_h = 640, 360 - local logo_x, logo_y = osd_w/2, osd_h/2-20 - local ass = assdraw.ass_new() - ass:new_event() - ass:pos(logo_x, logo_y) - ass:append('{\\1c&H8E348D&\\3c&H0&\\3a&H60&\\blur1\\bord0.5}') - ass:draw_start() - ass_draw_cir_cw(ass, 0, 0, 100) - ass:draw_stop() - - ass:new_event() - ass:pos(logo_x, logo_y) - ass:append('{\\1c&H632462&\\bord0}') - ass:draw_start() - ass_draw_cir_cw(ass, 6, -6, 75) - ass:draw_stop() - - ass:new_event() - ass:pos(logo_x, logo_y) - ass:append('{\\1c&HFFFFFF&\\bord0}') - ass:draw_start() - ass_draw_cir_cw(ass, -4, 4, 50) - ass:draw_stop() - - ass:new_event() - ass:pos(logo_x, logo_y) - ass:append('{\\1c&H632462&\\bord&}') - ass:draw_start() - ass:move_to(-20, -20) - ass:line_to(23.3, 5) - ass:line_to(-20, 30) - ass:draw_stop() - - ass:new_event() - ass:pos(logo_x, logo_y+110) - ass:an(8) - ass:append(texts.welcome) - set_osd(osd_w, osd_h, ass.text) + local osd_w, osd_h = 640, 360 + local logo_x, logo_y = osd_w/2, osd_h/2-20 + local ass = assdraw.ass_new() + ass:new_event() + ass:pos(logo_x, logo_y) + ass:append('{\\1c&H8E348D&\\3c&H0&\\3a&H60&\\blur1\\bord0.5}') + ass:draw_start() + ass_draw_cir_cw(ass, 0, 0, 100) + ass:draw_stop() + + ass:new_event() + ass:pos(logo_x, logo_y) + ass:append('{\\1c&H632462&\\bord0}') + ass:draw_start() + ass_draw_cir_cw(ass, 6, -6, 75) + ass:draw_stop() + + ass:new_event() + ass:pos(logo_x, logo_y) + ass:append('{\\1c&HFFFFFF&\\bord0}') + ass:draw_start() + ass_draw_cir_cw(ass, -4, 4, 50) + ass:draw_stop() + + ass:new_event() + ass:pos(logo_x, logo_y) + ass:append('{\\1c&H632462&\\bord&}') + ass:draw_start() + ass:move_to(-20, -20) + ass:line_to(23.3, 5) + ass:line_to(-20, 30) + ass:draw_stop() + + ass:new_event() + ass:pos(logo_x, logo_y+110) + ass:an(8) + ass:append(texts.welcome) + set_osd(osd_w, osd_h, ass.text) end -- called by mpv on every frame @@ -1841,7 +1920,7 @@ function tick() if (not state.enabled) then return end if (state.idle) then - show_logo() + show_logo() -- render idle message msg.trace('idle message') @@ -1921,6 +2000,11 @@ mp.observe_property('fullscreen', 'bool', request_init_resize() end ) +mp.observe_property('mute', 'bool', + function(name, val) + state.mute = val + end +) mp.observe_property('border', 'bool', function(name, val) state.border = val @@ -2018,8 +2102,8 @@ function visibility_mode(mode, no_osd) return end - user_opts.visibility = mode - + user_opts.visibility = mode + if not no_osd and tonumber(mp.get_property('osd-level')) >= 1 then mp.osd_message('OSC visibility: ' .. mode) end diff --git a/preview.png b/preview.png index bf1d25c..d6577e8 100644 Binary files a/preview.png and b/preview.png differ