Spaces:
Running
Running
Fetch the sample videos as blobs: the Space serves them from another origin
Browse files- index.html +13 -1
index.html
CHANGED
|
@@ -1568,7 +1568,19 @@
|
|
| 1568 |
return;
|
| 1569 |
}
|
| 1570 |
mark(sample);
|
| 1571 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1572 |
}
|
| 1573 |
|
| 1574 |
// Coming back to a tab shows what it showed last: a video with its kept frames, or the photo.
|
|
|
|
| 1568 |
return;
|
| 1569 |
}
|
| 1570 |
mark(sample);
|
| 1571 |
+
// Fetched whole, so that the video is of this page's origin: the Space serves it from another,
|
| 1572 |
+
// and the browser does not let a page read the pixels of a video from elsewhere.
|
| 1573 |
+
const turn = ++asked;
|
| 1574 |
+
fetch(`samples/${sample}.mp4`)
|
| 1575 |
+
.then((response) => response.ok ? response.blob() : Promise.reject(new Error(response.status)))
|
| 1576 |
+
.then((blob) => {
|
| 1577 |
+
if (turn === asked) openClip(URL.createObjectURL(blob), sample, true, turn);
|
| 1578 |
+
})
|
| 1579 |
+
.catch(() => {
|
| 1580 |
+
if (turn !== asked) return;
|
| 1581 |
+
mark(source?.sample);
|
| 1582 |
+
warn('That sample video did not load.');
|
| 1583 |
+
});
|
| 1584 |
}
|
| 1585 |
|
| 1586 |
// Coming back to a tab shows what it showed last: a video with its kept frames, or the photo.
|