Upload folder using huggingface_hub
Browse files- README.md +12 -0
- index.html +46 -198
README.md
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
title: DASH CORS Test
|
| 3 |
+
emoji: 🎬
|
| 4 |
+
colorFrom: blue
|
| 5 |
+
colorTo: indigo
|
| 6 |
+
sdk: static
|
| 7 |
+
pinned: false
|
| 8 |
+
***
|
| 9 |
+
|
| 10 |
+
Static Space for testing DASH playback from a Hugging Face dataset repo.
|
| 11 |
+
|
| 12 |
+
Edit `index.html` and set `DEFAULT_MPD` to your dataset manifest URL, or use the input box in the app.
|
index.html
CHANGED
|
@@ -3,228 +3,76 @@
|
|
| 3 |
<head>
|
| 4 |
<meta charset="utf-8" />
|
| 5 |
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
| 6 |
-
<title>
|
| 7 |
<style>
|
| 8 |
-
:root{
|
| 9 |
-
|
| 10 |
-
}
|
| 11 |
-
|
| 12 |
-
.
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
.
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
label{display:block;font-weight:700;margin:14px 0 6px}
|
| 20 |
-
input,textarea{width:100%;background:#0d1430;color:var(--text);border:1px solid var(--line);border-radius:12px;padding:12px}
|
| 21 |
-
textarea{min-height:110px;resize:vertical}
|
| 22 |
-
.row{display:flex;gap:10px;flex-wrap:wrap;margin-top:14px}
|
| 23 |
-
button{background:var(--accent);color:#08101f;border:0;border-radius:12px;padding:11px 14px;font-weight:700;cursor:pointer}
|
| 24 |
-
button.secondary{background:#223158;color:var(--text)}
|
| 25 |
-
pre{background:#08101f;border:1px solid var(--line);border-radius:12px;padding:14px;white-space:pre-wrap;word-break:break-word;min-height:360px;max-height:680px;overflow:auto}
|
| 26 |
-
.kpis{display:grid;grid-template-columns:repeat(4,1fr);gap:10px;margin-top:12px}
|
| 27 |
-
@media (max-width:760px){.kpis{grid-template-columns:repeat(2,1fr)}}
|
| 28 |
-
.kpi{background:#0d1430;border:1px solid var(--line);border-radius:12px;padding:12px}
|
| 29 |
-
.v{font-size:1.1rem;font-weight:800}
|
| 30 |
-
.ok{color:var(--ok)} .warn{color:var(--warn)} .bad{color:var(--bad)}
|
| 31 |
-
code{background:#0d1430;padding:2px 6px;border-radius:6px}
|
| 32 |
-
video{width:100%;aspect-ratio:16/9;background:black;border-radius:12px;border:1px solid var(--line)}
|
| 33 |
-
.small{font-size:.92rem;color:var(--muted)}
|
| 34 |
-
ul{padding-left:18px}
|
| 35 |
-
.mono{font-family:ui-monospace,SFMono-Regular,Menlo,Consolas,monospace}
|
| 36 |
</style>
|
| 37 |
</head>
|
| 38 |
<body>
|
| 39 |
<div class="wrap">
|
| 40 |
-
<h1>Hugging Face DASH
|
| 41 |
-
<p>
|
| 42 |
<div class="grid">
|
| 43 |
<section class="card">
|
| 44 |
-
<
|
| 45 |
-
<
|
| 46 |
-
<
|
| 47 |
-
|
| 48 |
-
<label for="sampleSegments">Sample segment URLs to test directly (one per line)</label>
|
| 49 |
-
<textarea id="sampleSegments" spellcheck="false">https://huggingface.co/datasets/USERNAME/REPO/resolve/main/dash/init.mp4
|
| 50 |
-
https://huggingface.co/datasets/USERNAME/REPO/resolve/main/dash/chunk-00001.m4s</textarea>
|
| 51 |
-
|
| 52 |
-
<label for="customHeaders">Optional extra headers for preflight testing (JSON)</label>
|
| 53 |
-
<textarea id="customHeaders" spellcheck="false">{}</textarea>
|
| 54 |
-
|
| 55 |
<div class="row">
|
| 56 |
-
<button id="testManifest">Test manifest
|
| 57 |
-
<button id="testSegments" class="secondary">Test
|
| 58 |
-
<button id="
|
| 59 |
-
<button id="
|
| 60 |
</div>
|
| 61 |
-
|
| 62 |
<div class="kpis">
|
| 63 |
-
<div class="kpi"><div class="small">Manifest
|
| 64 |
<div class="kpi"><div class="small">Segments</div><div id="segmentStatus" class="v">—</div></div>
|
| 65 |
<div class="kpi"><div class="small">dash.js</div><div id="dashStatus" class="v">—</div></div>
|
| 66 |
-
<div class="kpi"><div class="small">Video
|
| 67 |
</div>
|
| 68 |
-
|
| 69 |
<label for="log">Log</label>
|
| 70 |
<pre id="log"></pre>
|
| 71 |
</section>
|
| 72 |
-
|
| 73 |
<aside class="card">
|
| 74 |
-
<h2>Player and guidance</h2>
|
| 75 |
<video id="player" controls preload="metadata"></video>
|
| 76 |
-
<p class="small">
|
| 77 |
-
<
|
| 78 |
-
<li>If <code>manifest fetch()</code> fails, your JS player cannot even read the MPD.</li>
|
| 79 |
-
<li>If the MPD fetch works but sample segment fetches fail, the manifest may be readable while the actual media chunks are blocked.</li>
|
| 80 |
-
<li>If dash.js throws errors even though direct fetches look okay, the problem may be codec/container compatibility rather than CORS.</li>
|
| 81 |
-
<li>Use stable Hugging Face <code>/resolve/main/...</code> URLs here, not the temporary signed <code>cas-bridge...</code> URL.</li>
|
| 82 |
-
</ul>
|
| 83 |
-
<p class="small mono">Suggested repo layout:<br>dash/manifest.mpd<br>dash/video/init.mp4<br>dash/video/chunk-00001.m4s<br>dash/audio/init.mp4<br>dash/audio/chunk-00001.m4s</p>
|
| 84 |
</aside>
|
| 85 |
</div>
|
| 86 |
</div>
|
| 87 |
-
|
| 88 |
<script src="https://cdn.dashjs.org/v5.0.3/modern/umd/dash.all.min.js"></script>
|
| 89 |
<script>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 90 |
const $ = (id) => document.getElementById(id);
|
| 91 |
-
const logEl = $('log');
|
| 92 |
-
|
| 93 |
-
|
| 94 |
-
|
| 95 |
-
|
| 96 |
-
|
| 97 |
-
|
| 98 |
-
|
| 99 |
-
function
|
| 100 |
-
|
| 101 |
-
|
| 102 |
-
|
| 103 |
-
|
| 104 |
-
logEl.appendChild(div);
|
| 105 |
-
logEl.scrollTop = logEl.scrollHeight;
|
| 106 |
-
console.log(line);
|
| 107 |
-
}
|
| 108 |
-
function setStatus(el, text, cls=''){ el.textContent = text; el.className = `v ${cls}`; }
|
| 109 |
-
function getManifest(){ return $('manifestUrl').value.trim(); }
|
| 110 |
-
function getHeaders(){
|
| 111 |
-
const raw = $('customHeaders').value.trim() || '{}';
|
| 112 |
-
try { return JSON.parse(raw); }
|
| 113 |
-
catch (e) { throw new Error('Headers JSON is invalid: ' + e.message); }
|
| 114 |
-
}
|
| 115 |
-
function getSegments(){
|
| 116 |
-
return $('sampleSegments').value.split('\n').map(s => s.trim()).filter(Boolean);
|
| 117 |
-
}
|
| 118 |
-
|
| 119 |
-
async function testManifest(){
|
| 120 |
-
setStatus(manifestStatus,'running','warn');
|
| 121 |
-
const url = getManifest();
|
| 122 |
-
log(`Testing MPD fetch for ${url}`);
|
| 123 |
-
try {
|
| 124 |
-
const res = await fetch(url, { mode:'cors', redirect:'follow', headers:getHeaders() });
|
| 125 |
-
log(`MPD status=${res.status} redirected=${res.redirected} finalURL=${res.url}`);
|
| 126 |
-
log(`MPD content-type=${res.headers.get('content-type')}`);
|
| 127 |
-
log(`MPD access-control-allow-origin=${res.headers.get('access-control-allow-origin')}`);
|
| 128 |
-
const text = await res.text();
|
| 129 |
-
log(`MPD bytes read=${text.length}`);
|
| 130 |
-
log(`MPD first 200 chars=${text.slice(0,200).replace(/\s+/g,' ')}`);
|
| 131 |
-
setStatus(manifestStatus, res.ok ? 'OK' : String(res.status), res.ok ? 'ok' : 'bad');
|
| 132 |
-
} catch (e) {
|
| 133 |
-
log(`MPD fetch failed: ${e.name}: ${e.message}`,'bad');
|
| 134 |
-
setStatus(manifestStatus,'blocked','bad');
|
| 135 |
-
}
|
| 136 |
-
}
|
| 137 |
-
|
| 138 |
-
async function testSegments(){
|
| 139 |
-
const urls = getSegments();
|
| 140 |
-
if (!urls.length) { log('No sample segment URLs provided','bad'); return; }
|
| 141 |
-
setStatus(segmentStatus,'running','warn');
|
| 142 |
-
let ok = 0, partial = 0;
|
| 143 |
-
for (const url of urls) {
|
| 144 |
-
log(`Testing segment ${url}`);
|
| 145 |
-
try {
|
| 146 |
-
const res = await fetch(url, {
|
| 147 |
-
mode:'cors',
|
| 148 |
-
redirect:'follow',
|
| 149 |
-
headers: { ...getHeaders(), 'Range':'bytes=0-1023' }
|
| 150 |
-
});
|
| 151 |
-
const buf = await res.arrayBuffer();
|
| 152 |
-
log(`segment status=${res.status} finalURL=${res.url}`);
|
| 153 |
-
log(`segment content-type=${res.headers.get('content-type')}`);
|
| 154 |
-
log(`segment content-range=${res.headers.get('content-range')}`);
|
| 155 |
-
log(`segment access-control-allow-origin=${res.headers.get('access-control-allow-origin')}`);
|
| 156 |
-
log(`segment bytes read=${buf.byteLength}`);
|
| 157 |
-
if (res.ok) ok++;
|
| 158 |
-
if (res.status === 206) partial++;
|
| 159 |
-
} catch (e) {
|
| 160 |
-
log(`segment fetch failed: ${e.name}: ${e.message}`,'bad');
|
| 161 |
-
}
|
| 162 |
-
}
|
| 163 |
-
if (ok === urls.length && partial === urls.length) setStatus(segmentStatus,'all 206','ok');
|
| 164 |
-
else if (ok > 0) setStatus(segmentStatus,`${ok}/${urls.length} ok`,'warn');
|
| 165 |
-
else setStatus(segmentStatus,'blocked','bad');
|
| 166 |
-
}
|
| 167 |
-
|
| 168 |
-
function destroyPlayer(){
|
| 169 |
-
if (player) {
|
| 170 |
-
try { player.reset(); } catch (_) {}
|
| 171 |
-
player = null;
|
| 172 |
-
}
|
| 173 |
-
playerEl.removeAttribute('src');
|
| 174 |
-
playerEl.load();
|
| 175 |
-
}
|
| 176 |
-
|
| 177 |
-
function startDash(){
|
| 178 |
-
const url = getManifest();
|
| 179 |
-
destroyPlayer();
|
| 180 |
-
setStatus(dashStatus,'starting','warn');
|
| 181 |
-
setStatus(videoStatus,'waiting','warn');
|
| 182 |
-
log(`Initializing dash.js with ${url}`);
|
| 183 |
-
try {
|
| 184 |
-
player = dashjs.MediaPlayer().create();
|
| 185 |
-
player.updateSettings({ debug: { logLevel: dashjs.Debug.LOG_LEVEL_WARNING } });
|
| 186 |
-
player.on(dashjs.MediaPlayer.events.ERROR, (e) => {
|
| 187 |
-
log(`dash.js ERROR type=${e.error || e.event?.id || 'unknown'} message=${e.event?.message || e.message || 'n/a'}`,'bad');
|
| 188 |
-
setStatus(dashStatus,'error','bad');
|
| 189 |
-
});
|
| 190 |
-
player.on(dashjs.MediaPlayer.events.MANIFEST_LOADED, () => {
|
| 191 |
-
log('dash.js MANIFEST_LOADED','ok');
|
| 192 |
-
setStatus(dashStatus,'manifest ok','ok');
|
| 193 |
-
});
|
| 194 |
-
player.on(dashjs.MediaPlayer.events.STREAM_INITIALIZED, () => {
|
| 195 |
-
log('dash.js STREAM_INITIALIZED','ok');
|
| 196 |
-
setStatus(dashStatus,'stream ok','ok');
|
| 197 |
-
});
|
| 198 |
-
playerEl.onloadedmetadata = () => {
|
| 199 |
-
log(`video loaded metadata duration=${Number.isFinite(playerEl.duration) ? playerEl.duration.toFixed(2) : 'unknown'}s currentSrc=${playerEl.currentSrc}`,'ok');
|
| 200 |
-
setStatus(videoStatus,'metadata ok','ok');
|
| 201 |
-
};
|
| 202 |
-
playerEl.oncanplay = () => log('video canplay fired','ok');
|
| 203 |
-
playerEl.onerror = () => {
|
| 204 |
-
const err = playerEl.error;
|
| 205 |
-
log(`video element error code=${err ? err.code : 'unknown'}`,'bad');
|
| 206 |
-
setStatus(videoStatus,'error','bad');
|
| 207 |
-
};
|
| 208 |
-
player.initialize(playerEl, url, false);
|
| 209 |
-
} catch (e) {
|
| 210 |
-
log(`dash.js init failed: ${e.name}: ${e.message}`,'bad');
|
| 211 |
-
setStatus(dashStatus,'init failed','bad');
|
| 212 |
-
}
|
| 213 |
-
}
|
| 214 |
-
|
| 215 |
-
$('testManifest').addEventListener('click', testManifest);
|
| 216 |
-
$('testSegments').addEventListener('click', testSegments);
|
| 217 |
-
$('startDash').addEventListener('click', startDash);
|
| 218 |
-
$('clearLog').addEventListener('click', () => {
|
| 219 |
-
logEl.textContent = '';
|
| 220 |
-
setStatus(manifestStatus,'—');
|
| 221 |
-
setStatus(segmentStatus,'—');
|
| 222 |
-
setStatus(dashStatus,'—');
|
| 223 |
-
setStatus(videoStatus,'—');
|
| 224 |
-
destroyPlayer();
|
| 225 |
-
});
|
| 226 |
-
|
| 227 |
-
log('Ready. Paste your MPD URL and a few sample segment URLs, then run the tests.');
|
| 228 |
</script>
|
| 229 |
</body>
|
| 230 |
</html>
|
|
|
|
| 3 |
<head>
|
| 4 |
<meta charset="utf-8" />
|
| 5 |
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
| 6 |
+
<title>DASH CORS Test</title>
|
| 7 |
<style>
|
| 8 |
+
:root{--bg:#0f1220;--panel:#171c31;--panel2:#1d2440;--text:#ebefff;--muted:#a8b3d6;--line:#2b355e;--accent:#84a9ff;--ok:#39d39c;--warn:#ffce6a;--bad:#ff7b7b}
|
| 9 |
+
*{box-sizing:border-box} html,body{margin:0;padding:0;background:var(--bg);color:var(--text);font:16px/1.5 Inter,system-ui,sans-serif}
|
| 10 |
+
.wrap{max-width:1180px;margin:0 auto;padding:24px} h1{font-size:clamp(1.8rem,3vw,2.5rem);margin:0 0 8px} p{color:var(--muted);margin:8px 0}
|
| 11 |
+
.grid{display:grid;grid-template-columns:1.08fr .92fr;gap:18px}@media (max-width:960px){.grid{grid-template-columns:1fr}}
|
| 12 |
+
.card{background:linear-gradient(180deg,var(--panel),var(--panel2));border:1px solid var(--line);border-radius:18px;padding:18px;box-shadow:0 12px 34px rgba(0,0,0,.25)}
|
| 13 |
+
label{display:block;font-weight:700;margin:14px 0 6px} input,textarea{width:100%;background:#0d1430;color:var(--text);border:1px solid var(--line);border-radius:12px;padding:12px} textarea{min-height:110px;resize:vertical}
|
| 14 |
+
.row{display:flex;gap:10px;flex-wrap:wrap;margin-top:14px} button{background:var(--accent);color:#08101f;border:0;border-radius:12px;padding:11px 14px;font-weight:700;cursor:pointer} button.secondary{background:#26355f;color:var(--text)}
|
| 15 |
+
.kpis{display:grid;grid-template-columns:repeat(4,1fr);gap:10px;margin-top:12px}@media (max-width:760px){.kpis{grid-template-columns:repeat(2,1fr)}} .kpi{background:#0d1430;border:1px solid var(--line);border-radius:12px;padding:12px}
|
| 16 |
+
.v{font-size:1.08rem;font-weight:800}.ok{color:var(--ok)} .warn{color:var(--warn)} .bad{color:var(--bad)}
|
| 17 |
+
pre{background:#08101f;border:1px solid var(--line);border-radius:12px;padding:14px;white-space:pre-wrap;word-break:break-word;min-height:340px;max-height:680px;overflow:auto}
|
| 18 |
+
video{width:100%;aspect-ratio:16/9;background:#000;border-radius:14px;border:1px solid var(--line)} code{background:#0d1430;padding:2px 6px;border-radius:6px}.small{font-size:.92rem;color:var(--muted)}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 19 |
</style>
|
| 20 |
</head>
|
| 21 |
<body>
|
| 22 |
<div class="wrap">
|
| 23 |
+
<h1>Hugging Face Space DASH test</h1>
|
| 24 |
+
<p>This page is meant to run from a Hugging Face Static Space and test whether a DASH manifest and its segments can be played from a Hugging Face dataset repo without cross-origin failures.</p>
|
| 25 |
<div class="grid">
|
| 26 |
<section class="card">
|
| 27 |
+
<label for="mpd">Manifest URL (.mpd)</label>
|
| 28 |
+
<input id="mpd" type="url" spellcheck="false" />
|
| 29 |
+
<label for="segments">Optional sample segment URLs (one per line)</label>
|
| 30 |
+
<textarea id="segments" spellcheck="false"></textarea>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 31 |
<div class="row">
|
| 32 |
+
<button id="testManifest">Test manifest</button>
|
| 33 |
+
<button id="testSegments" class="secondary">Test segments</button>
|
| 34 |
+
<button id="start" class="secondary">Start dash.js</button>
|
| 35 |
+
<button id="clear" class="secondary">Clear</button>
|
| 36 |
</div>
|
|
|
|
| 37 |
<div class="kpis">
|
| 38 |
+
<div class="kpi"><div class="small">Manifest</div><div id="manifestStatus" class="v">—</div></div>
|
| 39 |
<div class="kpi"><div class="small">Segments</div><div id="segmentStatus" class="v">—</div></div>
|
| 40 |
<div class="kpi"><div class="small">dash.js</div><div id="dashStatus" class="v">—</div></div>
|
| 41 |
+
<div class="kpi"><div class="small">Video</div><div id="videoStatus" class="v">—</div></div>
|
| 42 |
</div>
|
|
|
|
| 43 |
<label for="log">Log</label>
|
| 44 |
<pre id="log"></pre>
|
| 45 |
</section>
|
|
|
|
| 46 |
<aside class="card">
|
|
|
|
| 47 |
<video id="player" controls preload="metadata"></video>
|
| 48 |
+
<p class="small">Use a dataset URL like <code>https://huggingface.co/datasets/USERNAME/REPO/resolve/main/dash-h264/manifest.mpd</code>. If playback works here but not on your own domain, the issue is cross-origin policy rather than packaging.</p>
|
| 49 |
+
<p class="small">Check the browser console too. dash.js may fail because of CORS, unsupported codecs, or a segment path problem.</p>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 50 |
</aside>
|
| 51 |
</div>
|
| 52 |
</div>
|
|
|
|
| 53 |
<script src="https://cdn.dashjs.org/v5.0.3/modern/umd/dash.all.min.js"></script>
|
| 54 |
<script>
|
| 55 |
+
const DEFAULT_MPD = 'https://huggingface.co/datasets/SassyDiffusion/test2/resolve/main/dash-h264/manifest.mpd';
|
| 56 |
+
const DEFAULT_SEGMENTS = [
|
| 57 |
+
'https://huggingface.co/datasets/SassyDiffusion/test2/resolve/main/dash-h264/init-0.mp4',
|
| 58 |
+
'https://huggingface.co/datasets/SassyDiffusion/test2/resolve/main/dash-h264/chunk-0-00001.m4s',
|
| 59 |
+
'https://huggingface.co/datasets/SassyDiffusion/test2/resolve/main/dash-h264/init-1.mp4',
|
| 60 |
+
'https://huggingface.co/datasets/SassyDiffusion/test2/resolve/main/dash-h264/chunk-1-00001.m4s'
|
| 61 |
+
];
|
| 62 |
const $ = (id) => document.getElementById(id);
|
| 63 |
+
const logEl = $('log'), playerEl = $('player'), manifestStatus = $('manifestStatus'), segmentStatus = $('segmentStatus'), dashStatus = $('dashStatus'), videoStatus = $('videoStatus');
|
| 64 |
+
let player = null;
|
| 65 |
+
$('mpd').value = DEFAULT_MPD; $('segments').value = DEFAULT_SEGMENTS.join('\n');
|
| 66 |
+
function log(msg, cls=''){ const line=`[${new Date().toLocaleTimeString()}] ${msg}`; const div=document.createElement('div'); div.textContent=line; if(cls) div.className=cls; logEl.appendChild(div); logEl.scrollTop=logEl.scrollHeight; console.log(line); }
|
| 67 |
+
function setStatus(el, text, cls=''){ el.textContent=text; el.className=`v ${cls}`; }
|
| 68 |
+
function manifestUrl(){ return $('mpd').value.trim(); }
|
| 69 |
+
function segmentUrls(){ return $('segments').value.split('\n').map(v=>v.trim()).filter(Boolean); }
|
| 70 |
+
async function testManifest(){ setStatus(manifestStatus,'running','warn'); try { const res=await fetch(manifestUrl(), {mode:'cors', redirect:'follow'}); const text=await res.text(); log(`manifest status=${res.status} finalURL=${res.url}`); log(`manifest content-type=${res.headers.get('content-type')}`); log(`manifest bytes=${text.length}`); setStatus(manifestStatus, res.ok?'OK':String(res.status), res.ok?'ok':'bad'); } catch(e){ log(`manifest fetch failed: ${e.name}: ${e.message}`, 'bad'); setStatus(manifestStatus,'blocked','bad'); } }
|
| 71 |
+
async function testSegments(){ const urls=segmentUrls(); setStatus(segmentStatus,'running','warn'); let ok=0; for(const url of urls){ try { const res=await fetch(url, {mode:'cors', redirect:'follow', headers:{Range:'bytes=0-1023'}}); const buf=await res.arrayBuffer(); log(`segment status=${res.status} finalURL=${res.url}`); log(`segment type=${res.headers.get('content-type')} content-range=${res.headers.get('content-range')}`); log(`segment bytes=${buf.byteLength}`); if(res.ok) ok++; } catch(e){ log(`segment fetch failed: ${e.name}: ${e.message}`, 'bad'); } } setStatus(segmentStatus, ok===urls.length?'OK':`${ok}/${urls.length}`, ok===urls.length?'ok':'warn'); }
|
| 72 |
+
function resetPlayer(){ if(player){ try{ player.reset(); }catch(_){} player=null; } playerEl.pause(); playerEl.removeAttribute('src'); playerEl.load(); }
|
| 73 |
+
function startDash(){ resetPlayer(); setStatus(dashStatus,'starting','warn'); setStatus(videoStatus,'waiting','warn'); const url=manifestUrl(); log(`Initializing dash.js with ${url}`); player=dashjs.MediaPlayer().create(); player.updateSettings({ debug:{ logLevel: dashjs.Debug.LOG_LEVEL_WARNING } }); player.on(dashjs.MediaPlayer.events.MANIFEST_LOADED, ()=>{ log('dash.js MANIFEST_LOADED','ok'); setStatus(dashStatus,'manifest ok','ok'); }); player.on(dashjs.MediaPlayer.events.STREAM_INITIALIZED, ()=>{ log('dash.js STREAM_INITIALIZED','ok'); setStatus(dashStatus,'stream ok','ok'); }); player.on(dashjs.MediaPlayer.events.ERROR, (e)=>{ const err=e?.error || e?.event || e; log(`dash.js ERROR ${JSON.stringify(err)}`,'bad'); setStatus(dashStatus,'error','bad'); }); playerEl.onloadedmetadata=()=>{ log(`video metadata loaded duration=${Number.isFinite(playerEl.duration)?playerEl.duration.toFixed(2):'unknown'}s`, 'ok'); setStatus(videoStatus,'metadata ok','ok'); }; playerEl.onerror=()=>{ const err=playerEl.error; log(`video error code=${err?err.code:'unknown'}`,'bad'); setStatus(videoStatus,'error','bad'); }; player.initialize(playerEl, url, false); }
|
| 74 |
+
$('testManifest').addEventListener('click', testManifest); $('testSegments').addEventListener('click', testSegments); $('start').addEventListener('click', startDash); $('clear').addEventListener('click', ()=>{ logEl.textContent=''; setStatus(manifestStatus,'—'); setStatus(segmentStatus,'—'); setStatus(dashStatus,'—'); setStatus(videoStatus,'—'); resetPlayer(); });
|
| 75 |
+
log('Ready. Edit the URLs if needed, then test from this Space.');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 76 |
</script>
|
| 77 |
</body>
|
| 78 |
</html>
|