@banou/media-player 0.2.1 → 0.2.2

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@banou/media-player",
3
- "version": "0.2.1",
3
+ "version": "0.2.2",
4
4
  "description": "",
5
5
  "type": "module",
6
6
  "main": "build/index.js",
@@ -37,7 +37,7 @@
37
37
  "dependencies": {
38
38
  "@emotion/react": "^11.10.5",
39
39
  "jassub": "^1.7.1",
40
- "libav-wasm": "^0.3.2",
40
+ "libav-wasm": "^0.3.3",
41
41
  "mp4box": "^0.5.2",
42
42
  "osra": "^0.0.11",
43
43
  "p-queue": "^7.3.4",
package/src/index.tsx CHANGED
@@ -250,8 +250,12 @@ const FKNVideo = forwardRef<HTMLVideoElement, VideoHTMLAttributes<HTMLInputEleme
250
250
 
251
251
  await appendBuffer(headerChunk.buffer)
252
252
 
253
+ let reachedEnd = false
254
+
253
255
  const pull = async () => {
256
+ if (reachedEnd) throw new Error('end')
254
257
  const chunk = await remuxer.read()
258
+ if (chunk.isTrailer) reachedEnd = true
255
259
  chunks = [...chunks, chunk]
256
260
  return chunk
257
261
  }
@@ -265,7 +269,7 @@ const FKNVideo = forwardRef<HTMLVideoElement, VideoHTMLAttributes<HTMLInputEleme
265
269
  const sliceIndex = Math.max(0, currentChunkIndex - PREVIOUS_BUFFER_COUNT)
266
270
 
267
271
  for (let i = 0; i < sliceIndex + BUFFER_COUNT; i++) {
268
- if (chunks[i]) continue
272
+ if (chunks[i] || reachedEnd) continue
269
273
  const chunk = await pull()
270
274
  await appendBuffer(chunk.buffer)
271
275
  }
@@ -297,6 +301,7 @@ const FKNVideo = forwardRef<HTMLVideoElement, VideoHTMLAttributes<HTMLInputEleme
297
301
  let firstSeekPaused: boolean | undefined
298
302
  const seek = debounceImmediateAndLatest(250, async (seekTime: number) => {
299
303
  try {
304
+ reachedEnd = false
300
305
  if (firstSeekPaused === undefined) firstSeekPaused = videoElement.paused
301
306
  seeking = true
302
307
  chunks = []
package/src/main.tsx CHANGED
@@ -25,7 +25,7 @@ const Mount = () => {
25
25
 
26
26
  const onFetch = async (offset: number, end?: number) =>
27
27
  fetch(
28
- '/video6.mkv',
28
+ '/video9.mkv',
29
29
  {
30
30
  headers: {
31
31
  Range: `bytes=${offset}-${end ?? ''}`
package/src/utils.ts CHANGED
@@ -200,6 +200,7 @@ export const toBufferedStream = (SIZE: number) => (stream: ReadableStream) =>
200
200
  this.currentPullPromise = undefined
201
201
  if (done) {
202
202
  try {
203
+ for (const buffer of this.buffers) controller.enqueue(buffer)
203
204
  controller.close()
204
205
  } catch (err) {
205
206
  // console.error(err)