Skip to content

armgit / peach

Public Imported from GitHub
0

Peach: Local-first video metadata scraper and media manager.

feat(web): 速度面板照 YouTube 改成滑条,播放与静音点击闪中心提示

longmeidao7f62971d733a
diff --git a/tests/test_web_ui.py b/tests/test_web_ui.py
index 3fad6abf8..31d4b8227 100644
--- a/tests/test_web_ui.py
+++ b/tests/test_web_ui.py
@@ -1609,7 +1609,7 @@ class WebUiSourceTests(unittest.TestCase):
self.assertPageContains("<span>氛围模式</span>")
self.assertPageContains("<span>播放速度</span>")
self.assertPageContains("<span>清晰度</span>")
- self.assertPageContains("player.playbackRate(Number(button.dataset.playerSpeedOption))")
+ self.assertPageContains("setSpeed(Number(button.dataset.playerSpeedOption))")
self.assertPageContains("applyAmbientMode(!appSettings.ambientMode)")
self.assertPageContains("${icon('player-ambient')}")
self.assertPageContains("${icon('player-speed')}")
@@ -1744,7 +1744,11 @@ class WebUiSourceTests(unittest.TestCase):
self.assertPageContains("const widthObserver=new ResizeObserver(syncWidthMode)")
self.assertPageContains("player.on('dispose',()=>widthObserver.disconnect())")
self.assertPageContains("expand.className='vjs-peach-expand vjs-control'")
- self.assertPageContains("icon('player-menu-next')")
+ self.assertPageContains("icon('player-expand')")
+ # 菜单行那个 `>` 是 24 视框、一个单位粗的细线,铺到展开键的 32px 只有 1.3px;上游
+ # 展开键自带一个 32 视框、两个单位粗的箭头,同样 32px 渲染就是 2px。
+ self.assertPageContains('<symbol id="i-player-expand" viewBox="0 0 32 32"')
+ self.assertPageContains('m12.59 20.34 4.58-4.59-4.58-4.59L14 9.75l6 6-6 6z')
# 展开键排在这一簇最左:`prepend` 而不是 append,否则它落在全屏键的右边。
self.assertPageContains("group.prepend(expand)")
# hover 高亮的规则是 `.vjs-control>.vjs-peach-hover`,高亮层必须是按钮的兄弟节点;
@@ -1752,11 +1756,15 @@ class WebUiSourceTests(unittest.TestCase):
self.assertPageContains(
'</button><span class="vjs-peach-hover" aria-hidden="true"></span>`;\n'
' group.prepend(expand);')
- # 窄屏其余键的 svg 缩到 18px,展开键排除在外并单独铺满 32px:那个箭头本来就细,
- # 跟着缩就几乎看不出是个可点的键。上游给这个按钮的 svg 内边距同样是 0。
+ # 窄屏其余键的 svg 缩到 18px,展开键排除在外并单独铺满 32px:跟着缩就几乎看不出
+ # 是个可点的键。上游给这个按钮的 svg 内边距同样是 0。
self.assertPageContains(
".video-js.vjs-peach-xsmall .vjs-peach-right-controls>.vjs-control"
":not(.vjs-peach-expand)>button>svg{width:18px;height:18px}")
+ # 窄屏这一排的悬停底是 32×32 的正圆,不是撑满 36px 一格的胶囊。
+ self.assertPageContains(
+ ".video-js.vjs-peach-xsmall .vjs-peach-right-controls>.vjs-control>.vjs-peach-hover{")
+ self.assertPageContains("left:2px;width:32px;height:32px;border-radius:50%}")
self.assertPageContains(
".video-js.vjs-peach-xsmall .vjs-peach-expand>button>svg{width:32px;height:32px}")
self.assertPageContains("expandButton.setAttribute('aria-expanded',String(open))")
@@ -1830,8 +1838,8 @@ class WebUiSourceTests(unittest.TestCase):
# 面板的定位祖先只有 36px 高,百分比高度到不了播放器,得由布局脚本把高度写上来。
self.assertPageContains("box.style.setProperty('--peach-player-h',`${box.clientHeight}px`)")
- def test_narrow_settings_panel_fits_eight_speed_options_without_scrolling(self):
- """八档播放速度单列要 57+16+8×48=457px,320px 高的播放器只给得出 246px。
+ def test_narrow_settings_panel_fits_the_longest_option_list_without_scrolling(self):
+ """清晰度多到八档,单列要 57+16+8×48=457px,320px 高的播放器只给得出 246px。
行高压到 44px、排成两列是 57+8+4×44=241px;只让选项多于四条的列表分两列,
主面板那三行仍是单列。
@@ -1842,6 +1850,93 @@ class WebUiSourceTests(unittest.TestCase):
".video-js.vjs-peach-xsmall .vjs-peach-panel-menu"
":has(>.vjs-peach-menu-option:nth-child(5)){display:grid;grid-template-columns:1fr 1fr}")
+ def test_playback_speed_panel_matches_the_youtube_slider_layout(self):
+ """播放速度是读数加滑条加预设胶囊,照 YouTube delhi-modern 的数值来。
+
+ 证据是 player 9470c977 的 www-player.css 与 base.js:内容区 24/16/16 内距,读数
+ 居中、下留 24px,滑条一行 gap 16px、加减键 32px 圆各动 0.05,胶囊 53×32、gap 8px,
+ 1.0 底下挂一行 14px 行高的说明。滑条两端取播放器支持的最低与最高倍速,步进 0.05。
+ 字号、字重和圆角走 Peach 的 token:上游读数那档 18px/900 与说明那档 10px 都不在
+ Peach 的刻度上,胶囊和轨道的圆角大于自身高度的一半,`--pill-radius` 渲染结果相同。
+ 上游第五个胶囊是 Premium 专属的 3.0 倍,Peach 没有分级,那一格不做。
+ """
+ self.assertPageContains(
+ "const SPEED_RATES=[.25,.5,.75,1,1.25,1.5,1.75,2],SPEED_STEP=.05,SPEED_PRESETS=[1,1.25,1.5,2];")
+ self.assertPageContains('<output data-player-speed-display></output>')
+ self.assertPageContains(
+ '<input type="range" class="vjs-peach-speed-range" data-player-speed-range '
+ 'min="${min}" max="${max}" step="${SPEED_STEP}" aria-label="播放速度">')
+ self.assertPageContains('data-player-speed-step="-1" aria-label="播放速度减 0.05"')
+ self.assertPageContains('data-player-speed-step="1" aria-label="播放速度加 0.05"')
+ self.assertPageContains('<span class="vjs-peach-speed-preset-label">正常</span>')
+ self.assertPageContains("display.textContent=`${speed.toFixed(2)}x`;range.value=String(speed);")
+ # 轨道已过的比例由脚本写成自定义属性,上游同样是自定义属性驱动那条渐变。
+ self.assertPageContains(
+ "range.style.setProperty('--peach-speed-percent',`${(speed-min)/(max-min)*100}%`);")
+ self.assertPageContains(
+ "setSpeed((Number(player.playbackRate())||1)+Number(button.dataset.playerSpeedStep)*SPEED_STEP))")
+ self.assertPageContains(
+ ".vjs-peach-speed-panel{box-sizing:border-box;display:flex;flex-direction:column;padding:24px 16px 16px}")
+ self.assertPageContains("font-size:var(--fs-lg);font-weight:600;line-height:22px;color:#fff}")
+ self.assertPageContains(
+ ".vjs-peach-speed-slider{display:flex;align-items:center;gap:16px;margin-bottom:24px}")
+ self.assertPageContains(".vjs-peach-speed-chips{display:flex;align-items:flex-start;gap:8px}")
+ self.assertPageContains(
+ ".vjs-peach-speed-preset-label{margin-top:4px;font-size:var(--fs-xs);font-weight:400;"
+ "line-height:14px;color:rgba(255,255,255,.7)}")
+ self.assertPageContains(
+ "height:32px;min-height:32px;padding:0;border:0;border-radius:var(--pill-radius);"
+ "background:rgba(255,255,255,.1);")
+ self.assertPageContains(
+ ".vjs-peach-speed-slider .vjs-peach-speed-button{flex:none;width:32px;font-size:var(--fs-2xl)}")
+ self.assertPageContains(
+ ".vjs-peach-speed-chips .vjs-peach-speed-button{width:53px;gap:4px;font-size:var(--fs-xs)}")
+ # 设置面板里的按钮统一是 100% 宽、48px 高、`:before` 铺满的高亮层,胶囊得单独退出这套。
+ self.assertPageContains(".vjs-peach-settings-menu .vjs-peach-speed-button:before{content:none}")
+ self.assertPageContains(
+ "background:linear-gradient(to right,#fff 0,#fff var(--peach-speed-percent),"
+ "#909090 var(--peach-speed-percent),#909090 100%)}")
+ self.assertPageContains(
+ ".vjs-peach-speed-range::-webkit-slider-thumb{-webkit-appearance:none;appearance:none;"
+ "width:16px;height:16px;")
+ # 头 57px 加内容 192px 是 249px,比窄屏给的 246px 高,所以内距和两处间隔都收到 16px。
+ self.assertPageContains(".video-js.vjs-peach-xsmall .vjs-peach-speed-panel{padding:16px}")
+ self.assertPageContains(".video-js.vjs-peach-xsmall .vjs-peach-speed-slider{margin-bottom:16px}")
+
+ def test_play_and_mute_clicks_flash_a_centered_bezel(self):
+ """点播放键和静音键都在画面中心闪一下当前动作的图标。
+
+ 照 player 9470c977 的 `.ytp-delhi-modern .ytp-bezel`:78px 毛玻璃圆、54px 图标,
+ 1s cubic-bezier(.05,0,0,1) 走 0→1.33→1 的缩放淡出,窄屏收到 64px 配 48px 图标。
+ """
+ self.assertPageContains(
+ "bezel.className='vjs-peach-bezel';bezel.setAttribute('role','status');bezel.hidden=true;")
+ self.assertPageContains(
+ "bezel.innerHTML=`<span class=\"vjs-peach-bezel-icon\">${icon('player-play')}</span>`;")
+ # 重复点同一个键要重新播一次动画:撤类之后读一次布局强制回流,再挂回去。
+ self.assertPageContains("void bezel.offsetWidth;bezel.classList.add('vjs-peach-bezel-run');")
+ self.assertPageContains("player.el().insertBefore(bezel,controlBar);")
+ self.assertPageContains("flashBezel(paused?'player-play':'player-pause',paused?'播放':'暂停');")
+ self.assertPageContains(
+ "flashBezel(silent?'player-volume':'player-volume-muted',silent?'取消静音':'静音');")
+ # 捕获阶段挂在控制条上,一定早于按钮自己的 Video.js 监听,读到的是切换之前的状态,
+ # 闪出来的正好是这一次做的事;冒泡阶段读到的已经是切换之后,图标会反。
+ self.assertPageContains(" }\n },true);")
+ self.assertPageContains(
+ ".vjs-peach-bezel{position:absolute;z-index:19;left:50%;top:50%;width:78px;height:78px;"
+ "margin:-39px 0 0 -39px;")
+ # 基础规则是 display:grid,不写这一条 hidden 属性压不住它。
+ self.assertPageContains(".vjs-peach-bezel[hidden]{display:none}")
+ self.assertPageContains(".vjs-peach-bezel-icon{display:grid;place-items:center;width:54px;height:54px}")
+ self.assertPageContains(
+ ".vjs-peach-bezel-run{animation:peach-bezel-fadeout 1s cubic-bezier(.05,0,0,1) 1 normal forwards}")
+ self.assertPageContains(
+ "@keyframes peach-bezel-fadeout{0%{opacity:0}25%,75%{opacity:1;transform:scale(1.33)}"
+ "to{opacity:0;transform:scale(1)}}")
+ self.assertPageContains(
+ ".video-js.vjs-peach-xsmall .vjs-peach-bezel{width:64px;height:64px;margin:-32px 0 0 -32px}")
+ self.assertPageContains(".video-js.vjs-peach-xsmall .vjs-peach-bezel-icon{width:48px;height:48px}")
+
def test_opening_one_player_overlay_closes_the_other(self):
"""设置面板和播放统计都盖在画面上,同时开就互相遮挡,开哪个另一个自己收起。
@@ -3736,19 +3831,21 @@ class WebUiSourceTests(unittest.TestCase):
self.assertPageContains("openItem(+button.dataset.reviewOpenItem)")
def test_detail_title_keeps_source_and_file_actions_inline(self):
- """来源徽标浮左、定位文件与刷新浮右,两者都浮出标题的文字流。
+ """来源徽标浮左只缩进标题的第一行,定位文件与刷新跟在标题文字末尾。
- 三者并排参与弹性布局时,徽标那一列会把标题的每一行都缩进,右端 66px 的动作
- 又在标题占满一行时被整块挤到下一行;浮动只缩短第一行的行盒,动作也留在行末。
+ 三者并排参与弹性布局时,徽标那一列会把标题的每一行都缩进;浮动只缩短第一行的
+ 行盒,折行后的第二行顶到内容左边缘。两个动作是行内块,上下各 3px 外边距把它们
+ 所在那一行的行盒撑到 32px,26px 的按钮和上下两行文字各留 3px。
"""
self.assertPageContains(
- '<div class="detailtitle">${srcBadge(it.location,it.cost,\'srcbig\')}'
+ '<div class="detailtitle">${srcBadge(it.location,it.cost,\'srcbig\')}\n'
+ ' <div class="stitle">${javTitleHtml(it)}'
'${it.location===\'online\'?\'\':`<span class="srctools detailtitletools">'
- '${sourceToolButtons(it.id)}</span>`}')
- self.assertPageContains('<div class="stitle">${javTitleHtml(it)}</div></div>')
+ '${sourceToolButtons(it.id)}</span>`}</div></div>')
self.assertPageContains(".detailtitle{display:flow-root;margin-bottom:10px}")
- self.assertPageContains(".detailtitletools{float:right;height:26px;margin:0 0 2px 8px;flex-wrap:nowrap}")
- # 浮动块整好一行高(28px),行高 1.75 既让 26px 的按钮上下留出空隙,也让第二行起整行宽。
+ self.assertPageContains(
+ ".detailtitletools{display:inline-flex;vertical-align:middle;margin:3px 0 3px 8px;flex-wrap:nowrap}")
+ # 徽标那个浮动块整好一行高(28px),所以第二行起是整行宽。
self.assertPageContains(".detailtitle .stitle{min-width:0;margin:0;line-height:1.75}")
def test_detail_metadata_uses_icons_instead_of_release_copy(self):
diff --git a/web/app.css b/web/app.css
index d43767a03..1afc38dbf 100644
--- a/web/app.css
+++ b/web/app.css
@@ -1417,6 +1417,58 @@ body.index-open #tiers,body.index-open #tagbar{display:none}
.video-js .vjs-peach-menu-option{display:grid;grid-template-columns:35px minmax(0,1fr);align-items:center;padding:0 20px 0 0!important;text-align:left;font-size:var(--fs-md)!important;line-height:18.2px}
.vjs-peach-option-check{width:35px;height:24px;display:grid;place-items:center}.vjs-peach-option-check svg{width:24px;height:24px;display:block;fill:currentColor;stroke:none}
.vjs-peach-option-label{min-width:0}
+/* 播放速度面板照 YouTube delhi-modern(player 9470c977 的 www-player.css 与 base.js):
+ 内容区 24px/16px/16px 内距;读数 18px/900/22px 居中、下留 24px;滑条一行 gap 16px、
+ 下留 24px,加减键 32px 圆、24px 字,各动 0.05;预设胶囊 53×32、圆角 16、12px 字、gap 8px,
+ 底色 rgba(255,255,255,.1)、悬停 .2、按下 .3,过渡 .2s cubic-bezier(.05,0,0,1);
+ 1.0 下面挂一行 14px 行高的说明。滑条轨道 4px 高,已过部分 #fff、余下 #909090,
+ 把手 16px 白圆上移 6px;已过比例由脚本写进自定义属性,上游同样是自定义属性驱动。
+ 字号、字重和圆角走 Peach 自己的 token:上游读数那档 18px/900 和说明那档 10px 都不在
+ Peach 的字号刻度上,900 也不在 Geist 的三档字重里;胶囊和轨道的圆角本来就大于自身高度的
+ 一半,`--pill-radius` 渲染出来与上游那两个字面值一模一样。 */
+.vjs-peach-speed-panel{box-sizing:border-box;display:flex;flex-direction:column;padding:24px 16px 16px}
+.vjs-peach-speed-display{display:flex;justify-content:center;margin-bottom:24px;
+ font-size:var(--fs-lg);font-weight:600;line-height:22px;color:#fff}
+.vjs-peach-speed-slider{display:flex;align-items:center;gap:16px;margin-bottom:24px}
+.vjs-peach-speed-chips{display:flex;align-items:flex-start;gap:8px}
+.vjs-peach-speed-preset{display:flex;flex-direction:column;align-items:center}
+.vjs-peach-speed-preset-label{margin-top:4px;font-size:var(--fs-xs);font-weight:400;line-height:14px;color:rgba(255,255,255,.7)}
+.vjs-peach-settings-menu .vjs-peach-speed-button{display:flex;justify-content:center;align-items:center;
+ height:32px;min-height:32px;padding:0;border:0;border-radius:var(--pill-radius);background:rgba(255,255,255,.1);
+ color:#fff;font-weight:500;line-height:16px;text-align:center;cursor:pointer;
+ transition:background .2s cubic-bezier(.05,0,0,1)}
+.vjs-peach-settings-menu .vjs-peach-speed-button:before{content:none}
+.vjs-peach-settings-menu .vjs-peach-speed-button:hover{background:rgba(255,255,255,.2)}
+.vjs-peach-settings-menu .vjs-peach-speed-button:active{background:rgba(255,255,255,.3)}
+.vjs-peach-speed-slider .vjs-peach-speed-button{flex:none;width:32px;font-size:var(--fs-2xl)}
+.vjs-peach-speed-chips .vjs-peach-speed-button{width:53px;gap:4px;font-size:var(--fs-xs)}
+.vjs-peach-speed-range{--peach-speed-percent:0%;-webkit-appearance:none;appearance:none;flex:1 1 auto;
+ width:100%;min-width:0;height:24px;margin:0;background:transparent;cursor:pointer}
+.vjs-peach-speed-range:focus-visible{outline:0}
+.vjs-peach-speed-range::-webkit-slider-runnable-track{height:4px;border-radius:var(--pill-radius);
+ background:linear-gradient(to right,#fff 0,#fff var(--peach-speed-percent),#909090 var(--peach-speed-percent),#909090 100%)}
+.vjs-peach-speed-range::-webkit-slider-thumb{-webkit-appearance:none;appearance:none;width:16px;height:16px;
+ margin-top:-6px;border-radius:50%;background:#fff}
+.vjs-peach-speed-range::-moz-range-track{height:4px;border-radius:var(--pill-radius);
+ background:linear-gradient(to right,#fff 0,#fff var(--peach-speed-percent),#909090 var(--peach-speed-percent),#909090 100%)}
+.vjs-peach-speed-range::-moz-range-thumb{width:16px;height:16px;border:0;border-radius:50%;background:#fff}
+/* 320px 高的播放器只给面板 246px:内距和两处 24px 间隔都收到 16px 就是 225px。 */
+.video-js.vjs-peach-xsmall .vjs-peach-speed-panel{padding:16px}
+.video-js.vjs-peach-xsmall .vjs-peach-speed-display,
+.video-js.vjs-peach-xsmall .vjs-peach-speed-slider{margin-bottom:16px}
+/* 中心提示照同一份 www-player.css:`.ytp-bezel` 78px 圆、blur(16px)、rgba(0,0,0,.6),
+ 图标 54px;窄屏收到 64px 圆配 48px 图标。动画 1s cubic-bezier(.05,0,0,1) 走
+ 0→1.33→1 的缩放淡出,`role="status"` 带这一次的动作名。 */
+.vjs-peach-bezel{position:absolute;z-index:19;left:50%;top:50%;width:78px;height:78px;margin:-39px 0 0 -39px;
+ display:grid;place-items:center;border-radius:50%;background:rgba(0,0,0,.6);
+ backdrop-filter:blur(16px);-webkit-backdrop-filter:blur(16px);color:#fff;opacity:0;pointer-events:none}
+.vjs-peach-bezel[hidden]{display:none}
+.vjs-peach-bezel-icon{display:grid;place-items:center;width:54px;height:54px}
+.vjs-peach-bezel-icon svg{width:100%;height:100%;display:block;fill:currentColor;stroke:none}
+.vjs-peach-bezel-run{animation:peach-bezel-fadeout 1s cubic-bezier(.05,0,0,1) 1 normal forwards}
+@keyframes peach-bezel-fadeout{0%{opacity:0}25%,75%{opacity:1;transform:scale(1.33)}to{opacity:0;transform:scale(1)}}
+.video-js.vjs-peach-xsmall .vjs-peach-bezel{width:64px;height:64px;margin:-32px 0 0 -32px}
+.video-js.vjs-peach-xsmall .vjs-peach-bezel-icon{width:48px;height:48px}
/* 悬停提示取自 YouTube delhi-modern(player 9470c977 的 www-player.css):毛玻璃 blur(16px)、
8px 圆角(--surface-radius)、5px 9px 内距、13px/15px 500 字重(--fs-sm)、
text-shadow 0 0 2px #000;快捷键徽标 1px rgba(255,255,255,.3) 边、4px 圆角(--badge-radius)、
@@ -1455,8 +1507,12 @@ body.index-open #tiers,body.index-open #tagbar{display:none}
.video-js.vjs-peach-xsmall .vjs-peach-right-controls>.vjs-control:not(.vjs-peach-expand)>button>svg{width:18px;height:18px}
/* 窄屏只有展开键不缩:YouTube 那边其余按钮的 svg 是 18px 加 7px 内边距,
`.ytp-expand-right-bottom-section-button` 的 svg 内边距是 0,整块 32px 铺满按钮。
- 跟着缩到 18px 的话,这个本来就细的箭头在窄屏上几乎看不出是个可点的键。 */
+ 跟着缩到 18px 的话,这个箭头在窄屏上几乎看不出是个可点的键。 */
.video-js.vjs-peach-xsmall .vjs-peach-expand>button>svg{width:32px;height:32px}
+/* 窄屏的悬停底照 `.ytp-delhi-modern.ytp-xsmall-width-mode .ytp-chrome-bottom .ytp-button:before`:
+ 32×32 的正圆。上游按钮本体 32px 配 4px 2px 外边距,正好是这里 40px 行高里 36px 的一格。 */
+.video-js.vjs-peach-xsmall .vjs-peach-right-controls>.vjs-control>.vjs-peach-hover{
+ left:2px;width:32px;height:32px;border-radius:50%}
/* 折叠态里设置键就是这排的右端,`right:-100px` 是给它右边还有影院和全屏时留的位;
窄屏照原样偏移会把整个面板推到播放器外面。贴住设置键右缘往左铺,高度按播放器
自己的高度收顶(`--peach-player-h` 由布局脚本写在播放器元素上)。 */
@@ -1540,9 +1596,9 @@ body.index-open #tiers,body.index-open #tagbar{display:none}
.sidecontent{box-sizing:border-box;width:100%;height:100%;max-height:76vh;padding:18px;display:flex;gap:0;
flex-direction:column;overflow-y:auto;overflow-x:hidden}
.stitle{font-size:var(--fs-lg);line-height:1.4;word-break:break-all;margin-bottom:8px}
-/* 来源徽标和两个文件动作都浮出标题的文字流:徽标浮左只缩进第一行,折行后的第二行顶到
- 内容左边缘;动作浮右占住行末那 66px,右边有空间时不会被挤到下一行。两个浮动块都刚好
- 一行高(28px),所以第二行起是整行宽。行高 1.75 让 26px 的按钮上下各留出空隙。 */
+/* 来源徽标浮左,只缩进标题的第一行,折行后的第二行顶到内容左边缘;浮动块整好一行高
+ (28px),所以第二行起是整行宽。两个文件动作跟在标题文字末尾,26px 的按钮加 3px 上下
+ 外边距把所在那一行的行盒撑到 32px,按钮和上下两行文字各留 3px。 */
.detailtitle{display:flow-root;margin-bottom:10px}
.detailtitle>.srcbig{float:left;width:17px;height:28px;margin:0 8px 0 0;place-items:center}
.detailtitle .stitle{min-width:0;margin:0;line-height:1.75}
@@ -1556,7 +1612,7 @@ body.index-open #tiers,body.index-open #tagbar{display:none}
.srctools button:hover{background:var(--hover);color:var(--ink)}
.srctools button:disabled{background:var(--surface);border-color:var(--border-15);color:var(--muted);cursor:default}
.srcstate{font-size:var(--fs-xs);color:var(--muted);min-width:0;flex:1 1 100%}
-.detailtitletools{float:right;height:26px;margin:0 0 2px 8px;flex-wrap:nowrap}.detailtitlestate{display:block;margin:-4px 0 10px}
+.detailtitletools{display:inline-flex;vertical-align:middle;margin:3px 0 3px 8px;flex-wrap:nowrap}.detailtitlestate{display:block;margin:-4px 0 10px}
.detailtitlestate:empty{display:none}
.photohead .srctools{margin:0 0 0 auto}
.photohead .srcstate{flex:none}
diff --git a/web/app.js b/web/app.js
index 660bbbf1b..bf5ebb747 100644
--- a/web/app.js
+++ b/web/app.js
@@ -915,12 +915,38 @@ function mountPlayerQualityControl(player,video,fallbackHeight=0,initialSourceQu
panel.querySelector('[data-player-speed]').onclick=()=>showSpeed();
panel.querySelector('[data-player-quality-view]').onclick=()=>showQuality();
};
+ /* 播放速度面板照 YouTube delhi-modern(player 9470c977 的 base.js):滑条两端取播放器
+ 支持的最低与最高倍速,步进 0.05,加减键各动 0.05 并按两位小数收敛,读数写成 1.00x。
+ 预设胶囊点了就地生效,面板不退回上一级;上游第五个胶囊是 Premium 专属的 3.0 倍,
+ Peach 没有分级,那一格连同角标一起不做。 */
+ const SPEED_RATES=[.25,.5,.75,1,1.25,1.5,1.75,2],SPEED_STEP=.05,SPEED_PRESETS=[1,1.25,1.5,2];
+ const speedLabel=speed=>Number.isInteger(speed)?speed.toFixed(1):String(speed);
const showSpeed=(direction=1)=>{
- const selectedSpeed=Number(player.playbackRate())||1,speeds=[.25,.5,.75,1,1.25,1.5,1.75,2];
- const panel=renderPanel(`<div class="vjs-peach-panel-header"><button type="button" class="vjs-peach-menu-back" data-player-menu-back aria-label="返回上一个菜单">${icon('player-menu-back')}</button><strong>播放速度</strong></div><div class="vjs-peach-panel-menu">${speeds.map(speed=>
- `<button type="button" class="vjs-peach-menu-option" role="menuitemradio" data-player-speed-option="${speed}" aria-checked="${speed===selectedSpeed}"><span class="vjs-peach-option-check">${speed===selectedSpeed?icon('player-option-check'):''}</span><span class="vjs-peach-option-label">${speed===1?'正常':speed+'×'}</span></button>`).join('')}</div>`,direction);
+ const min=SPEED_RATES[0],max=SPEED_RATES[SPEED_RATES.length-1];
+ const clampSpeed=value=>Math.min(max,Math.max(min,Number(value.toFixed(2))));
+ const panel=renderPanel(`<div class="vjs-peach-panel-header"><button type="button" class="vjs-peach-menu-back" data-player-menu-back aria-label="返回上一个菜单">${icon('player-menu-back')}</button><strong>播放速度</strong></div>
+ <div class="vjs-peach-speed-panel"><div class="vjs-peach-speed-display"><output data-player-speed-display></output></div>
+ <div class="vjs-peach-speed-slider"><button type="button" class="vjs-peach-speed-button" data-player-speed-step="-1" aria-label="播放速度减 0.05">−</button>
+ <input type="range" class="vjs-peach-speed-range" data-player-speed-range min="${min}" max="${max}" step="${SPEED_STEP}" aria-label="播放速度">
+ <button type="button" class="vjs-peach-speed-button" data-player-speed-step="1" aria-label="播放速度加 0.05">+</button></div>
+ <div class="vjs-peach-speed-chips">${SPEED_PRESETS.map(speed=>
+ `<span class="vjs-peach-speed-preset"><button type="button" class="vjs-peach-speed-button" data-player-speed-option="${speed}" aria-pressed="false">${speedLabel(speed)}</button>${speed===1?'<span class="vjs-peach-speed-preset-label">正常</span>':''}</span>`).join('')}</div></div>`,direction);
+ const display=panel.querySelector('[data-player-speed-display]'),range=panel.querySelector('[data-player-speed-range]');
+ const syncSpeed=()=>{
+ const speed=clampSpeed(Number(player.playbackRate())||1);
+ display.textContent=`${speed.toFixed(2)}x`;range.value=String(speed);
+ range.style.setProperty('--peach-speed-percent',`${(speed-min)/(max-min)*100}%`);
+ panel.querySelectorAll('[data-player-speed-option]').forEach(button=>
+ button.setAttribute('aria-pressed',String(Number(button.dataset.playerSpeedOption)===speed)));
+ };
+ const setSpeed=speed=>{player.playbackRate(clampSpeed(speed));syncSpeed()};
panel.querySelector('[data-player-menu-back]').onclick=()=>showMain(-1);
- panel.querySelectorAll('[data-player-speed-option]').forEach(button=>button.onclick=()=>{player.playbackRate(Number(button.dataset.playerSpeedOption));showMain(-1)});
+ range.oninput=()=>setSpeed(Number(range.value));
+ panel.querySelectorAll('[data-player-speed-step]').forEach(button=>button.onclick=()=>
+ setSpeed((Number(player.playbackRate())||1)+Number(button.dataset.playerSpeedStep)*SPEED_STEP));
+ panel.querySelectorAll('[data-player-speed-option]').forEach(button=>button.onclick=()=>
+ setSpeed(Number(button.dataset.playerSpeedOption)));
+ syncSpeed();
};
const showQuality=(direction=1)=>{
const {options}=qualityRows();
@@ -989,6 +1015,32 @@ function mountPlayerChromeLayout(player){
const syncVolumeIcon=()=>{const silent=player.muted()||player.volume()===0;
muteUse?.setAttribute('href',silent?'#i-player-volume-muted':'#i-player-volume');syncMuteTooltip(silent?'取消静音':'静音')};
player.on('volumechange',syncVolumeIcon);syncVolumeIcon();
+ /* 中心提示照 YouTube delhi-modern(player 9470c977 的 www-player.css 与 base.js):一块
+ 78px 的毛玻璃圆闪一下当前动作的图标,1s 走完 0→1.33→1 的缩放淡出。捕获阶段读的是
+ 切换之前的状态,闪出来的正好是这一次做的事:暂停中点播放键闪播放。键盘快捷键走的
+ 也是同一个按钮的点击路径,所以只挂控制条这一处。 */
+ const bezel=document.createElement('div');
+ bezel.className='vjs-peach-bezel';bezel.setAttribute('role','status');bezel.hidden=true;
+ bezel.innerHTML=`<span class="vjs-peach-bezel-icon">${icon('player-play')}</span>`;
+ const bezelUse=bezel.querySelector('use');let bezelTimer=null;
+ const flashBezel=(name,label)=>{
+ bezelUse.setAttribute('href',`#i-${name}`);bezel.setAttribute('aria-label',label);
+ bezel.hidden=false;bezel.classList.remove('vjs-peach-bezel-run');
+ void bezel.offsetWidth;bezel.classList.add('vjs-peach-bezel-run');
+ if(bezelTimer)clearTimeout(bezelTimer);
+ bezelTimer=setTimeout(()=>{bezel.hidden=true;bezel.classList.remove('vjs-peach-bezel-run')},1000);
+ };
+ player.el().insertBefore(bezel,controlBar);
+ controlBar.addEventListener('click',event=>{
+ if(event.target.closest('.vjs-play-control')){
+ const paused=player.paused()||player.ended();
+ flashBezel(paused?'player-play':'player-pause',paused?'播放':'暂停');
+ }else if(event.target.closest('.vjs-mute-control')){
+ const silent=player.muted()||player.volume()===0;
+ flashBezel(silent?'player-volume':'player-volume-muted',silent?'取消静音':'静音');
+ }
+ },true);
+ player.on('dispose',()=>{if(bezelTimer)clearTimeout(bezelTimer)});
const time=document.createElement('button');let remaining=false;
time.type='button';time.className='vjs-peach-time vjs-control';time.dataset.playerTime='';
time.innerHTML='<span class="vjs-peach-time-text"></span>';
@@ -1042,8 +1094,10 @@ function mountPlayerChromeLayout(player){
const expand=document.createElement('div');expand.className='vjs-peach-expand vjs-control';
/* 高亮层要挂在 `.vjs-control` 这一层:亮起来的规则是 `>.vjs-peach-hover`,塞进
button 里就差一层,展开键成了这排唯一没有 hover 的按钮。位置在这排左端——
- 这排整体右对齐,展开时新按钮从它右边长出来,箭头指左才对得上要发生的事。 */
- expand.innerHTML=`<button type="button" data-player-expand aria-expanded="false">${icon('player-menu-next')}</button><span class="vjs-peach-hover" aria-hidden="true"></span>`;
+ 这排整体右对齐,展开时新按钮从它右边长出来,箭头指左才对得上要发生的事。箭头用
+ `i-player-expand`:菜单行那个 `>` 是 24 视框、一个单位粗的细线,铺到 32px 只有 1.3px 粗;
+ 上游展开键自带一个 32 视框、两个单位粗的箭头,同样 32px 渲染就是 2px。 */
+ expand.innerHTML=`<button type="button" data-player-expand aria-expanded="false">${icon('player-expand')}</button><span class="vjs-peach-hover" aria-hidden="true"></span>`;
group.prepend(expand);
const expandButton=expand.querySelector('button');
const syncExpandTooltip=playerControlTooltip(expandButton,'展开控件');
@@ -6297,8 +6351,8 @@ async function openItem(id,push=true,queueContext=null,anchor=null){
:`<video id="vid" class="video-js vjs-big-play-centered" controls playsinline preload="metadata"></video>`}
</div>${queueContext?queueHtml(queueContext,it.id):''}
<div class="side"><div class="sidecontent">
- <div class="detailtitle">${srcBadge(it.location,it.cost,'srcbig')}${it.location==='online'?'':`<span class="srctools detailtitletools">${sourceToolButtons(it.id)}</span>`}
- <div class="stitle">${javTitleHtml(it)}</div></div>
+ <div class="detailtitle">${srcBadge(it.location,it.cost,'srcbig')}
+ <div class="stitle">${javTitleHtml(it)}${it.location==='online'?'':`<span class="srctools detailtitletools">${sourceToolButtons(it.id)}</span>`}</div></div>
${it.location==='online'?'':`<span class="srcstate detailtitlestate" aria-live="polite"></span>`}
<div class="smeta mono">
<span class="detailmetaitem">${icon('monitor')}<span>${it.width||'?'}×${it.height||'?'}</span></span>
diff --git a/web/index.html b/web/index.html
index a87a492ba..ebefaadde 100644
--- a/web/index.html
+++ b/web/index.html
@@ -51,6 +51,7 @@
<symbol id="i-player-bezel-play" viewBox="0 0 36 36" fill="currentColor" stroke="none"><path d="M 17 8.6 L 10.89 4.99 C 9.39 4.11 7.5 5.19 7.5 6.93 C 7.5 6.93 7.5 6.93 7.5 6.93 L 7.5 29.06 C 7.5 30.8 9.39 31.88 10.89 31 C 10.89 31 10.89 31 10.89 31 L 17 27.4 C 17 27.4 17 27.4 17 27.4 C 17 27.4 17 27.4 17 27.4 L 17 8.6 C 17 8.6 17 8.6 17 8.6 C 17 8.6 17 8.6 17 8.6 Z M 17 8.6 L 17 8.6 C 17 8.6 17 8.6 17 8.6 C 17 8.6 17 8.6 17 8.6 V 27.4 C 17 27.4 17 27.4 17 27.4 C 17 27.4 17 27.4 17 27.4 L 33 18 C 33 18 33 18 33 18 C 33 18 33 18 33 18 V 18 L 17 8.6 C 17 8.6 17 8.6 17 8.6 C 17 8.6 17 8.6 17 8.6 Z"/></symbol>
<symbol id="i-player-bezel-pause" viewBox="0 0 36 36" fill="currentColor" stroke="none"><path d="M 12.75 4.5 L 9.75 4.5 C 9.15 4.5 8.58 4.73 8.15 5.15 C 7.73 5.58 7.5 6.15 7.5 6.75 L 7.5 29.25 C 7.5 29.84 7.73 30.41 8.15 30.84 C 8.58 31.26 9.15 31.5 9.75 31.5 L 12.75 31.5 C 13.34 31.5 13.91 31.26 14.34 30.84 C 14.76 30.41 15 29.84 15 29.25 L 15 6.75 C 15 6.15 14.76 5.58 14.34 5.15 C 13.91 4.73 13.34 4.5 12.75 4.5 Z M 26.25 4.5 L 23.25 4.5 C 22.65 4.5 22.08 4.73 21.65 5.15 C 21.23 5.58 21 6.15 21 6.75 L 21 29.25 C 21 29.84 21.23 30.41 21.65 30.84 C 22.08 31.26 22.65 31.5 23.25 31.5 L 26.25 31.5 C 26.84 31.5 27.41 31.26 27.84 30.84 C 28.26 30.41 28.5 29.84 28.5 29.25 L 28.5 6.75 L 28.5 6.75 C 28.5 6.15 28.26 5.58 27.84 5.15 C 27.41 4.73 26.84 4.5 26.25 4.5 Z"/></symbol>
<symbol id="i-player-menu-next" viewBox="0 0 24 24" fill="currentColor" stroke="none"><path d="m9.4 18.4-.7-.7 5.6-5.6-5.7-5.7.7-.7 6.4 6.4Z"/></symbol>
+ <symbol id="i-player-expand" viewBox="0 0 32 32" fill="currentColor" stroke="none"><path d="m12.59 20.34 4.58-4.59-4.58-4.59L14 9.75l6 6-6 6z"/></symbol>
<symbol id="i-player-menu-back" viewBox="0 0 32 32" fill="currentColor" stroke="none"><path d="m19.41 20.09-4.58-4.59 4.58-4.59L18 9.5l-6 6 6 6Z"/></symbol>
<symbol id="i-player-option-check" viewBox="0 0 24 24" fill="currentColor" stroke="none"><path d="M9 16.2 4.8 12l-1.4 1.4L9 19 21 7l-1.4-1.4z"/></symbol>
<symbol id="i-history" viewBox="0 0 24 24"><path d="M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8" /><path d="M3 3v5h5" /><path d="M12 7v5l4 2" /></symbol>