caps: stop controlling transcoding; watchdog catches the silent stall
The canPlayType override is now OFF by default: Jellyfin builds its own device profile and the plugin no longer influences the direct-play / transcode decision (opt back in with localStorage['jfvr-cpt']='on'). The decodingInfo probe still runs for the diagnostics panel only. Keep the bitrate prompt, and make it actually reachable: the old "has picture" check (videoWidth > 0 && readyState >= 2) is already true for a decoder that parsed the header and then stalled, so a frozen 8K HEVC Main 10 playback stood the watchdog down forever. Track currentTime instead and prompt after STALL_MS (20s) when the playhead stops moving.
This commit is contained in:
Vendored
+73
-20
@@ -394,8 +394,11 @@
|
|||||||
* 10-bit will still claim 10-bit at that level and can black-screen on such a
|
* 10-bit will still claim 10-bit at that level and can black-screen on such a
|
||||||
* file. 40-watchdog.js covers exactly that, which is why it stays.
|
* file. 40-watchdog.js covers exactly that, which is why it stays.
|
||||||
*
|
*
|
||||||
* Escape hatches, if a device reports nonsense:
|
* THE HOOK IS OFF BY DEFAULT. The plugin no longer influences Jellyfin's
|
||||||
* localStorage['jfvr-cpt'] = 'off' disable the hook entirely
|
* direct-play / transcode decision at all -- Jellyfin uses its native device
|
||||||
|
* profile, and when playback cannot keep up the 40-watchdog.js prompt lets the
|
||||||
|
* user pick a bitrate. The override is kept only as an opt-in experiment:
|
||||||
|
* localStorage['jfvr-cpt'] = 'on' enable the canPlayType hook
|
||||||
* localStorage['jfvr-cpt-keep'] = '2:183' never downgrade these tiers
|
* localStorage['jfvr-cpt-keep'] = '2:183' never downgrade these tiers
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -571,10 +574,15 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
(function probeCodecs() {
|
(function probeCodecs() {
|
||||||
// Kill switch, and the escape hatch if this ever misbehaves on a device.
|
// Native behavior is the default: do NOT install the canPlayType override,
|
||||||
try {
|
// so Jellyfin builds its own device profile exactly as it would without this
|
||||||
if (localStorage.getItem('jfvr-cpt') === 'off') { NS.caps.cptMode = 'off'; return; }
|
// plugin. Opt back in with localStorage['jfvr-cpt'] = 'on' when diagnosing.
|
||||||
} catch (e) {}
|
// The decodingInfo probe still runs so the diagnostics panel can report what
|
||||||
|
// the device really supports -- it just no longer changes any decision.
|
||||||
|
var hookOn = false;
|
||||||
|
try { hookOn = localStorage.getItem('jfvr-cpt') === 'on'; } catch (e) {}
|
||||||
|
NS.caps.cptMode = hookOn ? null : 'off';
|
||||||
|
|
||||||
var mc = navigator.mediaCapabilities;
|
var mc = navigator.mediaCapabilities;
|
||||||
if (!mc || typeof mc.decodingInfo !== 'function') { NS.caps.cptMode = 'no-api'; return; }
|
if (!mc || typeof mc.decodingInfo !== 'function') { NS.caps.cptMode = 'no-api'; return; }
|
||||||
|
|
||||||
@@ -585,7 +593,7 @@
|
|||||||
// Install FIRST, synchronously, so the hook is in place before anything can
|
// Install FIRST, synchronously, so the hook is in place before anything can
|
||||||
// read canPlayType. Until a verdict lands the hook just defers to native,
|
// read canPlayType. Until a verdict lands the hook just defers to native,
|
||||||
// which is the safe default.
|
// which is the safe default.
|
||||||
installCanPlayTypeOverride();
|
if (hookOn) installCanPlayTypeOverride();
|
||||||
|
|
||||||
var pending = CODEC_PROBES.length;
|
var pending = CODEC_PROBES.length;
|
||||||
CODEC_PROBES.forEach(function (p) {
|
CODEC_PROBES.forEach(function (p) {
|
||||||
@@ -606,7 +614,8 @@
|
|||||||
}).then(function () {
|
}).then(function () {
|
||||||
if (--pending === 0) {
|
if (--pending === 0) {
|
||||||
applyVerdicts();
|
applyVerdicts();
|
||||||
NS.log('codec probe done; blocked = ' + (NS.caps.codecBlocked.join(', ') || 'none') +
|
NS.log('codec probe done (hook ' + NS.caps.cptMode + '); would block = ' +
|
||||||
|
(NS.caps.codecBlocked.join(', ') || 'none') +
|
||||||
(NS.caps.codecKept.length ? '; pinned = ' + NS.caps.codecKept.join(', ') : ''));
|
(NS.caps.codecKept.length ? '; pinned = ' + NS.caps.codecKept.join(', ') : ''));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -4745,6 +4754,15 @@
|
|||||||
var DEAD_MS = 15000;
|
var DEAD_MS = 15000;
|
||||||
var DEAD_TRANSCODE_MS = 45000;
|
var DEAD_TRANSCODE_MS = 45000;
|
||||||
|
|
||||||
|
// Metadata parsed but the playhead is not moving. This is the silent stall: a
|
||||||
|
// decoder that reads the header and then cannot keep up (8K HEVC Main 10 on a
|
||||||
|
// broken VAAPI driver is the motivating case). The old "has picture" check
|
||||||
|
// only looked at videoWidth/readyState, which are both already set here, so
|
||||||
|
// playback that never advances stood the watchdog down forever and the user
|
||||||
|
// got a frozen picture with no prompt. Give it a little longer than a clean
|
||||||
|
// start, since a heavy 8K stream legitimately buffers early.
|
||||||
|
var STALL_MS = 20000;
|
||||||
|
|
||||||
// After the user answers (either way) stay quiet, so a slow-but-working
|
// After the user answers (either way) stay quiet, so a slow-but-working
|
||||||
// playback does not get nagged at.
|
// playback does not get nagged at.
|
||||||
var QUIET_MS = 120000;
|
var QUIET_MS = 120000;
|
||||||
@@ -4765,7 +4783,9 @@
|
|||||||
lastReason: '',
|
lastReason: '',
|
||||||
applied: null,
|
applied: null,
|
||||||
codec: null, // filled in best-effort from the Jellyfin API
|
codec: null, // filled in best-effort from the Jellyfin API
|
||||||
panel: null
|
panel: null,
|
||||||
|
lastTime: -1, // playhead seen on the previous poll
|
||||||
|
progressAt: 0 // when the playhead last moved
|
||||||
};
|
};
|
||||||
NS.Watchdog = W;
|
NS.Watchdog = W;
|
||||||
|
|
||||||
@@ -4791,7 +4811,7 @@
|
|||||||
return src.indexOf('/hls') >= 0 || src.indexOf('.m3u8') >= 0;
|
return src.indexOf('/hls') >= 0 || src.indexOf('.m3u8') >= 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Metadata parsed AND a frame available. False means "no picture". */
|
/** Metadata parsed AND a frame available. False means "no picture at all". */
|
||||||
function hasPicture(v) {
|
function hasPicture(v) {
|
||||||
return v.videoWidth > 0 && v.readyState >= 2;
|
return v.videoWidth > 0 && v.readyState >= 2;
|
||||||
}
|
}
|
||||||
@@ -4933,17 +4953,25 @@
|
|||||||
|
|
||||||
var p = NS.makeEl('div', 'jfvr-wd');
|
var p = NS.makeEl('div', 'jfvr-wd');
|
||||||
p.id = 'jfvr-wd';
|
p.id = 'jfvr-wd';
|
||||||
p.appendChild(NS.makeEl('h3', null, '视频没能开始播放'));
|
p.appendChild(NS.makeEl('h3', null,
|
||||||
|
reason === 'stalled' ? '视频播放卡住了' : '视频没能开始播放'));
|
||||||
|
|
||||||
var body = NS.makeEl('div', 'jfvr-wd-body');
|
var body = NS.makeEl('div', 'jfvr-wd-body');
|
||||||
|
|
||||||
var msg = NS.makeEl('p');
|
var msg = NS.makeEl('p');
|
||||||
var waited = Math.round(timeoutMs(v) / 1000);
|
var waited = Math.round(timeoutMs(v) / 1000);
|
||||||
|
var intro;
|
||||||
|
if (reason === 'error') {
|
||||||
|
intro = '播放器报错了,一个画面都没解出来。';
|
||||||
|
} else if (reason === 'stalled') {
|
||||||
|
intro = '画面已经出来了,但播放进度停住不动了(<code>currentTime</code> 不再前进)—— ' +
|
||||||
|
'解码器跟不上这个文件。';
|
||||||
|
} else {
|
||||||
|
intro = '等了 ' + waited + ' 秒都没拿到任何画面(<code>videoWidth = 0</code>),' +
|
||||||
|
'所以播放器界面也没有被创建出来。';
|
||||||
|
}
|
||||||
msg.innerHTML =
|
msg.innerHTML =
|
||||||
(reason === 'error'
|
intro +
|
||||||
? '播放器报错了,一个画面都没解出来。'
|
|
||||||
: '等了 ' + waited + ' 秒都没拿到任何画面(<code>videoWidth = 0</code>),' +
|
|
||||||
'所以播放器界面也没有被创建出来。') +
|
|
||||||
'最常见的原因是<strong>这台设备解不动这个格式</strong>:' +
|
'最常见的原因是<strong>这台设备解不动这个格式</strong>:' +
|
||||||
'<span class="jfvr-wd-fmt">' + (W.codec || '该格式') + '</span>。<br>' +
|
'<span class="jfvr-wd-fmt">' + (W.codec || '该格式') + '</span>。<br>' +
|
||||||
'让服务器转码成 H.264 再播就能看到画面,代价是画质下降(这台 NAS 的转码上限约 4K)。';
|
'让服务器转码成 H.264 再播就能看到画面,代价是画质下降(这台 NAS 的转码上限约 4K)。';
|
||||||
@@ -4985,7 +5013,7 @@
|
|||||||
W.panel = p;
|
W.panel = p;
|
||||||
|
|
||||||
NS.recordError('watchdog', new Error('playback never started: ' + reason));
|
NS.recordError('watchdog', new Error('playback never started: ' + reason));
|
||||||
log('watchdog: playback never started, reason =', reason, 'codec =', W.codec);
|
log('watchdog: prompt shown, reason =', reason, 'codec =', W.codec);
|
||||||
}
|
}
|
||||||
|
|
||||||
function hide() {
|
function hide() {
|
||||||
@@ -4995,6 +5023,8 @@
|
|||||||
|
|
||||||
function reset() {
|
function reset() {
|
||||||
W.seenAt = 0;
|
W.seenAt = 0;
|
||||||
|
W.lastTime = -1;
|
||||||
|
W.progressAt = 0;
|
||||||
W.codec = null;
|
W.codec = null;
|
||||||
if (W.shown) hide();
|
if (W.shown) hide();
|
||||||
}
|
}
|
||||||
@@ -5015,9 +5045,6 @@
|
|||||||
var v = playerVideo();
|
var v = playerVideo();
|
||||||
if (!v) { reset(); return; }
|
if (!v) { reset(); return; }
|
||||||
|
|
||||||
// Playback is fine (or at least has a picture): stand down.
|
|
||||||
if (hasPicture(v)) { reset(); return; }
|
|
||||||
|
|
||||||
// A media error is unambiguous — no need to wait out the timer.
|
// A media error is unambiguous — no need to wait out the timer.
|
||||||
if (v.error) {
|
if (v.error) {
|
||||||
describeCodec(v);
|
describeCodec(v);
|
||||||
@@ -5026,6 +5053,31 @@
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Metadata is parsed and a frame exists. That is NOT enough to call it
|
||||||
|
// healthy: a decoder that read the header and then cannot keep up leaves
|
||||||
|
// videoWidth/readyState set while currentTime never moves. Only a moving
|
||||||
|
// playhead counts as playback.
|
||||||
|
if (hasPicture(v)) {
|
||||||
|
if (!W.progressAt) W.progressAt = now();
|
||||||
|
|
||||||
|
// Paused / seeking is the user's doing, not a stall.
|
||||||
|
if (v.paused || v.seeking) { W.progressAt = now(); W.lastTime = v.currentTime; return; }
|
||||||
|
|
||||||
|
if (v.currentTime !== W.lastTime) {
|
||||||
|
W.lastTime = v.currentTime;
|
||||||
|
W.progressAt = now();
|
||||||
|
if (W.shown) hide(); // it recovered (e.g. after a transcode switch)
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (now() - W.progressAt < STALL_MS) return;
|
||||||
|
if (W.quietUntil && now() < W.quietUntil) return;
|
||||||
|
describeCodec(v);
|
||||||
|
show(v, 'stalled');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// No picture at all yet: the original "never started" case.
|
||||||
if (!W.seenAt) W.seenAt = now();
|
if (!W.seenAt) W.seenAt = now();
|
||||||
if (now() - W.seenAt < timeoutMs(v)) return;
|
if (now() - W.seenAt < timeoutMs(v)) return;
|
||||||
|
|
||||||
@@ -5038,7 +5090,8 @@
|
|||||||
NS.Watchdog.init = function () {
|
NS.Watchdog.init = function () {
|
||||||
W.quietUntil = readQuiet();
|
W.quietUntil = readQuiet();
|
||||||
setInterval(poll, POLL_MS);
|
setInterval(poll, POLL_MS);
|
||||||
log('watchdog armed (dead=' + DEAD_MS + 'ms, transcode=' + DEAD_TRANSCODE_MS + 'ms)');
|
log('watchdog armed (dead=' + DEAD_MS + 'ms, transcode=' + DEAD_TRANSCODE_MS +
|
||||||
|
'ms, stall=' + STALL_MS + 'ms)');
|
||||||
};
|
};
|
||||||
})();
|
})();
|
||||||
|
|
||||||
|
|||||||
+17
-8
@@ -386,8 +386,11 @@
|
|||||||
* 10-bit will still claim 10-bit at that level and can black-screen on such a
|
* 10-bit will still claim 10-bit at that level and can black-screen on such a
|
||||||
* file. 40-watchdog.js covers exactly that, which is why it stays.
|
* file. 40-watchdog.js covers exactly that, which is why it stays.
|
||||||
*
|
*
|
||||||
* Escape hatches, if a device reports nonsense:
|
* THE HOOK IS OFF BY DEFAULT. The plugin no longer influences Jellyfin's
|
||||||
* localStorage['jfvr-cpt'] = 'off' disable the hook entirely
|
* direct-play / transcode decision at all -- Jellyfin uses its native device
|
||||||
|
* profile, and when playback cannot keep up the 40-watchdog.js prompt lets the
|
||||||
|
* user pick a bitrate. The override is kept only as an opt-in experiment:
|
||||||
|
* localStorage['jfvr-cpt'] = 'on' enable the canPlayType hook
|
||||||
* localStorage['jfvr-cpt-keep'] = '2:183' never downgrade these tiers
|
* localStorage['jfvr-cpt-keep'] = '2:183' never downgrade these tiers
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -563,10 +566,15 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
(function probeCodecs() {
|
(function probeCodecs() {
|
||||||
// Kill switch, and the escape hatch if this ever misbehaves on a device.
|
// Native behavior is the default: do NOT install the canPlayType override,
|
||||||
try {
|
// so Jellyfin builds its own device profile exactly as it would without this
|
||||||
if (localStorage.getItem('jfvr-cpt') === 'off') { NS.caps.cptMode = 'off'; return; }
|
// plugin. Opt back in with localStorage['jfvr-cpt'] = 'on' when diagnosing.
|
||||||
} catch (e) {}
|
// The decodingInfo probe still runs so the diagnostics panel can report what
|
||||||
|
// the device really supports -- it just no longer changes any decision.
|
||||||
|
var hookOn = false;
|
||||||
|
try { hookOn = localStorage.getItem('jfvr-cpt') === 'on'; } catch (e) {}
|
||||||
|
NS.caps.cptMode = hookOn ? null : 'off';
|
||||||
|
|
||||||
var mc = navigator.mediaCapabilities;
|
var mc = navigator.mediaCapabilities;
|
||||||
if (!mc || typeof mc.decodingInfo !== 'function') { NS.caps.cptMode = 'no-api'; return; }
|
if (!mc || typeof mc.decodingInfo !== 'function') { NS.caps.cptMode = 'no-api'; return; }
|
||||||
|
|
||||||
@@ -577,7 +585,7 @@
|
|||||||
// Install FIRST, synchronously, so the hook is in place before anything can
|
// Install FIRST, synchronously, so the hook is in place before anything can
|
||||||
// read canPlayType. Until a verdict lands the hook just defers to native,
|
// read canPlayType. Until a verdict lands the hook just defers to native,
|
||||||
// which is the safe default.
|
// which is the safe default.
|
||||||
installCanPlayTypeOverride();
|
if (hookOn) installCanPlayTypeOverride();
|
||||||
|
|
||||||
var pending = CODEC_PROBES.length;
|
var pending = CODEC_PROBES.length;
|
||||||
CODEC_PROBES.forEach(function (p) {
|
CODEC_PROBES.forEach(function (p) {
|
||||||
@@ -598,7 +606,8 @@
|
|||||||
}).then(function () {
|
}).then(function () {
|
||||||
if (--pending === 0) {
|
if (--pending === 0) {
|
||||||
applyVerdicts();
|
applyVerdicts();
|
||||||
NS.log('codec probe done; blocked = ' + (NS.caps.codecBlocked.join(', ') || 'none') +
|
NS.log('codec probe done (hook ' + NS.caps.cptMode + '); would block = ' +
|
||||||
|
(NS.caps.codecBlocked.join(', ') || 'none') +
|
||||||
(NS.caps.codecKept.length ? '; pinned = ' + NS.caps.codecKept.join(', ') : ''));
|
(NS.caps.codecKept.length ? '; pinned = ' + NS.caps.codecKept.join(', ') : ''));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
+56
-12
@@ -59,6 +59,15 @@
|
|||||||
var DEAD_MS = 15000;
|
var DEAD_MS = 15000;
|
||||||
var DEAD_TRANSCODE_MS = 45000;
|
var DEAD_TRANSCODE_MS = 45000;
|
||||||
|
|
||||||
|
// Metadata parsed but the playhead is not moving. This is the silent stall: a
|
||||||
|
// decoder that reads the header and then cannot keep up (8K HEVC Main 10 on a
|
||||||
|
// broken VAAPI driver is the motivating case). The old "has picture" check
|
||||||
|
// only looked at videoWidth/readyState, which are both already set here, so
|
||||||
|
// playback that never advances stood the watchdog down forever and the user
|
||||||
|
// got a frozen picture with no prompt. Give it a little longer than a clean
|
||||||
|
// start, since a heavy 8K stream legitimately buffers early.
|
||||||
|
var STALL_MS = 20000;
|
||||||
|
|
||||||
// After the user answers (either way) stay quiet, so a slow-but-working
|
// After the user answers (either way) stay quiet, so a slow-but-working
|
||||||
// playback does not get nagged at.
|
// playback does not get nagged at.
|
||||||
var QUIET_MS = 120000;
|
var QUIET_MS = 120000;
|
||||||
@@ -79,7 +88,9 @@
|
|||||||
lastReason: '',
|
lastReason: '',
|
||||||
applied: null,
|
applied: null,
|
||||||
codec: null, // filled in best-effort from the Jellyfin API
|
codec: null, // filled in best-effort from the Jellyfin API
|
||||||
panel: null
|
panel: null,
|
||||||
|
lastTime: -1, // playhead seen on the previous poll
|
||||||
|
progressAt: 0 // when the playhead last moved
|
||||||
};
|
};
|
||||||
NS.Watchdog = W;
|
NS.Watchdog = W;
|
||||||
|
|
||||||
@@ -105,7 +116,7 @@
|
|||||||
return src.indexOf('/hls') >= 0 || src.indexOf('.m3u8') >= 0;
|
return src.indexOf('/hls') >= 0 || src.indexOf('.m3u8') >= 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Metadata parsed AND a frame available. False means "no picture". */
|
/** Metadata parsed AND a frame available. False means "no picture at all". */
|
||||||
function hasPicture(v) {
|
function hasPicture(v) {
|
||||||
return v.videoWidth > 0 && v.readyState >= 2;
|
return v.videoWidth > 0 && v.readyState >= 2;
|
||||||
}
|
}
|
||||||
@@ -247,17 +258,25 @@
|
|||||||
|
|
||||||
var p = NS.makeEl('div', 'jfvr-wd');
|
var p = NS.makeEl('div', 'jfvr-wd');
|
||||||
p.id = 'jfvr-wd';
|
p.id = 'jfvr-wd';
|
||||||
p.appendChild(NS.makeEl('h3', null, '视频没能开始播放'));
|
p.appendChild(NS.makeEl('h3', null,
|
||||||
|
reason === 'stalled' ? '视频播放卡住了' : '视频没能开始播放'));
|
||||||
|
|
||||||
var body = NS.makeEl('div', 'jfvr-wd-body');
|
var body = NS.makeEl('div', 'jfvr-wd-body');
|
||||||
|
|
||||||
var msg = NS.makeEl('p');
|
var msg = NS.makeEl('p');
|
||||||
var waited = Math.round(timeoutMs(v) / 1000);
|
var waited = Math.round(timeoutMs(v) / 1000);
|
||||||
|
var intro;
|
||||||
|
if (reason === 'error') {
|
||||||
|
intro = '播放器报错了,一个画面都没解出来。';
|
||||||
|
} else if (reason === 'stalled') {
|
||||||
|
intro = '画面已经出来了,但播放进度停住不动了(<code>currentTime</code> 不再前进)—— ' +
|
||||||
|
'解码器跟不上这个文件。';
|
||||||
|
} else {
|
||||||
|
intro = '等了 ' + waited + ' 秒都没拿到任何画面(<code>videoWidth = 0</code>),' +
|
||||||
|
'所以播放器界面也没有被创建出来。';
|
||||||
|
}
|
||||||
msg.innerHTML =
|
msg.innerHTML =
|
||||||
(reason === 'error'
|
intro +
|
||||||
? '播放器报错了,一个画面都没解出来。'
|
|
||||||
: '等了 ' + waited + ' 秒都没拿到任何画面(<code>videoWidth = 0</code>),' +
|
|
||||||
'所以播放器界面也没有被创建出来。') +
|
|
||||||
'最常见的原因是<strong>这台设备解不动这个格式</strong>:' +
|
'最常见的原因是<strong>这台设备解不动这个格式</strong>:' +
|
||||||
'<span class="jfvr-wd-fmt">' + (W.codec || '该格式') + '</span>。<br>' +
|
'<span class="jfvr-wd-fmt">' + (W.codec || '该格式') + '</span>。<br>' +
|
||||||
'让服务器转码成 H.264 再播就能看到画面,代价是画质下降(这台 NAS 的转码上限约 4K)。';
|
'让服务器转码成 H.264 再播就能看到画面,代价是画质下降(这台 NAS 的转码上限约 4K)。';
|
||||||
@@ -299,7 +318,7 @@
|
|||||||
W.panel = p;
|
W.panel = p;
|
||||||
|
|
||||||
NS.recordError('watchdog', new Error('playback never started: ' + reason));
|
NS.recordError('watchdog', new Error('playback never started: ' + reason));
|
||||||
log('watchdog: playback never started, reason =', reason, 'codec =', W.codec);
|
log('watchdog: prompt shown, reason =', reason, 'codec =', W.codec);
|
||||||
}
|
}
|
||||||
|
|
||||||
function hide() {
|
function hide() {
|
||||||
@@ -309,6 +328,8 @@
|
|||||||
|
|
||||||
function reset() {
|
function reset() {
|
||||||
W.seenAt = 0;
|
W.seenAt = 0;
|
||||||
|
W.lastTime = -1;
|
||||||
|
W.progressAt = 0;
|
||||||
W.codec = null;
|
W.codec = null;
|
||||||
if (W.shown) hide();
|
if (W.shown) hide();
|
||||||
}
|
}
|
||||||
@@ -329,9 +350,6 @@
|
|||||||
var v = playerVideo();
|
var v = playerVideo();
|
||||||
if (!v) { reset(); return; }
|
if (!v) { reset(); return; }
|
||||||
|
|
||||||
// Playback is fine (or at least has a picture): stand down.
|
|
||||||
if (hasPicture(v)) { reset(); return; }
|
|
||||||
|
|
||||||
// A media error is unambiguous — no need to wait out the timer.
|
// A media error is unambiguous — no need to wait out the timer.
|
||||||
if (v.error) {
|
if (v.error) {
|
||||||
describeCodec(v);
|
describeCodec(v);
|
||||||
@@ -340,6 +358,31 @@
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Metadata is parsed and a frame exists. That is NOT enough to call it
|
||||||
|
// healthy: a decoder that read the header and then cannot keep up leaves
|
||||||
|
// videoWidth/readyState set while currentTime never moves. Only a moving
|
||||||
|
// playhead counts as playback.
|
||||||
|
if (hasPicture(v)) {
|
||||||
|
if (!W.progressAt) W.progressAt = now();
|
||||||
|
|
||||||
|
// Paused / seeking is the user's doing, not a stall.
|
||||||
|
if (v.paused || v.seeking) { W.progressAt = now(); W.lastTime = v.currentTime; return; }
|
||||||
|
|
||||||
|
if (v.currentTime !== W.lastTime) {
|
||||||
|
W.lastTime = v.currentTime;
|
||||||
|
W.progressAt = now();
|
||||||
|
if (W.shown) hide(); // it recovered (e.g. after a transcode switch)
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (now() - W.progressAt < STALL_MS) return;
|
||||||
|
if (W.quietUntil && now() < W.quietUntil) return;
|
||||||
|
describeCodec(v);
|
||||||
|
show(v, 'stalled');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// No picture at all yet: the original "never started" case.
|
||||||
if (!W.seenAt) W.seenAt = now();
|
if (!W.seenAt) W.seenAt = now();
|
||||||
if (now() - W.seenAt < timeoutMs(v)) return;
|
if (now() - W.seenAt < timeoutMs(v)) return;
|
||||||
|
|
||||||
@@ -352,6 +395,7 @@
|
|||||||
NS.Watchdog.init = function () {
|
NS.Watchdog.init = function () {
|
||||||
W.quietUntil = readQuiet();
|
W.quietUntil = readQuiet();
|
||||||
setInterval(poll, POLL_MS);
|
setInterval(poll, POLL_MS);
|
||||||
log('watchdog armed (dead=' + DEAD_MS + 'ms, transcode=' + DEAD_TRANSCODE_MS + 'ms)');
|
log('watchdog armed (dead=' + DEAD_MS + 'ms, transcode=' + DEAD_TRANSCODE_MS +
|
||||||
|
'ms, stall=' + STALL_MS + 'ms)');
|
||||||
};
|
};
|
||||||
})();
|
})();
|
||||||
|
|||||||
Reference in New Issue
Block a user