6 Commits
Author SHA1 Message Date
cat-shark 0bf0a1f1da docs: the VR button is draggable (0.4.0.0) 2026-10-18 01:21:19 +08:00
cat-shark 1176c2009c plugin: publish 0.4.0.0 (bundle ae28bd) 2026-10-18 01:21:01 +08:00
cat-shark 30f97808ae ui: make the VR button draggable
It was pinned to the bottom-right corner. On a short window that put it straight
on top of the bitrate choices the playback watchdog shows (that panel is
centred), and there was no way to move it out of the way.

The button now uses left/top (set from JS) instead of right/bottom, is draggable
with pointer events, and remembers where it was dropped. Details that matter:

  - touch-action:none, otherwise a drag on a touch screen scrolls the page
  - a drag still fires a click on most browsers, so the click that ends a drag is
    swallowed; dragging never opens the panel by accident
  - clamped to the viewport, and re-clamped on resize
  - double click resets to the default corner (escape hatch for a button dragged
    somewhere awkward)
  - the settings panel follows the button instead of the viewport corner, so the
    two cannot drift apart; it prefers to sit just above the button, falls back
    to below, and clamps on screen when it is taller than the space available

Verified against a local harness, 18 checks, all passing: default placement
matches the old corner, a drag moves it by exactly the pointer delta and
persists it, the click ending a drag does not open the panel, a plain click
still does, the panel tracks the button's right edge, clamping holds at all four
edges, and double click restores the default.
2026-10-18 01:20:22 +08:00
cat-shark 85fea48159 docs: document the decoder-driven canPlayType override (0.3.0.0)
README gains 1.3 and the 2.0 capability row is corrected: the old
"8K HEVC decodingInfo supported:true" was only ever true for 8-bit Main.
HANDOFF 18.7/18.8 record what the override does, the three verified modes, the
kill switch, and what is deliberately left out (AV1, and acting on smooth:false).
2026-10-18 01:09:00 +08:00
cat-shark 986d30dfb4 plugin: publish 0.3.0.0 (bundle 4e9a8f) 2026-10-18 01:08:12 +08:00
cat-shark ab36d2f25c caps: ask the real decoder, and stop the client from over-claiming HEVC
The capability probe only ever asked canPlayType about Main profile (8-bit)
codec strings, which is why the project notes said "8K HEVC: supported" right up
until a Main 10 file showed up and could not be decoded at all. It now also asks
about Main 10, and -- more importantly -- asks the decoder itself.

The override: Jellyfin Web derives its entire HEVC claim from canPlayType
(browserDeviceProfile.js):

    if (canPlayType('video/mp4; codecs="hvc1.2.4.L183"')) {
        maxHevcLevel = 183;              // level 6.1 = 8K
        hevcProfiles = 'main|main 10';
    }

canPlayType answers "does this system have an HEVC decoder", not "can it do
8192x4096 Main 10 at 60fps". A desktop that merely ships an HEVC decoder
therefore claims 8K Main 10, the server picks DirectPlay, and playback dies on a
black screen with no player UI at all. MediaCapabilities.decodingInfo asks the
actual decoder, so its verdict is fed back through canPlayType and Jellyfin's own
logic lands on the right profile -- the desktop drops to what it can really do
and the server transcodes, while a Quest that genuinely decodes 8K Main 10 keeps
DirectPlay. Meta's browser-video docs recommend exactly this API over UA sniffing.

Deliberately conservative: only supported === false downgrades.
supported:true/smooth:false is recorded but changes nothing -- too close to the
edge to act on, and the watchdog already covers "claimed to work, did not".
Kill switch if a device reports nonsense: localStorage['jfvr-cpt'] = 'off'.

Each level is probed at the resolution it exists for (L120 -> 1080p30,
L153 -> 4K60, L183/L186 -> 8K60), because a level string carries no dimensions.

Verified against a local harness in three modes, all passing:
  pc    -> 8K Main10 blocked, Jellyfin caps at level 153, the 8K Main 10 file
           exceeds the claim and the server transcodes
  quest -> nothing blocked, claim stays >= 183, DirectPlay preserved
  off   -> hook not installed, canPlayType untouched, old behaviour restored
Also re-ran the playback watchdog on the new bundle: still fires on media error.

