Spaces:
Running
Running
Upload index.html
Browse files- index.html +8 -0
index.html
CHANGED
|
@@ -293,6 +293,14 @@ $('exBtn').onclick=async()=>{ if(busy||!det) return; try{ setStatus('Loading exa
|
|
| 293 |
$('file').onchange=async e=>{ const f=e.target.files[0]; if(!f||busy||!det) return; try{ await openVideo(URL.createObjectURL(f),0,null); await analyze(); await replay(false);}catch(err){setStatus('Error: '+err.message)} };
|
| 294 |
$('playBtn').onclick=()=>replay(false);
|
| 295 |
$('recBtn').onclick=()=>replay(true);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 296 |
loadModels().catch(e=>setStatus('Could not load models: '+e.message));
|
| 297 |
</script>
|
| 298 |
</body>
|
|
|
|
| 293 |
$('file').onchange=async e=>{ const f=e.target.files[0]; if(!f||busy||!det) return; try{ await openVideo(URL.createObjectURL(f),0,null); await analyze(); await replay(false);}catch(err){setStatus('Error: '+err.message)} };
|
| 294 |
$('playBtn').onclick=()=>replay(false);
|
| 295 |
$('recBtn').onclick=()=>replay(true);
|
| 296 |
+
// Embed hook: a parent page can ask for the example result as a video clip.
|
| 297 |
+
window.addEventListener('message', async e=>{
|
| 298 |
+
if(!(e.data && e.data.cmd==='example-record')) return;
|
| 299 |
+
while(!det) await new Promise(r=>setTimeout(r,500));
|
| 300 |
+
window.NO_DOWNLOAD=true;
|
| 301 |
+
await openVideo(EXAMPLE.url,EXAMPLE.start,EXAMPLE.end); await analyze(); await replay(true);
|
| 302 |
+
e.source.postMessage({kind:'clip', blob:window.lastClip}, e.origin);
|
| 303 |
+
});
|
| 304 |
loadModels().catch(e=>setStatus('Could not load models: '+e.message));
|
| 305 |
</script>
|
| 306 |
</body>
|