@banou/media-player 0.6.2 → 0.7.0
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 +148 -3
- package/dist/engine/index.d.ts +10 -0
- package/dist/engine/index.js +2 -0
- package/dist/engine/picture-in-picture.d.ts +27 -0
- package/dist/engine/playback.d.ts +45 -0
- package/dist/engine/source-buffer.d.ts +12 -0
- package/dist/engine/subtitles.d.ts +36 -0
- package/dist/engine/thumbnails.d.ts +22 -0
- package/dist/engine-Dmc7JSd9.js +470 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.js +1566 -0
- package/dist/react/components/chrome.d.ts +9 -0
- package/dist/react/components/control-bar.d.ts +2 -0
- package/dist/react/components/overlay.d.ts +4 -0
- package/dist/react/components/playback-slider.d.ts +2 -0
- package/dist/react/components/progress-bar.d.ts +2 -0
- package/dist/react/components/settings.d.ts +2 -0
- package/dist/react/components/sound.d.ts +7 -0
- package/{build → dist/react}/components/tooltip-display.d.ts +8 -8
- package/dist/react/components/volume-slider.d.ts +6 -0
- package/dist/react/hooks/use-drag-value.d.ts +23 -0
- package/dist/react/hooks/use-picture-in-picture.d.ts +2 -0
- package/dist/react/hooks/use-playback.d.ts +6 -0
- package/dist/react/hooks/use-thumbnails.d.ts +11 -0
- package/dist/react/player.d.ts +25 -0
- package/dist/react/source-feature.d.ts +84 -0
- package/dist/react/video-player.d.ts +43 -0
- package/dist/utils/source.d.ts +30 -0
- package/dist/utils/track-label.d.ts +19 -0
- package/dist/utils/volume-utils.d.ts +6 -0
- package/package.json +49 -37
- package/src/lib/engine/index.ts +14 -0
- package/src/lib/engine/picture-in-picture.ts +250 -0
- package/src/lib/engine/playback.ts +352 -0
- package/src/lib/engine/source-buffer.ts +61 -0
- package/src/lib/engine/subtitles.ts +210 -0
- package/src/lib/engine/thumbnails.ts +137 -0
- package/src/lib/globals.d.ts +8 -0
- package/src/lib/index.tsx +36 -0
- package/src/lib/react/components/chrome.tsx +126 -0
- package/src/{components → lib/react/components}/control-bar.tsx +74 -96
- package/src/lib/react/components/overlay.tsx +121 -0
- package/src/{components → lib/react/components}/playback-slider.tsx +30 -52
- package/src/{components → lib/react/components}/progress-bar.tsx +128 -41
- package/src/lib/react/components/settings.tsx +391 -0
- package/src/lib/react/components/sound.tsx +133 -0
- package/src/{components → lib/react/components}/tooltip-display.tsx +11 -8
- package/src/{components → lib/react/components}/volume-slider.tsx +32 -46
- package/src/lib/react/hooks/use-drag-value.ts +73 -0
- package/src/lib/react/hooks/use-picture-in-picture.ts +36 -0
- package/src/lib/react/hooks/use-playback.ts +134 -0
- package/src/lib/react/hooks/use-thumbnails.ts +77 -0
- package/src/lib/react/player.ts +20 -0
- package/src/lib/react/source-feature.ts +90 -0
- package/src/lib/react/video-player.tsx +119 -0
- package/src/lib/utils/source.ts +60 -0
- package/src/lib/utils/track-label.ts +36 -0
- package/src/lib/utils/volume-utils.ts +13 -0
- package/build/components/chrome.d.ts +0 -7
- package/build/components/control-bar.d.ts +0 -6
- package/build/components/overlay.d.ts +0 -4
- package/build/components/playback-slider.d.ts +0 -2
- package/build/components/progress-bar.d.ts +0 -1
- package/build/components/settings.d.ts +0 -2
- package/build/components/sound.d.ts +0 -4
- package/build/components/volume-slider.d.ts +0 -6
- package/build/index.d.ts +0 -26
- package/build/index.js +0 -3416
- package/build/main.d.ts +0 -1
- package/build/state-machines/data-source.d.ts +0 -27
- package/build/state-machines/index.d.ts +0 -34038
- package/build/state-machines/media-properties.d.ts +0 -45
- package/build/state-machines/media-source.d.ts +0 -34
- package/build/state-machines/media.d.ts +0 -8558
- package/build/state-machines/subtitles.d.ts +0 -56
- package/build/state-machines/thumbnails.d.ts +0 -24
- package/build/state-machines/utils.d.ts +0 -26
- package/build/utils/actor-utils.d.ts +0 -2
- package/build/utils/context.d.ts +0 -14
- package/build/utils/index.d.ts +0 -4
- package/build/utils/languages.d.ts +0 -260
- package/build/utils/mp4box.d.ts +0 -61
- package/build/utils/use-local-storage.d.ts +0 -3
- package/build/utils/use-scrub.d.ts +0 -11
- package/build/utils/volume-utils.d.ts +0 -17
- package/build/utils/window-height.d.ts +0 -2
- package/src/components/chrome.tsx +0 -95
- package/src/components/overlay.tsx +0 -91
- package/src/components/settings.tsx +0 -322
- package/src/components/sound.tsx +0 -101
- package/src/index.tsx +0 -195
- package/src/main.tsx +0 -169
- package/src/state-machines/data-source.ts +0 -84
- package/src/state-machines/index.ts +0 -5
- package/src/state-machines/media-properties.ts +0 -82
- package/src/state-machines/media-source.ts +0 -129
- package/src/state-machines/media.ts +0 -255
- package/src/state-machines/subtitles.ts +0 -285
- package/src/state-machines/thumbnails.ts +0 -123
- package/src/state-machines/utils.ts +0 -94
- package/src/utils/actor-utils.ts +0 -19
- package/src/utils/context.ts +0 -23
- package/src/utils/index.ts +0 -229
- package/src/utils/languages.ts +0 -262
- package/src/utils/mp4box.ts +0 -74
- package/src/utils/use-local-storage.ts +0 -30
- package/src/utils/use-scrub.ts +0 -40
- package/src/utils/volume-utils.ts +0 -39
- package/src/utils/window-height.ts +0 -19
- package/src/vite-env.d.ts +0 -1
- package/tsconfig.json +0 -28
- package/tsconfig.node.json +0 -9
- /package/{build → dist}/utils/colors.d.ts +0 -0
- /package/{build → dist}/utils/fonts.d.ts +0 -0
- /package/{build → dist}/utils/time.d.ts +0 -0
- /package/src/{assets → lib/assets}/picture-in-picture.svg +0 -0
- /package/src/{utils → lib/utils}/colors.ts +0 -0
- /package/src/{utils → lib/utils}/fonts.ts +0 -0
- /package/src/{utils → lib/utils}/time.ts +0 -0
package/src/utils/mp4box.ts
DELETED
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
declare module "mp4box" {
|
|
2
|
-
|
|
3
|
-
export interface MP4MediaTrack {
|
|
4
|
-
id: number
|
|
5
|
-
created: Date
|
|
6
|
-
modified: Date
|
|
7
|
-
movie_duration: number
|
|
8
|
-
layer: number
|
|
9
|
-
alternate_group: number
|
|
10
|
-
volume: number
|
|
11
|
-
track_width: number
|
|
12
|
-
track_height: number
|
|
13
|
-
timescale: number
|
|
14
|
-
duration: number
|
|
15
|
-
bitrate: number
|
|
16
|
-
codec: string
|
|
17
|
-
language: string
|
|
18
|
-
nb_samples: number
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export interface MP4VideoData {
|
|
22
|
-
width: number
|
|
23
|
-
height: number
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
export interface MP4VideoTrack extends MP4MediaTrack {
|
|
27
|
-
video: MP4VideoData
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
export interface MP4AudioData {
|
|
31
|
-
sample_rate: number
|
|
32
|
-
channel_count: number
|
|
33
|
-
sample_size: number
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
export interface MP4AudioTrack extends MP4MediaTrack {
|
|
37
|
-
audio: MP4AudioData
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
export type MP4Track = MP4VideoTrack | MP4AudioTrack
|
|
41
|
-
|
|
42
|
-
export interface MP4Info {
|
|
43
|
-
duration: number
|
|
44
|
-
timescale: number
|
|
45
|
-
fragment_duration: number
|
|
46
|
-
isFragmented: boolean
|
|
47
|
-
isProgressive: boolean
|
|
48
|
-
hasIOD: boolean
|
|
49
|
-
brands: string[]
|
|
50
|
-
created: Date
|
|
51
|
-
modified: Date
|
|
52
|
-
tracks: MP4Track[]
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
export type MP4ArrayBuffer = ArrayBuffer & { fileStart: number }
|
|
56
|
-
|
|
57
|
-
export interface MP4File {
|
|
58
|
-
|
|
59
|
-
onMoovStart?: () => void
|
|
60
|
-
onReady?: (info: MP4Info) => void
|
|
61
|
-
onError?: (e: Error) => void
|
|
62
|
-
|
|
63
|
-
appendBuffer(data: MP4ArrayBuffer): number
|
|
64
|
-
start(): void
|
|
65
|
-
stop(): void
|
|
66
|
-
flush(): void
|
|
67
|
-
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
export function createFile(): MP4File
|
|
71
|
-
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
export { }
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { useEffect, useState } from 'react'
|
|
2
|
-
|
|
3
|
-
export const useLocalStorage = <T,>(name: string, defaultValue?: T) => {
|
|
4
|
-
const [storageValue, setStorageValue] = useState(() => localStorage.getItem(name) ?? defaultValue)
|
|
5
|
-
|
|
6
|
-
const updateStorage = (newValue: string) => {
|
|
7
|
-
localStorage.setItem(name, newValue)
|
|
8
|
-
setStorageValue(newValue)
|
|
9
|
-
window.dispatchEvent(new Event('storage'))
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
useEffect(() => {
|
|
13
|
-
const syncLocalStorage = () => {
|
|
14
|
-
const item = localStorage.getItem(name)
|
|
15
|
-
setStorageValue(item ?? defaultValue)
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
window.addEventListener('storage', syncLocalStorage)
|
|
19
|
-
return () => {
|
|
20
|
-
window.removeEventListener('storage', syncLocalStorage)
|
|
21
|
-
}
|
|
22
|
-
}, [name])
|
|
23
|
-
|
|
24
|
-
return [storageValue, updateStorage] as const
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
export default useLocalStorage
|
|
28
|
-
|
|
29
|
-
export type booleanType = 'true' | 'false' | undefined
|
|
30
|
-
|
package/src/utils/use-scrub.ts
DELETED
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import type { MouseEventHandler, RefObject } from 'react'
|
|
2
|
-
|
|
3
|
-
import { useState, useEffect } from 'react'
|
|
4
|
-
|
|
5
|
-
export default ({ ref, defaultValue }: { ref: RefObject<HTMLElement>, defaultValue?: number }) => {
|
|
6
|
-
const [value, setValue] = useState(defaultValue)
|
|
7
|
-
const [scrubbing, setScrubbing] = useState(false)
|
|
8
|
-
|
|
9
|
-
const scrub: MouseEventHandler<HTMLDivElement> = (ev) => {
|
|
10
|
-
setScrubbing(true)
|
|
11
|
-
if (!ref.current) return
|
|
12
|
-
const { clientX: x } = ev
|
|
13
|
-
const { left, right } = ref.current.getBoundingClientRect()
|
|
14
|
-
setValue(Math.min(Math.max(((x - left) / (right - left)), 0), 1))
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
useEffect(() => {
|
|
18
|
-
if (!scrubbing) return
|
|
19
|
-
const mouseUp = () => setScrubbing(false)
|
|
20
|
-
const mouseMove = (ev: globalThis.MouseEvent) => {
|
|
21
|
-
if (!ref.current) return
|
|
22
|
-
const { clientX: x } = ev
|
|
23
|
-
const { left, right } = ref.current.getBoundingClientRect()
|
|
24
|
-
setValue(Math.min(Math.max(((x - left) / (right - left)), 0), 1))
|
|
25
|
-
}
|
|
26
|
-
document.addEventListener('mousemove', mouseMove)
|
|
27
|
-
document.addEventListener('mouseup', mouseUp)
|
|
28
|
-
return () => {
|
|
29
|
-
document.removeEventListener('mousemove', mouseMove)
|
|
30
|
-
document.removeEventListener('mouseup', mouseUp)
|
|
31
|
-
}
|
|
32
|
-
}, [scrubbing])
|
|
33
|
-
|
|
34
|
-
return {
|
|
35
|
-
value,
|
|
36
|
-
scrubbing,
|
|
37
|
-
scrub,
|
|
38
|
-
setValue
|
|
39
|
-
}
|
|
40
|
-
}
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
// Constants for logarithmic scaling
|
|
2
|
-
const MIN_VOLUME = 0.0001 // Avoid zero which would give -Infinity when taking log
|
|
3
|
-
const MAX_VOLUME = 1.0
|
|
4
|
-
|
|
5
|
-
// Defines how "curved" the logarithmic response is
|
|
6
|
-
// Higher values = more dramatic volume change at the low end
|
|
7
|
-
export const VOLUME_EXPONENT = 2.0
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* Converts a linear slider value (0-1) to logarithmic volume scale
|
|
11
|
-
* Uses formula: volume = minVolume * (maxVolume/minVolume)^position
|
|
12
|
-
*
|
|
13
|
-
* @param linearValue Linear slider position (0-1)
|
|
14
|
-
* @returns Logarithmic volume value (0-1)
|
|
15
|
-
*/
|
|
16
|
-
export const linearToLogVolume = (linearValue: number): number => {
|
|
17
|
-
// Ensure value is within range
|
|
18
|
-
const normalizedLinear = Math.max(MIN_VOLUME, Math.min(MAX_VOLUME, linearValue))
|
|
19
|
-
|
|
20
|
-
// Calculate using the formula: volume = minVolume * (maxVolume/minVolume)^position
|
|
21
|
-
// We can also use a simpler formula: Math.pow(normalizedLinear, VOLUME_EXPONENT)
|
|
22
|
-
// Which gives a good perceptual curve with proper scaling
|
|
23
|
-
return Math.pow(normalizedLinear, VOLUME_EXPONENT)
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* Converts a logarithmic volume (0-1) back to linear slider position (0-1)
|
|
28
|
-
* Inverse of the logarithmic formula
|
|
29
|
-
*
|
|
30
|
-
* @param logVolume Logarithmic volume (0-1)
|
|
31
|
-
* @returns Linear slider position (0-1)
|
|
32
|
-
*/
|
|
33
|
-
export const logToLinearVolume = (logVolume: number): number => {
|
|
34
|
-
// Ensure value is within range
|
|
35
|
-
const normalizedLog = Math.max(MIN_VOLUME, Math.min(MAX_VOLUME, logVolume))
|
|
36
|
-
|
|
37
|
-
// Inverse of our simplified formula
|
|
38
|
-
return Math.pow(normalizedLog, MAX_VOLUME/VOLUME_EXPONENT)
|
|
39
|
-
}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { useEffect, useState } from 'react'
|
|
2
|
-
|
|
3
|
-
const useWindowSize = () => {
|
|
4
|
-
const [windowHeight, setWindowHeight] = useState(window.innerHeight)
|
|
5
|
-
const [windowWidth, setWindowWidth] = useState(window.innerWidth)
|
|
6
|
-
useEffect(() => {
|
|
7
|
-
const handleResize = () => {
|
|
8
|
-
setWindowHeight(window.innerHeight)
|
|
9
|
-
setWindowWidth(window.innerWidth)
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
window.addEventListener('resize', handleResize)
|
|
13
|
-
|
|
14
|
-
return () => { window.removeEventListener('resize', handleResize) }
|
|
15
|
-
}, [])
|
|
16
|
-
return [windowHeight, windowWidth]
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
export default useWindowSize
|
package/src/vite-env.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
/// <reference types="vite/client" />
|
package/tsconfig.json
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
"target": "ESNext",
|
|
4
|
-
"outDir": "build",
|
|
5
|
-
"lib": ["DOM", "DOM.Iterable", "ESNext"],
|
|
6
|
-
"allowJs": false,
|
|
7
|
-
"skipLibCheck": true,
|
|
8
|
-
"esModuleInterop": false,
|
|
9
|
-
"allowSyntheticDefaultImports": true,
|
|
10
|
-
"strict": true,
|
|
11
|
-
"forceConsistentCasingInFileNames": true,
|
|
12
|
-
"module": "ESNext",
|
|
13
|
-
"moduleResolution": "Node",
|
|
14
|
-
"resolveJsonModule": true,
|
|
15
|
-
"isolatedModules": true,
|
|
16
|
-
"noEmit": false,
|
|
17
|
-
"declaration": true,
|
|
18
|
-
"emitDeclarationOnly": true,
|
|
19
|
-
"jsx": "react-jsx",
|
|
20
|
-
"paths": {
|
|
21
|
-
"mp4box": ["./src/utils/mp4box.ts"]
|
|
22
|
-
},
|
|
23
|
-
"types": []
|
|
24
|
-
},
|
|
25
|
-
"include": ["src"],
|
|
26
|
-
"exclude": ["node_modules"],
|
|
27
|
-
"references": [{ "path": "./tsconfig.node.json" }]
|
|
28
|
-
}
|
package/tsconfig.node.json
DELETED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|