Also widens the harness gitignore to _harness*.html for the new codec harness.
2026-10-18 01:07:44 +08:00
8 changed files with 737 additions and 25 deletions
+1 -1
View File
@@ -9,7 +9,7 @@ secrets*.md
# deploy.py --legacy actually uses), so only the legacy one is tracked. # deploy.py --legacy actually uses), so only the legacy one is tracked.
/jfvr-mvp.js /jfvr-mvp.js
# Temporary offline test page (fake <video> + libass canvas + XR stubs). # Temporary offline test page (fake <video> + libass canvas + XR stubs).
_harness.html _harness*.html
# --- build / tooling noise -------------------------------------------- # --- build / tooling noise --------------------------------------------
__pycache__/ __pycache__/
+25 -4
View File
@@ -122,7 +122,7 @@ Style: RightEye, Alignment=8, MarginL=1920, MarginR=50 , MarginV=700
| `XRWebGLBinding.createQuadLayer` | **true** | | `XRWebGLBinding.createQuadLayer` | **true** |
| `XRWebGLBinding.getSubImage` | **需要 2 个参数** `(layer, frame)` | | `XRWebGLBinding.getSubImage` | **需要 2 个参数** `(layer, frame)` |
| `MAX_TEXTURE_SIZE` / `MAX_RENDERBUFFER_SIZE` | **8192 / 16384** | | `MAX_TEXTURE_SIZE` / `MAX_RENDERBUFFER_SIZE` | **8192 / 16384** |
| 8K HEVC `decodingInfo` | `supported:true, powerEfficient:true` | | 8K HEVC `decodingInfo` | `supported:true, powerEfficient:true`(仅 8-bit Main,见 ADDENDUM 12) |
| `supportedFrameRates` | **[72, 80, 90, 120]** | | `supportedFrameRates` | **[72, 80, 90, 120]** |
| `enabledFeatures` | `[local, viewer, bounded-floor, layers, hand-tracking, webxr, local-floor]` | | `enabledFeatures` | `[local, viewer, bounded-floor, layers, hand-tracking, webxr, local-floor]` |
| 手部追踪 | ✅ 25 关节齐全,profiles `["oculus-hand","generic-hand","generic-hand-select","generic-trigger"]` | | 手部追踪 | ✅ 25 关节齐全,profiles `["oculus-hand","generic-hand","generic-hand-select","generic-trigger"]` |
@@ -890,7 +890,28 @@ enableautobitratebitrate-Video-<true|false> = false ← 上游拼写,bitra
1. **续播点 33:22.759 的来历**:就是 2026-10-05 那次转码会话留下的(`stopped ... at 2002759ms`)。所以 10-17 两次播放都从 33:22 续播,画面出不来进度自然不动,于是「停在 33:22」重复了两次。 1. **续播点 33:22.759 的来历**:就是 2026-10-05 那次转码会话留下的(`stopped ... at 2002759ms`)。所以 10-17 两次播放都从 33:22 续播,画面出不来进度自然不动,于是「停在 33:22」重复了两次。
2. **文件本身没问题**:完全分配无空洞(`du` 实际用量 == 表观大小)、`moov` 在文件头(faststart 正常)、33:22 处 ffmpeg 解码无报错、Jellyfin 数据库里时长正确(50:58)。同目录还有 3 个垃圾广告文件(`.url` × 3 + 一个 20 MB 的 `三 上 悠 亚…mp4`),是盗版站打包进来的。 2. **文件本身没问题**:完全分配无空洞(`du` 实际用量 == 表观大小)、`moov` 在文件头(faststart 正常)、33:22 处 ffmpeg 解码无报错、Jellyfin 数据库里时长正确(50:58)。同目录还有 3 个垃圾广告文件(`.url` × 3 + 一个 20 MB 的 `三 上 悠 亚…mp4`),是盗版站打包进来的。
### 18.7 待办 ### 18.7 已做(插件 0.3.0.0 / bundle `4e9a8f`)
- [ ] `src/00-core.js` 的能力探测补上 Main 10(`hev1.2.4.L183.B0` / `hvc1.2.4.L183.B0`)和 8K/4K 的分档,让诊断面板不再只说「8K HEVC 支持」 - [x] `src/00-core.js` 的能力探测补上 Main 10 和 8K/4K 分档;新增 `NS.caps.codec`(`decodingInfo` 逐档结果)与 `NS.capsDiag()` 里的 `HEVC real` 段
- [ ] 若想彻底自动化(PC 自动转码、Quest 继续直连 8K):用 `MediaCapabilities.decodingInfo` 真机探测后覆盖 `HTMLVideoElement.prototype.canPlayType`,让 Jellyfin Web 自己那套 `maxHevcLevel` 逻辑算出准确 profile(Meta 官方文档也是这么建议的)。看门狗是「先给用户一个出路」的版本,不是这个。 - [x] **彻底自动化**:用 `MediaCapabilities.decodingInfo` 真机探测后覆盖 `HTMLVideoElement.prototype.canPlayType`,让 Jellyfin Web 自己那套 `maxHevcLevel` 逻辑算出准确 profile
覆盖逻辑的关键点:
- 每档在**它对应的分辨率**上探测(level 字符串不带尺寸):`L120→1920x1080@30`、`L123→1080p60`、`L153→3840x2160@60`、`L183/L186→8192x4096@60`
- codec string → `'<profile_idc>:<level>'`(`hvc1.2.4.L183` → `2:183`);`hvc1`/`hev1` 同键,因为差的只是 sample entry
- **只有 `supported === false` 才降级**;`supported:true, smooth:false` 只记录不行动(太贴边,而且看门狗已经兜底)
- 钩子在 bundle 执行时**同步**装上(此时还没有 verdict,一律交给原生),探测结果落地后才生效
- 逃生开关:`localStorage['jfvr-cpt'] = 'off'` → 完全不装钩子
三种模式本地实测(`_harness-codec.html`,全过):
| 模式 | 结果 |
|---|---|
| `pc` | 8K Main10 被拦 → Jellyfin 封顶 level 153 → 8K 文件超出声明 → **转码** |
| `quest` | 无一被拦 → 声明保持 ≥183 → **Direct Play 不变** |
| `off` | 钩子未安装,`canPlayType` 完全未动 → 恢复旧行为 |
### 18.8 待办
- [ ] 探测目前只覆盖 HEVC。AV1 / VP9 走同一套机制,但库里没有这类片源,先不做。
- [ ] `decodingInfo` 的 `smooth` 现在是只记录不行动。如果哪天出现「supported:true 但实际掉帧」的案例,可以考虑把 `smooth === false` 也纳入降级条件(风险:可能误伤 Quest)。
+54 -1
View File
@@ -34,6 +34,7 @@ JFVR 同时也是一个标准的 **Jellyfin 插件**,通过自建 Gitea 仓库
| 脚本端点 | `/JFVR/jfvr.js`(bundle 内嵌在 DLL 里,URL 带内容哈希做缓存键) | | 脚本端点 | `/JFVR/jfvr.js`(bundle 内嵌在 DLL 里,URL 带内容哈希做缓存键) |
| 状态查询 | `/JFVR/status` | | 状态查询 | `/JFVR/status` |
| 设置页 | Dashboard → 插件 → Jellyfin Web VR(开关注入 / 覆盖脚本 URL) | | 设置页 | Dashboard → 插件 → Jellyfin Web VR(开关注入 / 覆盖脚本 URL) |
| 页面按钮 | 「VR 播放」按钮**可拖动**(位置记住;双击回到默认右下角) |
**安装**:Dashboard → 插件 → 目录 → ⚙️ → ➕ → 粘贴上面的仓库地址 → 保存 → **安装**:Dashboard → 插件 → 目录 → ⚙️ → ➕ → 粘贴上面的仓库地址 → 保存 →
在 Catalog 里找到 **Jellyfin Web VR** → 安装 → **重启 Jellyfin**。 在 Catalog 里找到 **Jellyfin Web VR** → 安装 → **重启 Jellyfin**。
@@ -93,6 +94,54 @@ enableautobitratebitrate-Video-<true|false> = false
选过之后 120 秒内不再打扰(记在 sessionStorage)。 选过之后 120 秒内不再打扰(记在 sessionStorage)。
### 1.3 让客户端如实上报解码能力(`canPlayType` 覆盖)
`src/00-core.js`。解决的问题:**Jellyfin 的直连/转码决策 100% 看客户端上报的设备档案**,而 Jellyfin Web 是从 `canPlayType` 推出整个 HEVC 声明的(`browserDeviceProfile.js`):
```js
if (canPlayType('video/mp4; codecs="hvc1.2.4.L183"')) {
maxHevcLevel = 183; // level 6.1 = 8K
hevcProfiles = 'main|main 10';
}
```
`canPlayType` 回答的是「这台机器*有没有* HEVC 解码器」,不是「能不能解 8192×4096 的 Main 10 @60fps」。所以一个只是「系统里有 HEVC 解码器」的桌面浏览器会声称支持 8K Main 10 → 服务器选 DirectPlay → 黑屏(而 OSD 压根不会创建,见 §1.2)。
插件的做法:
1. 页面加载时用 **`MediaCapabilities.decodingInfo`** 对 HEVC 各档做真机探测(每档在它对应的分辨率上测:L120→1080p30、L153→4K60、L183/L186→8K60,因为 level 字符串本身不带尺寸);
2. 把结果回灌给 `HTMLVideoElement.prototype.canPlayType`:只有 `supported === false` 才返回 `''`,其余全部交给原生实现。
这样 Jellyfin Web 自己那套 `maxHevcLevel` 逻辑就会得出**准确**档案:
| 设备 | 结果 |
|---|---|
| 桌面(声称支持但实际解不动 8K Main 10) | 降到 level 153 → 8K 文件超出声明 → **服务器转码** |
| Quest 3(真能解 8K Main 10) | 保持 ≥183 → **继续 Direct Play** |
**故意保守**:只有 `supported === false` 才降级。`supported:true, smooth:false` 会记录但不影响行为 —— 太贴边了,而且「声称能播结果没播出来」已经有 §1.2 的看门狗兜底。
出问题的逃生开关(某台设备报得离谱时用):
```js
localStorage['jfvr-cpt'] = 'off'; // 然后刷新,覆盖完全不安装
```
当前状态可以在诊断面板里看到(`canPlayType hook` 和 `HEVC real (decodingInfo)` 两段)。这也是 Meta 官方文档推荐的做法 —— 他们明确说「用 Media Capabilities API 探测,不要靠 UA 嗅探」。
### 1.4 「VR 播放」按钮可以拖了
原来钉死在右下角(`right:16px; bottom:120px`),窗口矮的时候正好压在播放看门狗弹窗的码率按钮上,没地方躲。
现在:
- 用 `left/top` 定位(不再用 `right/bottom`),用 pointer 事件拖动,位置记在 `localStorage['jfvr-btn-pos']`
- `touch-action:none` —— 不加这个,触屏上拖动会变成滚动页面
- **拖动结束仍然会触发一次 click**,代码会把那一次吃掉,所以拖完不会意外弹出面板
- 限制在视窗内,窗口缩放时会重新夹紧
- **双击回到默认右下角**(拖到尴尬位置时的逃生口)
- 设置面板跟着按钮走(不再是钉在视窗角落),优先放在按钮上方,上方放不下就放下方,再放不下就夹在屏幕内
--- ---
## 2. Quest 3 实测数据(已用 ADB + CDP 在真机验证) ## 2. Quest 3 实测数据(已用 ADB + CDP 在真机验证)
@@ -114,10 +163,14 @@ UA Mozilla/5.0 (X11; Linux x86_64; Quest 3) ... Chrome/152 ... VR Safari/537.36
| `XRWebGLBinding` | — | true ← 回退路径可用 | | `XRWebGLBinding` | — | true ← 回退路径可用 |
| `MAX_TEXTURE_SIZE` | 8192 | 8192 | | `MAX_TEXTURE_SIZE` | 8192 | 8192 |
| `MAX_RENDERBUFFER_SIZE` | 16384 | 16384 | | `MAX_RENDERBUFFER_SIZE` | 16384 | 16384 |
| 8K HEVC `decodingInfo` | supported / powerEfficient | **supported:true, powerEfficient:true** | | 8K HEVC `decodingInfo` | supported / powerEfficient | **supported:true, powerEfficient:true**(仅 8-bit Main) |
结论:**HTTPS 下 Quest 浏览器提供全部所需 WebXR 能力,8K HEVC 走硬件解码。** 结论:**HTTPS 下 Quest 浏览器提供全部所需 WebXR 能力,8K HEVC 走硬件解码。**
> ⚠️ 上面那行 `decodingInfo` 当年只测了 **8-bit Main** 的 codec string(`hev1.1.6.L183.B0`),
> **10-bit Main 10(`hev1.2.4.L183.B0`)从来没测过**。插件现在会分档探测(见 §1.3),
> 诊断面板里会列出 Main/Main10 × 4K/8K 的真实结果。
### 2.1 网络实测:HTTPS 域名在 Quest 上就是内网直连 ### 2.1 网络实测:HTTPS 域名在 Quest 上就是内网直连
``` ```
+320 -9
View File
@@ -315,9 +315,81 @@
hasGetJointPose: typeof window.XRFrame !== 'undefined' && typeof XRFrame.prototype.getJointPose === 'function', hasGetJointPose: typeof window.XRFrame !== 'undefined' && typeof XRFrame.prototype.getJointPose === 'function',
maxTextureSize: null, maxTextureSize: null,
hevc: {}, hevc: {},
decoding8k: null decoding8k: null,
/* MediaCapabilities verdicts, keyed '<profile_idc>:<level>'. See below. */
codec: {},
codecBlocked: [],
cptPatched: false,
cptMode: null
}; };
/* ------------------------------------------------------------------ *
* codec capability: what this browser will ACTUALLY decode
* ------------------------------------------------------------------
* Two layers.
*
* 1. NS.caps.hevc -- raw canPlayType() answers, for the diagnostics panel.
* This used to only ask about Main profile (8-bit), which is why the
* project's notes said "8K HEVC: supported" right up until a Main 10
* (10-bit) file showed up and could not be decoded at all. The Main 10
* strings are the ones that actually matter for 8K VR here.
*
* 2. NS.caps.codec + the canPlayType override -- makes Jellyfin Web build
* an ACCURATE device profile.
*
* Why the override: Jellyfin Web derives its entire HEVC claim from
* canPlayType (src/scripts/browserDeviceProfile.js):
*
* let maxHevcLevel = 120, hevcProfiles = 'main';
* ...
* if (canPlayType('video/mp4; codecs="hvc1.2.4.L183"')) {
* maxHevcLevel = 183; // level 6.1 = 8K
* hevcProfiles = 'main|main 10';
* }
*
* canPlayType answers "does this system have an HEVC decoder", not "can it
* do 8192x4096 Main 10 at 60 fps". So a desktop browser that merely ships an
* HEVC decoder claims 8K Main 10, the server picks DirectPlay, and playback
* dies on a black screen with no player UI (the OSD is only built after
* 'playbackstart'). decodingInfo asks the actual decoder, so feeding its
* verdict back through canPlayType lets Jellyfin's own logic land on the
* right profile: the desktop drops to whatever it can really do and the
* server transcodes, while a Quest that genuinely decodes 8K Main 10 keeps
* DirectPlay. Meta's browser-video docs recommend exactly this API over UA
* sniffing.
*
* Only `supported === false` downgrades. `supported:true, smooth:false` is
* recorded but does not change behaviour: it is too close to the edge to act
* on, and 40-watchdog.js already covers "it claimed to work and did not".
*
* Kill switch if a device reports nonsense:
* localStorage['jfvr-cpt'] = 'off' then reload
*/
// decodingInfo needs real dimensions; a level string does not carry them, so
// each level is probed at the resolution it exists for.
var CODEC_PROBES = [
{ key: '1:120', name: 'Main L4.0', w: 1920, h: 1080, fps: 30, codec: 'hvc1.1.L120' },
{ key: '1:123', name: 'Main L4.1', w: 1920, h: 1080, fps: 60, codec: 'hvc1.1.4.L123' },
{ key: '1:183', name: 'Main L6.1 (8K)', w: 8192, h: 4096, fps: 60, codec: 'hvc1.1.6.L183.B0' },
{ key: '2:123', name: 'Main10 L4.1', w: 1920, h: 1080, fps: 60, codec: 'hvc1.2.4.L123' },
{ key: '2:153', name: 'Main10 L5.1 (4K)', w: 3840, h: 2160, fps: 60, codec: 'hvc1.2.4.L153' },
{ key: '2:183', name: 'Main10 L6.1 (8K)', w: 8192, h: 4096, fps: 60, codec: 'hvc1.2.4.L183' },
{ key: '2:186', name: 'Main10 L6.2 (8K60)', w: 8192, h: 4096, fps: 60, codec: 'hvc1.2.4.L186' }
];
/**
* 'video/mp4; codecs="hvc1.2.4.L183.B0"' -> '2:183' (profile_idc : level).
* Both the hvc1 and hev1 spellings map to the same key: they differ in the
* sample entry, not in what has to be decoded.
*/
function hevcKey(type) {
var m = /(?:hvc1|hev1)\.([0-9]+)(?:\.[0-9]+)?\.l([0-9]+)/i.exec(String(type || ''));
return m ? m[1] + ':' + m[2] : null;
}
NS.caps.hevcKey = hevcKey;
(function probe() { (function probe() {
try { try {
var mb = window.XRMediaBinding; var mb = window.XRMediaBinding;
@@ -331,12 +403,17 @@
if (gl) NS.caps.maxTextureSize = gl.getParameter(gl.MAX_TEXTURE_SIZE); if (gl) NS.caps.maxTextureSize = gl.getParameter(gl.MAX_TEXTURE_SIZE);
} catch (e) {} } catch (e) {}
try { try {
['video/mp4; codecs="hev1.1.6.L183.B0"', var ve = document.createElement('video');
['video/mp4; codecs="hev1.1.6.L183.B0"', // Main 8-bit 8K (the files that work)
'video/mp4; codecs="hvc1.1.6.L183.B0"', 'video/mp4; codecs="hvc1.1.6.L183.B0"',
'video/mp4; codecs="hev1.2.4.L183.B0"', // Main 10 8K (the files that do not)
'video/mp4; codecs="hvc1.2.4.L183.B0"',
'video/mp4; codecs="hev1.2.4.L153.B0"', // Main 10 4K
'video/mp4; codecs="hvc1.2.4.L153.B0"',
'video/mp4; codecs="hev1"', 'video/mp4; codecs="hev1"',
'video/mp4; codecs="hvc1"'].forEach(function (cs) { 'video/mp4; codecs="hvc1"'].forEach(function (cs) {
NS.caps.hevc[cs] = (typeof MediaSource !== 'undefined' && MediaSource.isTypeSupported(cs)) || NS.caps.hevc[cs] = (typeof MediaSource !== 'undefined' && MediaSource.isTypeSupported(cs)) ||
document.createElement('video').canPlayType(cs) || 'no'; ve.canPlayType(cs) || 'no';
}); });
} catch (e) {} } catch (e) {}
if (navigator.xr && navigator.xr.isSessionSupported) { if (navigator.xr && navigator.xr.isSessionSupported) {
@@ -346,8 +423,85 @@
} }
})(); })();
/* ------------------------------------------------------------------ *
* MediaCapabilities probe + canPlayType override
* ------------------------------------------------------------------ */
function applyVerdicts() {
NS.caps.codecBlocked = CODEC_PROBES.filter(function (p) {
var v = NS.caps.codec[p.key];
return v && v.supported === false;
}).map(function (p) { return p.name; });
}
function installCanPlayTypeOverride() {
if (NS.caps.cptMode === 'off') return;
var proto = window.HTMLVideoElement && window.HTMLVideoElement.prototype;
if (!proto || typeof proto.canPlayType !== 'function') return;
var orig = proto.canPlayType;
proto.canPlayType = function (type) {
try {
var key = hevcKey(type);
var v = key && NS.caps.codec[key];
// Only a definite "no" is acted on. Anything else is the browser's call.
if (v && v.supported === false) return '';
} catch (e) { /* never break the native answer */ }
return orig.apply(this, arguments);
};
NS.caps.cptPatched = true;
NS.caps.cptMode = 'on';
}
(function probeCodecs() {
// Kill switch, and the escape hatch if this ever misbehaves on a device.
try {
if (localStorage.getItem('jfvr-cpt') === 'off') { NS.caps.cptMode = 'off'; return; }
} catch (e) {}
var mc = navigator.mediaCapabilities;
if (!mc || typeof mc.decodingInfo !== 'function') { NS.caps.cptMode = 'no-api'; return; }
// Install FIRST, synchronously, so the hook is in place before anything can
// read canPlayType. Until a verdict lands the hook just defers to native,
// which is the safe default.
installCanPlayTypeOverride();
var pending = CODEC_PROBES.length;
CODEC_PROBES.forEach(function (p) {
var cfg = {
type: 'file',
video: {
contentType: 'video/mp4; codecs="' + p.codec + '"',
width: p.w, height: p.h, bitrate: 20000000, framerate: p.fps
}
};
mc.decodingInfo(cfg).then(function (info) {
NS.caps.codec[p.key] = {
name: p.name, workload: p.w + 'x' + p.h + '@' + p.fps,
supported: info.supported, smooth: info.smooth, powerEfficient: info.powerEfficient
};
}).catch(function (e) {
NS.caps.codec[p.key] = { name: p.name, error: String(e && e.message || e) };
}).then(function () {
if (--pending === 0) {
applyVerdicts();
NS.log('codec probe done; blocked = ' + (NS.caps.codecBlocked.join(', ') || 'none'));
}
});
});
})();
NS.capsDiag = function () { NS.capsDiag = function () {
var c = NS.caps; var c = NS.caps;
var real = CODEC_PROBES.map(function (p) {
var v = c.codec[p.key];
if (!v) return ' ' + p.name.padEnd(20) + ' (pending)';
if (v.error) return ' ' + p.name.padEnd(20) + ' error: ' + v.error;
return ' ' + p.name.padEnd(20) + ' supported=' + v.supported +
' smooth=' + v.smooth + ' powerEfficient=' + v.powerEfficient +
' [' + v.workload + ']' + (v.supported === false ? ' <-- BLOCKED' : '');
}).join('\n');
return [ return [
'origin : ' + location.origin, 'origin : ' + location.origin,
'secureContext : ' + c.secureContext, 'secureContext : ' + c.secureContext,
@@ -357,7 +511,11 @@
'createQuadLayer : ' + c.hasQuadLayer, 'createQuadLayer : ' + c.hasQuadLayer,
'hand tracking API : ' + c.hasHandTracking + ' / jointSpace=' + c.hasXRJointSpace + ' / getJointPose=' + c.hasGetJointPose, 'hand tracking API : ' + c.hasHandTracking + ' / jointSpace=' + c.hasXRJointSpace + ' / getJointPose=' + c.hasGetJointPose,
'MAX_TEXTURE_SIZE : ' + c.maxTextureSize, 'MAX_TEXTURE_SIZE : ' + c.maxTextureSize,
'HEVC : ' + JSON.stringify(c.hevc) 'HEVC canPlayType : ' + JSON.stringify(c.hevc),
'canPlayType hook : ' + (c.cptMode || 'pending') +
(c.cptMode === 'on' ? ' (downgraded: ' + (c.codecBlocked.join(', ') || 'nothing yet') + ')' : ''),
'HEVC real (decodingInfo):',
real
].join('\n'); ].join('\n');
}; };
})(); })();
@@ -5061,16 +5219,23 @@
// Sits ABOVE Jellyfin's own OSD bar: at the viewport's bottom-right it // Sits ABOVE Jellyfin's own OSD bar: at the viewport's bottom-right it
// covered the player's fullscreen button (owner report). 120 px clears the // covered the player's fullscreen button (owner report). 120 px clears the
// OSD bottom bar; the settings panel stacks above it. // OSD bottom bar; the settings panel stacks above it.
'.jfvr-btn{position:fixed;right:16px;bottom:120px;z-index:2147483000;display:flex;align-items:center;gap:8px;', // left/top are set from JS (see placeButton) so the button can be dragged
// anywhere. touch-action:none is what makes a drag work on a touch screen
// instead of scrolling the page underneath.
'.jfvr-btn{position:fixed;z-index:2147483000;display:flex;align-items:center;gap:8px;',
'padding:10px 16px;border:0;border-radius:24px;background:linear-gradient(135deg,#4ea1ff,#7b5cff);color:#fff;', 'padding:10px 16px;border:0;border-radius:24px;background:linear-gradient(135deg,#4ea1ff,#7b5cff);color:#fff;',
'font-size:15px;font-weight:600;cursor:pointer;box-shadow:0 6px 22px rgba(0,0,0,.45);font-family:inherit}', 'font-size:15px;font-weight:600;cursor:grab;box-shadow:0 6px 22px rgba(0,0,0,.45);font-family:inherit;',
'touch-action:none;user-select:none;-webkit-user-select:none;-webkit-tap-highlight-color:transparent}',
'.jfvr-btn:active{transform:scale(.96)}', '.jfvr-btn:active{transform:scale(.96)}',
'.jfvr-btn.jfvr-drag{cursor:grabbing;transform:none;box-shadow:0 10px 32px rgba(0,0,0,.65)}',
// the panel must always fit the viewport AND keep the CTA reachable, so the // the panel must always fit the viewport AND keep the CTA reachable, so the
// body scrolls and the button lives in a sticky footer // body scrolls and the button lives in a sticky footer
'.jfvr-panel{position:fixed;right:16px;bottom:180px;z-index:2147483001;width:290px;background:rgba(20,20,24,.96);', // Positioned from JS (positionPanel) so it follows the button once the
// button has been dragged; it no longer lives in the viewport corner.
'.jfvr-panel{position:fixed;z-index:2147483001;width:290px;background:rgba(20,20,24,.96);',
'color:#eaeaea;border:1px solid rgba(255,255,255,.14);border-radius:14px;box-shadow:0 12px 40px rgba(0,0,0,.6);', 'color:#eaeaea;border:1px solid rgba(255,255,255,.14);border-radius:14px;box-shadow:0 12px 40px rgba(0,0,0,.6);',
'font-family:inherit;font-size:14px;backdrop-filter:blur(10px);display:flex;flex-direction:column;', 'font-family:inherit;font-size:14px;backdrop-filter:blur(10px);display:flex;flex-direction:column;',
'max-height:calc(100vh - 200px);overflow:hidden}', 'max-height:calc(100vh - 32px);overflow:hidden}',
'.jfvr-head{display:flex;justify-content:space-between;align-items:center;padding:10px 12px;background:rgba(255,255,255,.06);font-weight:600;flex:0 0 auto}', '.jfvr-head{display:flex;justify-content:space-between;align-items:center;padding:10px 12px;background:rgba(255,255,255,.06);font-weight:600;flex:0 0 auto}',
'.jfvr-x{background:none;border:0;color:#aaa;font-size:20px;line-height:1;cursor:pointer;padding:0 4px}', '.jfvr-x{background:none;border:0;color:#aaa;font-size:20px;line-height:1;cursor:pointer;padding:0 4px}',
'.jfvr-body{padding:12px;overflow-y:auto;flex:1 1 auto;min-height:0}', '.jfvr-body{padding:12px;overflow-y:auto;flex:1 1 auto;min-height:0}',
@@ -5118,9 +5283,151 @@
var b = NS.makeEl('button', 'jfvr-btn'); var b = NS.makeEl('button', 'jfvr-btn');
b.type = 'button'; b.type = 'button';
b.innerHTML = '<span>&#127909;</span><span>VR 播放</span>'; b.innerHTML = '<span>&#127909;</span><span>VR 播放</span>';
b.addEventListener('click', function (ev) { ev.stopPropagation(); togglePanel(); }); b.title = '点击打开设置;按住拖动可以换位置;双击回到默认位置';
b.addEventListener('click', function (ev) {
ev.stopPropagation();
// A drag still produces a click on most browsers. Swallow that one so
// dragging the button never opens the panel by accident.
if (dragMoved) { dragMoved = false; return; }
togglePanel();
});
// Escape hatch: a button dragged half off a small window is annoying to
// recover by hand.
b.addEventListener('dblclick', function (ev) {
ev.stopPropagation();
resetButtonPos();
});
installDrag(b);
document.body.appendChild(b); document.body.appendChild(b);
btn = b; btn = b;
btnPos = readBtnPos();
placeButton(b, btnPos);
}
/* ------------------------------------------------------------------ *
* button placement / dragging
* ------------------------------------------------------------------
* The button used to be pinned to the bottom-right corner. On a short window
* that put it right on top of the bitrate choices the playback watchdog
* shows (that panel is centred), and there was no way to move it. It is
* draggable now and the spot is remembered per browser.
*
* The settings panel follows the button rather than the viewport corner, so
* the two cannot drift apart.
* ------------------------------------------------------------------ */
var BTN_POS_KEY = 'jfvr-btn-pos';
var BTN_MARGIN = 8;
var DRAG_SLOP = 4; // px of travel before it counts as a drag, not a tap
var btnPos = null; // {left, top} once placed; persisted on drop
var dragging = false;
var dragMoved = false;
var dragStart = null;
function readBtnPos() {
try {
var o = JSON.parse(localStorage.getItem(BTN_POS_KEY) || 'null');
if (o && typeof o.left === 'number' && typeof o.top === 'number') return o;
} catch (e) {}
return null;
}
function writeBtnPos(pos) {
try { localStorage.setItem(BTN_POS_KEY, JSON.stringify(pos)); } catch (e) {}
}
function clampPos(left, top, w, h) {
var maxLeft = Math.max(BTN_MARGIN, window.innerWidth - w - BTN_MARGIN);
var maxTop = Math.max(BTN_MARGIN, window.innerHeight - h - BTN_MARGIN);
return {
left: Math.round(Math.min(Math.max(left, BTN_MARGIN), maxLeft)),
top: Math.round(Math.min(Math.max(top, BTN_MARGIN), maxTop))
};
}
/** The default spot: the old fixed corner, expressed in left/top. */
function defaultPos(b) {
return { left: window.innerWidth - b.offsetWidth - 16,
top: window.innerHeight - b.offsetHeight - 120 };
}
function placeButton(b, pos) {
var p = pos || defaultPos(b);
var c = clampPos(p.left, p.top, b.offsetWidth, b.offsetHeight);
b.style.left = c.left + 'px';
b.style.top = c.top + 'px';
b.style.right = 'auto';
b.style.bottom = 'auto';
return c;
}
function resetButtonPos() {
if (!btn) return;
try { localStorage.removeItem(BTN_POS_KEY); } catch (e) {}
btnPos = placeButton(btn, null);
positionPanel();
}
function installDrag(b) {
b.addEventListener('pointerdown', function (ev) {
if (ev.button != null && ev.button !== 0) return; // primary button / touch only
var r = b.getBoundingClientRect();
dragging = true;
dragMoved = false;
dragStart = { x: ev.clientX, y: ev.clientY, left: r.left, top: r.top };
b.classList.add('jfvr-drag');
try { b.setPointerCapture(ev.pointerId); } catch (e) {}
});
b.addEventListener('pointermove', function (ev) {
if (!dragging || !dragStart) return;
var dx = ev.clientX - dragStart.x;
var dy = ev.clientY - dragStart.y;
if (!dragMoved) {
if (Math.abs(dx) < DRAG_SLOP && Math.abs(dy) < DRAG_SLOP) return;
dragMoved = true;
if (panel) hidePanel(); // do not drag the panel around with it
}
btnPos = clampPos(dragStart.left + dx, dragStart.top + dy, b.offsetWidth, b.offsetHeight);
b.style.left = btnPos.left + 'px';
b.style.top = btnPos.top + 'px';
});
function endDrag(ev) {
if (!dragging) return;
dragging = false;
dragStart = null;
b.classList.remove('jfvr-drag');
try { b.releasePointerCapture(ev.pointerId); } catch (e) {}
if (dragMoved) writeBtnPos(btnPos);
}
b.addEventListener('pointerup', endDrag);
b.addEventListener('pointercancel', endDrag);
}
/** Put the panel next to the button: above it, or below when there is no room. */
function positionPanel() {
if (!panel || !btn) return;
var b = btn.getBoundingClientRect();
var w = panel.offsetWidth;
var h = panel.offsetHeight;
var gap = 8;
var left = b.right - w; // right edges aligned
var top = b.top - h - gap;
if (top < BTN_MARGIN) top = b.bottom + gap; // no room above -> below
var maxLeft = Math.max(BTN_MARGIN, window.innerWidth - w - BTN_MARGIN);
var maxTop = Math.max(BTN_MARGIN, window.innerHeight - h - BTN_MARGIN);
panel.style.left = Math.round(Math.min(Math.max(left, BTN_MARGIN), maxLeft)) + 'px';
panel.style.top = Math.round(Math.min(Math.max(top, BTN_MARGIN), maxTop)) + 'px';
panel.style.right = 'auto';
panel.style.bottom = 'auto';
}
function onViewportResize() {
if (btn && document.body.contains(btn)) btnPos = placeButton(btn, btnPos);
positionPanel();
} }
function removeButton() { function removeButton() {
@@ -5304,6 +5611,7 @@
panel.appendChild(foot); panel.appendChild(foot);
document.body.appendChild(panel); document.body.appendChild(panel);
positionPanel();
panelSync = function () { panelSync = function () {
for (var i = 0; i < panelSyncs.length; i++) { for (var i = 0; i < panelSyncs.length; i++) {
@@ -6715,6 +7023,9 @@
window.addEventListener('beforeunload', function () { window.addEventListener('beforeunload', function () {
if (S.session) { try { S.session.end(); } catch (e) {} } if (S.session) { try { S.session.end(); } catch (e) {} }
}); });
// Keep the draggable button (and the panel that follows it) on screen when
// the window changes size.
window.addEventListener('resize', onViewportResize);
installFrameTracker(); installFrameTracker();
window.__JFVR_STATE__ = S; window.__JFVR_STATE__ = S;
+16
View File
@@ -7,6 +7,22 @@
"owner": "cat-shark", "owner": "cat-shark",
"category": "General", "category": "General",
"versions": [ "versions": [
{
"version": "0.4.0.0",
"targetAbi": "12.0.0.0",
"changelog": "Bundle version: `ae28bd`\n\nFirst plugin build. The web bundle is embedded in the DLL and served from /JFVR/jfvr.js; index.html is rewritten at request time, so nothing is written to the jellyfin-web folder on disk.",
"sourceUrl": "https://git.cat-shark.xyz/cat-shark/jellyfin_vr_web_plugin/releases/download/v0.4.0.0/Jellyfin.Plugin.JFVR_12.0.0.0.zip",
"checksum": "30A0E388FFD6A3D88C73DAB5928C6388",
"timestamp": "2026-10-17T17:20:34"
},
{
"version": "0.3.0.0",
"targetAbi": "12.0.0.0",
"changelog": "Bundle version: `4e9a8f`\n\nFirst plugin build. The web bundle is embedded in the DLL and served from /JFVR/jfvr.js; index.html is rewritten at request time, so nothing is written to the jellyfin-web folder on disk.",
"sourceUrl": "https://git.cat-shark.xyz/cat-shark/jellyfin_vr_web_plugin/releases/download/v0.3.0.0/Jellyfin.Plugin.JFVR_12.0.0.0.zip",
"checksum": "1BFAF246451C090E351F9DDD516BD4DC",
"timestamp": "2026-10-17T17:08:08"
},
{ {
"version": "0.2.0.0", "version": "0.2.0.0",
"targetAbi": "12.0.0.0", "targetAbi": "12.0.0.0",
+1 -1
View File
@@ -7,7 +7,7 @@
# (InstallationManager.GetAvailablePackages), so one package covers all of 12.x. # (InstallationManager.GetAvailablePackages), so one package covers all of 12.x.
name: "Jellyfin Web VR" name: "Jellyfin Web VR"
guid: "7d33ef59-f9b0-412b-93bd-5cd5353018de" guid: "7d33ef59-f9b0-412b-93bd-5cd5353018de"
version: "0.2.0.0" version: "0.4.0.0"
targetAbi: "12.0.0.0" targetAbi: "12.0.0.0"
framework: "net10.0" framework: "net10.0"
overview: "VR180/VR360 playback inside Jellyfin Web for Meta Quest 3." overview: "VR180/VR360 playback inside Jellyfin Web for Meta Quest 3."
+162 -4
View File
@@ -307,9 +307,81 @@
hasGetJointPose: typeof window.XRFrame !== 'undefined' && typeof XRFrame.prototype.getJointPose === 'function', hasGetJointPose: typeof window.XRFrame !== 'undefined' && typeof XRFrame.prototype.getJointPose === 'function',
maxTextureSize: null, maxTextureSize: null,
hevc: {}, hevc: {},
decoding8k: null decoding8k: null,
/* MediaCapabilities verdicts, keyed '<profile_idc>:<level>'. See below. */
codec: {},
codecBlocked: [],
cptPatched: false,
cptMode: null
}; };
/* ------------------------------------------------------------------ *
* codec capability: what this browser will ACTUALLY decode
* ------------------------------------------------------------------
* Two layers.
*
* 1. NS.caps.hevc -- raw canPlayType() answers, for the diagnostics panel.
* This used to only ask about Main profile (8-bit), which is why the
* project's notes said "8K HEVC: supported" right up until a Main 10
* (10-bit) file showed up and could not be decoded at all. The Main 10
* strings are the ones that actually matter for 8K VR here.
*
* 2. NS.caps.codec + the canPlayType override -- makes Jellyfin Web build
* an ACCURATE device profile.
*
* Why the override: Jellyfin Web derives its entire HEVC claim from
* canPlayType (src/scripts/browserDeviceProfile.js):
*
* let maxHevcLevel = 120, hevcProfiles = 'main';
* ...
* if (canPlayType('video/mp4; codecs="hvc1.2.4.L183"')) {
* maxHevcLevel = 183; // level 6.1 = 8K
* hevcProfiles = 'main|main 10';
* }
*
* canPlayType answers "does this system have an HEVC decoder", not "can it
* do 8192x4096 Main 10 at 60 fps". So a desktop browser that merely ships an
* HEVC decoder claims 8K Main 10, the server picks DirectPlay, and playback
* dies on a black screen with no player UI (the OSD is only built after
* 'playbackstart'). decodingInfo asks the actual decoder, so feeding its
* verdict back through canPlayType lets Jellyfin's own logic land on the
* right profile: the desktop drops to whatever it can really do and the
* server transcodes, while a Quest that genuinely decodes 8K Main 10 keeps
* DirectPlay. Meta's browser-video docs recommend exactly this API over UA
* sniffing.
*
* Only `supported === false` downgrades. `supported:true, smooth:false` is
* recorded but does not change behaviour: it is too close to the edge to act
* on, and 40-watchdog.js already covers "it claimed to work and did not".
*
* Kill switch if a device reports nonsense:
* localStorage['jfvr-cpt'] = 'off' then reload
*/
// decodingInfo needs real dimensions; a level string does not carry them, so
// each level is probed at the resolution it exists for.
var CODEC_PROBES = [
{ key: '1:120', name: 'Main L4.0', w: 1920, h: 1080, fps: 30, codec: 'hvc1.1.L120' },
{ key: '1:123', name: 'Main L4.1', w: 1920, h: 1080, fps: 60, codec: 'hvc1.1.4.L123' },
{ key: '1:183', name: 'Main L6.1 (8K)', w: 8192, h: 4096, fps: 60, codec: 'hvc1.1.6.L183.B0' },
{ key: '2:123', name: 'Main10 L4.1', w: 1920, h: 1080, fps: 60, codec: 'hvc1.2.4.L123' },
{ key: '2:153', name: 'Main10 L5.1 (4K)', w: 3840, h: 2160, fps: 60, codec: 'hvc1.2.4.L153' },
{ key: '2:183', name: 'Main10 L6.1 (8K)', w: 8192, h: 4096, fps: 60, codec: 'hvc1.2.4.L183' },
{ key: '2:186', name: 'Main10 L6.2 (8K60)', w: 8192, h: 4096, fps: 60, codec: 'hvc1.2.4.L186' }
];
/**
* 'video/mp4; codecs="hvc1.2.4.L183.B0"' -> '2:183' (profile_idc : level).
* Both the hvc1 and hev1 spellings map to the same key: they differ in the
* sample entry, not in what has to be decoded.
*/
function hevcKey(type) {
var m = /(?:hvc1|hev1)\.([0-9]+)(?:\.[0-9]+)?\.l([0-9]+)/i.exec(String(type || ''));
return m ? m[1] + ':' + m[2] : null;
}
NS.caps.hevcKey = hevcKey;
(function probe() { (function probe() {
try { try {
var mb = window.XRMediaBinding; var mb = window.XRMediaBinding;
@@ -323,12 +395,17 @@
if (gl) NS.caps.maxTextureSize = gl.getParameter(gl.MAX_TEXTURE_SIZE); if (gl) NS.caps.maxTextureSize = gl.getParameter(gl.MAX_TEXTURE_SIZE);
} catch (e) {} } catch (e) {}
try { try {
['video/mp4; codecs="hev1.1.6.L183.B0"', var ve = document.createElement('video');
['video/mp4; codecs="hev1.1.6.L183.B0"', // Main 8-bit 8K (the files that work)
'video/mp4; codecs="hvc1.1.6.L183.B0"', 'video/mp4; codecs="hvc1.1.6.L183.B0"',
'video/mp4; codecs="hev1.2.4.L183.B0"', // Main 10 8K (the files that do not)
'video/mp4; codecs="hvc1.2.4.L183.B0"',
'video/mp4; codecs="hev1.2.4.L153.B0"', // Main 10 4K
'video/mp4; codecs="hvc1.2.4.L153.B0"',
'video/mp4; codecs="hev1"', 'video/mp4; codecs="hev1"',
'video/mp4; codecs="hvc1"'].forEach(function (cs) { 'video/mp4; codecs="hvc1"'].forEach(function (cs) {
NS.caps.hevc[cs] = (typeof MediaSource !== 'undefined' && MediaSource.isTypeSupported(cs)) || NS.caps.hevc[cs] = (typeof MediaSource !== 'undefined' && MediaSource.isTypeSupported(cs)) ||
document.createElement('video').canPlayType(cs) || 'no'; ve.canPlayType(cs) || 'no';
}); });
} catch (e) {} } catch (e) {}
if (navigator.xr && navigator.xr.isSessionSupported) { if (navigator.xr && navigator.xr.isSessionSupported) {
@@ -338,8 +415,85 @@
} }
})(); })();
/* ------------------------------------------------------------------ *
* MediaCapabilities probe + canPlayType override
* ------------------------------------------------------------------ */
function applyVerdicts() {
NS.caps.codecBlocked = CODEC_PROBES.filter(function (p) {
var v = NS.caps.codec[p.key];
return v && v.supported === false;
}).map(function (p) { return p.name; });
}
function installCanPlayTypeOverride() {
if (NS.caps.cptMode === 'off') return;
var proto = window.HTMLVideoElement && window.HTMLVideoElement.prototype;
if (!proto || typeof proto.canPlayType !== 'function') return;
var orig = proto.canPlayType;
proto.canPlayType = function (type) {
try {
var key = hevcKey(type);
var v = key && NS.caps.codec[key];
// Only a definite "no" is acted on. Anything else is the browser's call.
if (v && v.supported === false) return '';
} catch (e) { /* never break the native answer */ }
return orig.apply(this, arguments);
};
NS.caps.cptPatched = true;
NS.caps.cptMode = 'on';
}
(function probeCodecs() {
// Kill switch, and the escape hatch if this ever misbehaves on a device.
try {
if (localStorage.getItem('jfvr-cpt') === 'off') { NS.caps.cptMode = 'off'; return; }
} catch (e) {}
var mc = navigator.mediaCapabilities;
if (!mc || typeof mc.decodingInfo !== 'function') { NS.caps.cptMode = 'no-api'; return; }
// Install FIRST, synchronously, so the hook is in place before anything can
// read canPlayType. Until a verdict lands the hook just defers to native,
// which is the safe default.
installCanPlayTypeOverride();
var pending = CODEC_PROBES.length;
CODEC_PROBES.forEach(function (p) {
var cfg = {
type: 'file',
video: {
contentType: 'video/mp4; codecs="' + p.codec + '"',
width: p.w, height: p.h, bitrate: 20000000, framerate: p.fps
}
};
mc.decodingInfo(cfg).then(function (info) {
NS.caps.codec[p.key] = {
name: p.name, workload: p.w + 'x' + p.h + '@' + p.fps,
supported: info.supported, smooth: info.smooth, powerEfficient: info.powerEfficient
};
}).catch(function (e) {
NS.caps.codec[p.key] = { name: p.name, error: String(e && e.message || e) };
}).then(function () {
if (--pending === 0) {
applyVerdicts();
NS.log('codec probe done; blocked = ' + (NS.caps.codecBlocked.join(', ') || 'none'));
}
});
});
})();
NS.capsDiag = function () { NS.capsDiag = function () {
var c = NS.caps; var c = NS.caps;
var real = CODEC_PROBES.map(function (p) {
var v = c.codec[p.key];
if (!v) return ' ' + p.name.padEnd(20) + ' (pending)';
if (v.error) return ' ' + p.name.padEnd(20) + ' error: ' + v.error;
return ' ' + p.name.padEnd(20) + ' supported=' + v.supported +
' smooth=' + v.smooth + ' powerEfficient=' + v.powerEfficient +
' [' + v.workload + ']' + (v.supported === false ? ' <-- BLOCKED' : '');
}).join('\n');
return [ return [
'origin : ' + location.origin, 'origin : ' + location.origin,
'secureContext : ' + c.secureContext, 'secureContext : ' + c.secureContext,
@@ -349,7 +503,11 @@
'createQuadLayer : ' + c.hasQuadLayer, 'createQuadLayer : ' + c.hasQuadLayer,
'hand tracking API : ' + c.hasHandTracking + ' / jointSpace=' + c.hasXRJointSpace + ' / getJointPose=' + c.hasGetJointPose, 'hand tracking API : ' + c.hasHandTracking + ' / jointSpace=' + c.hasXRJointSpace + ' / getJointPose=' + c.hasGetJointPose,
'MAX_TEXTURE_SIZE : ' + c.maxTextureSize, 'MAX_TEXTURE_SIZE : ' + c.maxTextureSize,
'HEVC : ' + JSON.stringify(c.hevc) 'HEVC canPlayType : ' + JSON.stringify(c.hevc),
'canPlayType hook : ' + (c.cptMode || 'pending') +
(c.cptMode === 'on' ? ' (downgraded: ' + (c.codecBlocked.join(', ') || 'nothing yet') + ')' : ''),
'HEVC real (decodingInfo):',
real
].join('\n'); ].join('\n');
}; };
})(); })();
+158 -5
View File
@@ -299,16 +299,23 @@
// Sits ABOVE Jellyfin's own OSD bar: at the viewport's bottom-right it // Sits ABOVE Jellyfin's own OSD bar: at the viewport's bottom-right it
// covered the player's fullscreen button (owner report). 120 px clears the // covered the player's fullscreen button (owner report). 120 px clears the
// OSD bottom bar; the settings panel stacks above it. // OSD bottom bar; the settings panel stacks above it.
'.jfvr-btn{position:fixed;right:16px;bottom:120px;z-index:2147483000;display:flex;align-items:center;gap:8px;', // left/top are set from JS (see placeButton) so the button can be dragged
// anywhere. touch-action:none is what makes a drag work on a touch screen
// instead of scrolling the page underneath.
'.jfvr-btn{position:fixed;z-index:2147483000;display:flex;align-items:center;gap:8px;',
'padding:10px 16px;border:0;border-radius:24px;background:linear-gradient(135deg,#4ea1ff,#7b5cff);color:#fff;', 'padding:10px 16px;border:0;border-radius:24px;background:linear-gradient(135deg,#4ea1ff,#7b5cff);color:#fff;',
'font-size:15px;font-weight:600;cursor:pointer;box-shadow:0 6px 22px rgba(0,0,0,.45);font-family:inherit}', 'font-size:15px;font-weight:600;cursor:grab;box-shadow:0 6px 22px rgba(0,0,0,.45);font-family:inherit;',
'touch-action:none;user-select:none;-webkit-user-select:none;-webkit-tap-highlight-color:transparent}',
'.jfvr-btn:active{transform:scale(.96)}', '.jfvr-btn:active{transform:scale(.96)}',
'.jfvr-btn.jfvr-drag{cursor:grabbing;transform:none;box-shadow:0 10px 32px rgba(0,0,0,.65)}',
// the panel must always fit the viewport AND keep the CTA reachable, so the // the panel must always fit the viewport AND keep the CTA reachable, so the
// body scrolls and the button lives in a sticky footer // body scrolls and the button lives in a sticky footer
'.jfvr-panel{position:fixed;right:16px;bottom:180px;z-index:2147483001;width:290px;background:rgba(20,20,24,.96);', // Positioned from JS (positionPanel) so it follows the button once the
// button has been dragged; it no longer lives in the viewport corner.
'.jfvr-panel{position:fixed;z-index:2147483001;width:290px;background:rgba(20,20,24,.96);',
'color:#eaeaea;border:1px solid rgba(255,255,255,.14);border-radius:14px;box-shadow:0 12px 40px rgba(0,0,0,.6);', 'color:#eaeaea;border:1px solid rgba(255,255,255,.14);border-radius:14px;box-shadow:0 12px 40px rgba(0,0,0,.6);',
'font-family:inherit;font-size:14px;backdrop-filter:blur(10px);display:flex;flex-direction:column;', 'font-family:inherit;font-size:14px;backdrop-filter:blur(10px);display:flex;flex-direction:column;',
'max-height:calc(100vh - 200px);overflow:hidden}', 'max-height:calc(100vh - 32px);overflow:hidden}',
'.jfvr-head{display:flex;justify-content:space-between;align-items:center;padding:10px 12px;background:rgba(255,255,255,.06);font-weight:600;flex:0 0 auto}', '.jfvr-head{display:flex;justify-content:space-between;align-items:center;padding:10px 12px;background:rgba(255,255,255,.06);font-weight:600;flex:0 0 auto}',
'.jfvr-x{background:none;border:0;color:#aaa;font-size:20px;line-height:1;cursor:pointer;padding:0 4px}', '.jfvr-x{background:none;border:0;color:#aaa;font-size:20px;line-height:1;cursor:pointer;padding:0 4px}',
'.jfvr-body{padding:12px;overflow-y:auto;flex:1 1 auto;min-height:0}', '.jfvr-body{padding:12px;overflow-y:auto;flex:1 1 auto;min-height:0}',
@@ -356,9 +363,151 @@
var b = NS.makeEl('button', 'jfvr-btn'); var b = NS.makeEl('button', 'jfvr-btn');
b.type = 'button'; b.type = 'button';
b.innerHTML = '<span>&#127909;</span><span>VR 播放</span>'; b.innerHTML = '<span>&#127909;</span><span>VR 播放</span>';
b.addEventListener('click', function (ev) { ev.stopPropagation(); togglePanel(); }); b.title = '点击打开设置;按住拖动可以换位置;双击回到默认位置';
b.addEventListener('click', function (ev) {
ev.stopPropagation();
// A drag still produces a click on most browsers. Swallow that one so
// dragging the button never opens the panel by accident.
if (dragMoved) { dragMoved = false; return; }
togglePanel();
});
// Escape hatch: a button dragged half off a small window is annoying to
// recover by hand.
b.addEventListener('dblclick', function (ev) {
ev.stopPropagation();
resetButtonPos();
});
installDrag(b);
document.body.appendChild(b); document.body.appendChild(b);
btn = b; btn = b;
btnPos = readBtnPos();
placeButton(b, btnPos);
}
/* ------------------------------------------------------------------ *
* button placement / dragging
* ------------------------------------------------------------------
* The button used to be pinned to the bottom-right corner. On a short window
* that put it right on top of the bitrate choices the playback watchdog
* shows (that panel is centred), and there was no way to move it. It is
* draggable now and the spot is remembered per browser.
*
* The settings panel follows the button rather than the viewport corner, so
* the two cannot drift apart.
* ------------------------------------------------------------------ */
var BTN_POS_KEY = 'jfvr-btn-pos';
var BTN_MARGIN = 8;
var DRAG_SLOP = 4; // px of travel before it counts as a drag, not a tap
var btnPos = null; // {left, top} once placed; persisted on drop
var dragging = false;
var dragMoved = false;
var dragStart = null;
function readBtnPos() {
try {
var o = JSON.parse(localStorage.getItem(BTN_POS_KEY) || 'null');
if (o && typeof o.left === 'number' && typeof o.top === 'number') return o;
} catch (e) {}
return null;
}
function writeBtnPos(pos) {
try { localStorage.setItem(BTN_POS_KEY, JSON.stringify(pos)); } catch (e) {}
}
function clampPos(left, top, w, h) {
var maxLeft = Math.max(BTN_MARGIN, window.innerWidth - w - BTN_MARGIN);
var maxTop = Math.max(BTN_MARGIN, window.innerHeight - h - BTN_MARGIN);
return {
left: Math.round(Math.min(Math.max(left, BTN_MARGIN), maxLeft)),
top: Math.round(Math.min(Math.max(top, BTN_MARGIN), maxTop))
};
}
/** The default spot: the old fixed corner, expressed in left/top. */
function defaultPos(b) {
return { left: window.innerWidth - b.offsetWidth - 16,
top: window.innerHeight - b.offsetHeight - 120 };
}
function placeButton(b, pos) {
var p = pos || defaultPos(b);
var c = clampPos(p.left, p.top, b.offsetWidth, b.offsetHeight);
b.style.left = c.left + 'px';
b.style.top = c.top + 'px';
b.style.right = 'auto';
b.style.bottom = 'auto';
return c;
}
function resetButtonPos() {
if (!btn) return;
try { localStorage.removeItem(BTN_POS_KEY); } catch (e) {}
btnPos = placeButton(btn, null);
positionPanel();
}
function installDrag(b) {
b.addEventListener('pointerdown', function (ev) {
if (ev.button != null && ev.button !== 0) return; // primary button / touch only
var r = b.getBoundingClientRect();
dragging = true;
dragMoved = false;
dragStart = { x: ev.clientX, y: ev.clientY, left: r.left, top: r.top };
b.classList.add('jfvr-drag');
try { b.setPointerCapture(ev.pointerId); } catch (e) {}
});
b.addEventListener('pointermove', function (ev) {
if (!dragging || !dragStart) return;
var dx = ev.clientX - dragStart.x;
var dy = ev.clientY - dragStart.y;
if (!dragMoved) {
if (Math.abs(dx) < DRAG_SLOP && Math.abs(dy) < DRAG_SLOP) return;
dragMoved = true;
if (panel) hidePanel(); // do not drag the panel around with it
}
btnPos = clampPos(dragStart.left + dx, dragStart.top + dy, b.offsetWidth, b.offsetHeight);
b.style.left = btnPos.left + 'px';
b.style.top = btnPos.top + 'px';
});
function endDrag(ev) {
if (!dragging) return;
dragging = false;
dragStart = null;
b.classList.remove('jfvr-drag');
try { b.releasePointerCapture(ev.pointerId); } catch (e) {}
if (dragMoved) writeBtnPos(btnPos);
}
b.addEventListener('pointerup', endDrag);
b.addEventListener('pointercancel', endDrag);
}
/** Put the panel next to the button: above it, or below when there is no room. */
function positionPanel() {
if (!panel || !btn) return;
var b = btn.getBoundingClientRect();
var w = panel.offsetWidth;
var h = panel.offsetHeight;
var gap = 8;
var left = b.right - w; // right edges aligned
var top = b.top - h - gap;
if (top < BTN_MARGIN) top = b.bottom + gap; // no room above -> below
var maxLeft = Math.max(BTN_MARGIN, window.innerWidth - w - BTN_MARGIN);
var maxTop = Math.max(BTN_MARGIN, window.innerHeight - h - BTN_MARGIN);
panel.style.left = Math.round(Math.min(Math.max(left, BTN_MARGIN), maxLeft)) + 'px';
panel.style.top = Math.round(Math.min(Math.max(top, BTN_MARGIN), maxTop)) + 'px';
panel.style.right = 'auto';
panel.style.bottom = 'auto';
}
function onViewportResize() {
if (btn && document.body.contains(btn)) btnPos = placeButton(btn, btnPos);
positionPanel();
} }
function removeButton() { function removeButton() {
@@ -542,6 +691,7 @@
panel.appendChild(foot); panel.appendChild(foot);
document.body.appendChild(panel); document.body.appendChild(panel);
positionPanel();
panelSync = function () { panelSync = function () {
for (var i = 0; i < panelSyncs.length; i++) { for (var i = 0; i < panelSyncs.length; i++) {
@@ -1953,6 +2103,9 @@
window.addEventListener('beforeunload', function () { window.addEventListener('beforeunload', function () {
if (S.session) { try { S.session.end(); } catch (e) {} } if (S.session) { try { S.session.end(); } catch (e) {} }
}); });
// Keep the draggable button (and the panel that follows it) on screen when
// the window changes size.
window.addEventListener('resize', onViewportResize);
installFrameTracker(); installFrameTracker();
window.__JFVR_STATE__ = S; window.__JFVR_STATE__ = S;