Skip to content

Commit

Permalink
同步与整合上游
Browse files Browse the repository at this point in the history
  • Loading branch information
hooke007 committed Jul 14, 2024
1 parent 4fd0407 commit 3750a56
Show file tree
Hide file tree
Showing 17 changed files with 331 additions and 214 deletions.
3 changes: 2 additions & 1 deletion portable_config/input_scripts.conf
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,13 @@

##⇘⇘MPV内部自带的LUA脚本

i script-binding stats/display-stats # 临时显示统计信息(此时01234翻页,024页可方向上下键滚动查看
i script-binding stats/display-stats # 临时显示统计信息(此时 数字键012345 可翻页,第024页可用 方向上下键 滚动查看
I script-binding stats/display-stats-toggle # 开/关 常驻显示统计信息

` script-binding console/enable # 进入控制台(此时Esc退出)

DEL script-binding osc/visibility # 切换 内置OSC的可见性
Alt+DEL script-message osc-show # 临时显示内置OSC


##⇘⇘追加绑定外置脚本内建的快捷键方案,此处追加绑定的按键会与脚本内建的方案共存
Expand Down
2 changes: 1 addition & 1 deletion portable_config/mpv.conf
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@

##⇘⇘高级字幕部分 —— SSA ASS

sub-ass-override = yes # <no|默认 yes|scale|force|strip> 是否覆盖字幕脚本的原始样式,默认只应用 --sub-ass-* 类的选项
sub-ass-override = scale # <no|yes|默认scale|force|strip> 是否覆盖字幕脚本的原始样式。值 yes 只应用 --sub-ass-* 类的选项
# scale 在此基础上也应用了 --sub-scale , force 更进一步应用所有 --sub-* 的选项, strip 则剥离全部标记和样式
sub-ass-scale-with-window = no # 字幕随窗口缩放而不是随视频缩放,默认 no
embeddedfonts = yes # 是否使用mkv容器的内嵌字体,默认 yes
Expand Down
123 changes: 72 additions & 51 deletions portable_config/script-opts.conf

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions portable_config/script-opts/load_plus.conf
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,5 @@ skip_hidden=yes
max_entries=150
##<auto|lazy|recursive|默认ignore> 子文件夹的处理模式,参考主设置选项,功能近似 https://mpv.io/manual/master/#options-directory-mode
directory_mode=ignore
如果文件名中匹配到指定字符则略过,示例即默认值。语法 https://lua.org/pil/20.2.html
ignore_pattern=$^
21 changes: 18 additions & 3 deletions portable_config/script-opts/osc.conf
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,8 @@ scalewindowed=1
# -- 窗口化时OSC的缩放系数,默认:1
scalefullscreen=1
# -- 全屏时OSC的缩放系数,默认:1
scaleforcedwindow=2
# -- 强制(虚拟)窗口的缩放系数?? 默认:2
vidscale=yes
# -- 随视频大小缩放OSC? 默认:yes
# -- <no|默认yes|auto> 随视频大小缩放OSC? 值 auto 会根据选项 --osd-scale-by-window ,使 OSC 与 OSD 一起缩放。
valign=0.8
# -- <-1(顶部)--1(底部)> 垂直对齐 默认:0.8
halign=0
Expand Down Expand Up @@ -91,3 +89,20 @@ chapter_fmt=Chapter: %s
# -- 悬停进度条时显示章节信息的格式,特殊值no为不显示,示例为默认值
unicodeminus=no
# -- 是否使用Unicode的减号字符,默认:no

## 以下多项为各元素相关的颜色自定义
background_color=#000000
timecode_color=#FFFFFF
title_color=#FFFFFF
time_pos_color=#FFFFFF
time_pos_outline_color=#FFFFFF
buttons_color=#FFFFFF
top_buttons_color=#FFFFFF
small_buttonsL_color=#FFFFFF
small_buttonsR_color=#FFFFFF
held_element_color=#999999

tick_delay=1/60
# -- 以秒为单位设定OSC渲染的最小间隔
tick_delay_follow_display_fps=no
# -- OSC渲染的间隔是否跟随显示刷新率
4 changes: 4 additions & 0 deletions portable_config/script-opts/stats.conf
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,14 @@ skip_frames=5
global_max=yes
flush_graph_data=yes
##切换显示时清除已缓存的数据
plot_bg_border_width=0.5
plot_bg_border_color=0000FF
plot_bg_color=262626
plot_color=FFFFFF

##<no|默认yes|auto> 随视频大小缩放stats? 值 auto 会根据选项 --osd-scale-by-window ,使 stats 与 OSD 一起缩放。
vidscale=yes

# -- 字体相关设定
font=sans-serif
font_mono=monospace
Expand Down
6 changes: 4 additions & 2 deletions portable_config/script-opts/uosc.conf
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ menu_type_to_search=yes
# 顶栏的显隐逻辑(仅在无边框和全屏模式下显示),默认 no-border 其它可用的值 never always
top_bar=no-border
top_bar_size=40
# 启用顶栏的右侧控制按钮,示例即默认值
top_bar_controls=yes
# 启用顶栏的控制按钮,其它可用的值 no left
top_bar_controls=right
# 启用顶栏主标题,yes即使用mpv.conf中的设定,no则禁用,或使用自定义的属性扩展字符串。推荐 ${media-title}
top_bar_title=yes
# 启用顶栏备用标题,留空即不使用,推荐 ${filename}
Expand Down Expand Up @@ -129,6 +129,8 @@ audio_types=aac,ac3,ape,dsf,dts,flac,m4a,mka,mp3,ogg,opus,wav,wma,wv
image_types=apng,avif,bmp,gif,jfif,jpeg,jpg,jxl,png,svg,tif,tiff,webp
# (导入字幕时)文件浏览器的扩展名过滤列表。默认值覆盖极广,此预设精简为常见的字幕格式
subtitle_types=ass,idx,lrc,mks,pgs,sup,srt,ssa,txt,vtt
# (导入播放列表时)文件浏览器的扩展名过滤列表,示例即默认值
playlist_types=m3u,m3u8,pls,url,cue

# 文件浏览器的默认目录,示例即默认值
default_directory=~/
Expand Down
12 changes: 9 additions & 3 deletions portable_config/scripts/load_plus.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
--[[
SOURCE_ https://github.com/mpv-player/mpv/blob/master/TOOLS/lua/autoload.lua
COMMIT_ b1491bed28ffad2adb23d704241ca4cbfcae8df3
COMMIT_ a1caa001870985f36ae3c0082181e4e708ebdd73
SOURCE_ https://github.com/rossy/mpv-open-file-dialog/blob/master/open-file-dialog.lua
COMMIT_ 04fe818fc703d8c5dcc3a6aabe1caeed8286bdbb
文档_ https://github.com/hooke007/MPV_lazy/discussions/106
Expand Down Expand Up @@ -33,7 +33,8 @@ opt = {
image_ext = "default",
skip_hidden = true,
max_entries = 150,
directory_mode = "ignore"
directory_mode = "ignore",
ignore_pattern = "$^",
}
options.read_options(opt)

Expand Down Expand Up @@ -244,9 +245,14 @@ function scan_dir(path, current_file, dir_mode, separator, dir_depth, total_file
table.filter(files, function (v)
-- The current file could be a hidden file, ignoring it doesn't load other
-- files from the current directory.
if (opt.skip_hidden and not (prefix .. v == current_file) and string.match(v, "^%.")) then
local current = prefix .. v == current_file
if (opt.skip_hidden and not current and string.match(v, "^%.")) then
return false
end
if (not current and string.match(v, opt.ignore_pattern)) then
return false
end

local ext = get_extension(v)
if ext == nil then
return false
Expand Down
6 changes: 6 additions & 0 deletions portable_config/scripts/uosc/elements/CycleButton.lua
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,12 @@ function CycleButton:init(id, props)
end

local function handle_change(name, value)
-- Removes unnecessary floating point digits from values like `2.00000`.
-- This happens when observing properties like `speed`.
if type(value) == 'string' and string.match(value, '^[%+%-]?%d+%.%d+$') then
value = tonumber(value)
end

value = type(value) == 'boolean' and (value and 'yes' or 'no') or tostring(value or '')
local index = itable_find(self.states, function(state) return state.value == value end)
self.current_state_index = index or 1
Expand Down
2 changes: 1 addition & 1 deletion portable_config/scripts/uosc/elements/Element.lua
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ function Element:init(id, props)
local function getTo() return self.proximity end
local function onTweenEnd() self.forced_visibility = nil end
if self.enabled then
self:tween_property('forced_visibility', 1, getTo, onTweenEnd)
self:tween_property('forced_visibility', self:get_visibility(), getTo, onTweenEnd)
else
onTweenEnd()
end
Expand Down
9 changes: 9 additions & 0 deletions portable_config/scripts/uosc/elements/Menu.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1213,6 +1213,15 @@ function Menu:render()
opacity = highlight_opacity * menu_opacity,
clip = item_clip,
})

-- Selected item indicator line
if is_selected then
local size = round(2 * state.scale)
local v_padding = math.min(state.radius, math.ceil(self.item_height / 3))
ass:rect(ax + self.padding - size - 1, item_ay + v_padding, ax + self.padding - 1, item_by - v_padding, {
radius = 1, color = fg, opacity = menu_opacity, clip = item_clip,
})
end
end

-- Icon
Expand Down
21 changes: 9 additions & 12 deletions portable_config/scripts/uosc/elements/Timeline.lua
Original file line number Diff line number Diff line change
Expand Up @@ -163,8 +163,6 @@ function Timeline:on_global_mouse_move()
end
end
end
function Timeline:handle_wheel_up() mp.commandv('seek', options.timeline_step) end
function Timeline:handle_wheel_down() mp.commandv('seek', -options.timeline_step) end

function Timeline:render()
if self.size == 0 then return end
Expand All @@ -186,8 +184,10 @@ function Timeline:render()
self:handle_cursor_down()
cursor:once('primary_up', function() self:handle_cursor_up() end)
end)
cursor:zone('wheel_down', self, function() self:handle_wheel_down() end)
cursor:zone('wheel_up', self, function() self:handle_wheel_up() end)
if options.timeline_step ~= 0 then
cursor:zone('wheel_down', self, function() mp.commandv('seek', -options.timeline_step) end)
cursor:zone('wheel_up', self, function() mp.commandv('seek', options.timeline_step) end)
end
end

local ass = assdraw.ass_new()
Expand Down Expand Up @@ -251,15 +251,11 @@ function Timeline:render()
ass:rect(fax, fay, fbx, fby, {opacity = config.opacity.position})

-- Uncached ranges
local buffered_playtime = nil
if state.uncached_ranges then
local opts = {size = 80, anchor_y = fby}
local texture_char = visibility > 0 and 'b' or 'a'
local offset = opts.size / (visibility > 0 and 24 or 28)
for _, range in ipairs(state.uncached_ranges) do
if not buffered_playtime and (range[1] > state.time or range[2] > state.time) then
buffered_playtime = (range[1] - state.time) / state.speed
end
if options.timeline_cache then
local ax = range[1] < 0.5 and bax or math.floor(t2x(range[1]))
local bx = range[2] > state.duration - 0.5 and bbx or math.ceil(t2x(range[2]))
Expand Down Expand Up @@ -321,7 +317,7 @@ function Timeline:render()
if chapter ~= hovered_chapter then draw_chapter(chapter.time, diamond_radius) end
local circle = {point = {x = t2x(chapter.time), y = fay - 1}, r = diamond_radius_hovered}
if visibility > 0 then
cursor:zone('primary_down', circle, function()
cursor:zone('primary_click', circle, function()
mp.commandv('seek', chapter.time, 'absolute+exact')
end)
end
Expand Down Expand Up @@ -377,14 +373,15 @@ function Timeline:render()
if text_opacity > 0 then
local time_opts = {size = self.font_size, opacity = text_opacity, border = 2 * state.scale}
-- Upcoming cache time
if buffered_playtime and options.buffered_time_threshold > 0
and buffered_playtime < options.buffered_time_threshold then
local cache_duration = state.cache_duration and state.cache_duration / state.speed or nil
if cache_duration and options.buffered_time_threshold > 0
and cache_duration < options.buffered_time_threshold then
local margin = 5 * state.scale
local x, align = fbx + margin, 4
local cache_opts = {
size = self.font_size * 0.8, opacity = text_opacity * 0.6, border = options.text_border * state.scale,
}
local human = round(math.max(buffered_playtime, 0)) .. 's'
local human = round(cache_duration) .. 's'
local width = text_width(human, cache_opts)
local time_width = timestamp_width(state.time_human, time_opts)
local time_width_end = timestamp_width(state.destination_time_human, time_opts)
Expand Down
Loading

0 comments on commit 3750a56

Please sign in to comment.