@banou/media-player 0.9.0 → 0.10.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +40 -4
- package/dist/engine/index.d.ts +1 -1
- package/dist/engine/index.js +1 -1
- package/dist/engine/playback.d.ts +17 -0
- package/dist/engine/thumbnails.d.ts +11 -0
- package/dist/{engine-DZrYu66u.js → engine-b5_5HscR.js} +36 -19
- package/dist/index.d.ts +1 -1
- package/dist/index.js +641 -337
- package/dist/react/components/skip-chapter.d.ts +10 -0
- package/dist/react/hooks/use-thumbnails.d.ts +12 -1
- package/dist/react/player.d.ts +2 -0
- package/dist/react/source-feature.d.ts +39 -1
- package/dist/react/video-player.d.ts +13 -0
- package/dist/utils/chapters.d.ts +37 -0
- package/package.json +1 -1
- package/src/lib/engine/index.ts +1 -1
- package/src/lib/engine/playback.ts +15 -0
- package/src/lib/engine/thumbnails.ts +80 -21
- package/src/lib/index.tsx +1 -0
- package/src/lib/react/components/chrome.tsx +2 -0
- package/src/lib/react/components/progress-bar.tsx +144 -29
- package/src/lib/react/components/skip-chapter.tsx +166 -0
- package/src/lib/react/hooks/use-playback.ts +17 -2
- package/src/lib/react/hooks/use-thumbnails.ts +19 -3
- package/src/lib/react/source-feature.ts +22 -1
- package/src/lib/react/video-player.tsx +32 -3
- package/src/lib/utils/chapters.ts +302 -0
- package/src/lib/utils/source.ts +12 -1
package/src/lib/utils/source.ts
CHANGED
|
@@ -24,8 +24,19 @@ const fromUrl = async (
|
|
|
24
24
|
) => {
|
|
25
25
|
const length = _length ?? await probeLength(url, credentials)
|
|
26
26
|
const read = async (offset: number, size: number) => {
|
|
27
|
+
/*
|
|
28
|
+
* A read that starts at or past the end answers empty, the way slicing a Blob does.
|
|
29
|
+
*
|
|
30
|
+
* Without this the range comes out as `bytes=<offset>-<length-1>` with the last byte before the
|
|
31
|
+
* first, which is not a range a server can satisfy: it answers 416 and the read throws, so the
|
|
32
|
+
* demuxer's ordinary walk into EOF surfaces as "Reading the video file failed" on a file that is
|
|
33
|
+
* perfectly fine. The blob arm has always returned empty here, so this is also what makes the two
|
|
34
|
+
* arms of `inputToRemuxerInput` behave the same.
|
|
35
|
+
*/
|
|
36
|
+
const end = Math.min(offset + size, length) - 1
|
|
37
|
+
if (end < offset) return new ArrayBuffer(0)
|
|
27
38
|
const response = await fetch(url, {
|
|
28
|
-
headers: { Range: `bytes=${offset}-${
|
|
39
|
+
headers: { Range: `bytes=${offset}-${end}` },
|
|
29
40
|
credentials,
|
|
30
41
|
})
|
|
31
42
|
if (!response.ok) throw new Error(`The source could not be read: HTTP ${response.status}`)
|