@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.
Files changed (119) hide show
  1. package/README.md +148 -3
  2. package/dist/engine/index.d.ts +10 -0
  3. package/dist/engine/index.js +2 -0
  4. package/dist/engine/picture-in-picture.d.ts +27 -0
  5. package/dist/engine/playback.d.ts +45 -0
  6. package/dist/engine/source-buffer.d.ts +12 -0
  7. package/dist/engine/subtitles.d.ts +36 -0
  8. package/dist/engine/thumbnails.d.ts +22 -0
  9. package/dist/engine-Dmc7JSd9.js +470 -0
  10. package/dist/index.d.ts +12 -0
  11. package/dist/index.js +1566 -0
  12. package/dist/react/components/chrome.d.ts +9 -0
  13. package/dist/react/components/control-bar.d.ts +2 -0
  14. package/dist/react/components/overlay.d.ts +4 -0
  15. package/dist/react/components/playback-slider.d.ts +2 -0
  16. package/dist/react/components/progress-bar.d.ts +2 -0
  17. package/dist/react/components/settings.d.ts +2 -0
  18. package/dist/react/components/sound.d.ts +7 -0
  19. package/{build → dist/react}/components/tooltip-display.d.ts +8 -8
  20. package/dist/react/components/volume-slider.d.ts +6 -0
  21. package/dist/react/hooks/use-drag-value.d.ts +23 -0
  22. package/dist/react/hooks/use-picture-in-picture.d.ts +2 -0
  23. package/dist/react/hooks/use-playback.d.ts +6 -0
  24. package/dist/react/hooks/use-thumbnails.d.ts +11 -0
  25. package/dist/react/player.d.ts +25 -0
  26. package/dist/react/source-feature.d.ts +84 -0
  27. package/dist/react/video-player.d.ts +43 -0
  28. package/dist/utils/source.d.ts +30 -0
  29. package/dist/utils/track-label.d.ts +19 -0
  30. package/dist/utils/volume-utils.d.ts +6 -0
  31. package/package.json +49 -37
  32. package/src/lib/engine/index.ts +14 -0
  33. package/src/lib/engine/picture-in-picture.ts +250 -0
  34. package/src/lib/engine/playback.ts +352 -0
  35. package/src/lib/engine/source-buffer.ts +61 -0
  36. package/src/lib/engine/subtitles.ts +210 -0
  37. package/src/lib/engine/thumbnails.ts +137 -0
  38. package/src/lib/globals.d.ts +8 -0
  39. package/src/lib/index.tsx +36 -0
  40. package/src/lib/react/components/chrome.tsx +126 -0
  41. package/src/{components → lib/react/components}/control-bar.tsx +74 -96
  42. package/src/lib/react/components/overlay.tsx +121 -0
  43. package/src/{components → lib/react/components}/playback-slider.tsx +30 -52
  44. package/src/{components → lib/react/components}/progress-bar.tsx +128 -41
  45. package/src/lib/react/components/settings.tsx +391 -0
  46. package/src/lib/react/components/sound.tsx +133 -0
  47. package/src/{components → lib/react/components}/tooltip-display.tsx +11 -8
  48. package/src/{components → lib/react/components}/volume-slider.tsx +32 -46
  49. package/src/lib/react/hooks/use-drag-value.ts +73 -0
  50. package/src/lib/react/hooks/use-picture-in-picture.ts +36 -0
  51. package/src/lib/react/hooks/use-playback.ts +134 -0
  52. package/src/lib/react/hooks/use-thumbnails.ts +77 -0
  53. package/src/lib/react/player.ts +20 -0
  54. package/src/lib/react/source-feature.ts +90 -0
  55. package/src/lib/react/video-player.tsx +119 -0
  56. package/src/lib/utils/source.ts +60 -0
  57. package/src/lib/utils/track-label.ts +36 -0
  58. package/src/lib/utils/volume-utils.ts +13 -0
  59. package/build/components/chrome.d.ts +0 -7
  60. package/build/components/control-bar.d.ts +0 -6
  61. package/build/components/overlay.d.ts +0 -4
  62. package/build/components/playback-slider.d.ts +0 -2
  63. package/build/components/progress-bar.d.ts +0 -1
  64. package/build/components/settings.d.ts +0 -2
  65. package/build/components/sound.d.ts +0 -4
  66. package/build/components/volume-slider.d.ts +0 -6
  67. package/build/index.d.ts +0 -26
  68. package/build/index.js +0 -3416
  69. package/build/main.d.ts +0 -1
  70. package/build/state-machines/data-source.d.ts +0 -27
  71. package/build/state-machines/index.d.ts +0 -34038
  72. package/build/state-machines/media-properties.d.ts +0 -45
  73. package/build/state-machines/media-source.d.ts +0 -34
  74. package/build/state-machines/media.d.ts +0 -8558
  75. package/build/state-machines/subtitles.d.ts +0 -56
  76. package/build/state-machines/thumbnails.d.ts +0 -24
  77. package/build/state-machines/utils.d.ts +0 -26
  78. package/build/utils/actor-utils.d.ts +0 -2
  79. package/build/utils/context.d.ts +0 -14
  80. package/build/utils/index.d.ts +0 -4
  81. package/build/utils/languages.d.ts +0 -260
  82. package/build/utils/mp4box.d.ts +0 -61
  83. package/build/utils/use-local-storage.d.ts +0 -3
  84. package/build/utils/use-scrub.d.ts +0 -11
  85. package/build/utils/volume-utils.d.ts +0 -17
  86. package/build/utils/window-height.d.ts +0 -2
  87. package/src/components/chrome.tsx +0 -95
  88. package/src/components/overlay.tsx +0 -91
  89. package/src/components/settings.tsx +0 -322
  90. package/src/components/sound.tsx +0 -101
  91. package/src/index.tsx +0 -195
  92. package/src/main.tsx +0 -169
  93. package/src/state-machines/data-source.ts +0 -84
  94. package/src/state-machines/index.ts +0 -5
  95. package/src/state-machines/media-properties.ts +0 -82
  96. package/src/state-machines/media-source.ts +0 -129
  97. package/src/state-machines/media.ts +0 -255
  98. package/src/state-machines/subtitles.ts +0 -285
  99. package/src/state-machines/thumbnails.ts +0 -123
  100. package/src/state-machines/utils.ts +0 -94
  101. package/src/utils/actor-utils.ts +0 -19
  102. package/src/utils/context.ts +0 -23
  103. package/src/utils/index.ts +0 -229
  104. package/src/utils/languages.ts +0 -262
  105. package/src/utils/mp4box.ts +0 -74
  106. package/src/utils/use-local-storage.ts +0 -30
  107. package/src/utils/use-scrub.ts +0 -40
  108. package/src/utils/volume-utils.ts +0 -39
  109. package/src/utils/window-height.ts +0 -19
  110. package/src/vite-env.d.ts +0 -1
  111. package/tsconfig.json +0 -28
  112. package/tsconfig.node.json +0 -9
  113. /package/{build → dist}/utils/colors.d.ts +0 -0
  114. /package/{build → dist}/utils/fonts.d.ts +0 -0
  115. /package/{build → dist}/utils/time.d.ts +0 -0
  116. /package/src/{assets → lib/assets}/picture-in-picture.svg +0 -0
  117. /package/src/{utils → lib/utils}/colors.ts +0 -0
  118. /package/src/{utils → lib/utils}/fonts.ts +0 -0
  119. /package/src/{utils → lib/utils}/time.ts +0 -0
@@ -0,0 +1,9 @@
1
+ import type { ReactNode, Ref } from 'react';
2
+ export type ChromeProps = {
3
+ ref?: Ref<HTMLDivElement> | ((element: HTMLDivElement | null) => void);
4
+ onVideoRef: (element: HTMLVideoElement | null) => void;
5
+ onCanvasRef: (element: HTMLCanvasElement | null) => void;
6
+ children?: ReactNode;
7
+ };
8
+ export declare const Chrome: ({ ref, onVideoRef, onCanvasRef, children }: ChromeProps) => import("@emotion/react/jsx-runtime").JSX.Element;
9
+ export default Chrome;
@@ -0,0 +1,2 @@
1
+ export declare const ControlBar: () => import("@emotion/react/jsx-runtime").JSX.Element;
2
+ export default ControlBar;
@@ -0,0 +1,4 @@
1
+ export declare const Overlay: ({ onCanvasRef }: {
2
+ onCanvasRef: (element: HTMLCanvasElement | null) => void;
3
+ }) => import("@emotion/react/jsx-runtime").JSX.Element;
4
+ export default Overlay;
@@ -0,0 +1,2 @@
1
+ export declare const PlaybackSlider: () => import("@emotion/react/jsx-runtime").JSX.Element;
2
+ export default PlaybackSlider;
@@ -0,0 +1,2 @@
1
+ export declare const ProgressBar: () => import("@emotion/react/jsx-runtime").JSX.Element;
2
+ export default ProgressBar;
@@ -0,0 +1,2 @@
1
+ export declare const SettingsAction: () => import("@emotion/react/jsx-runtime").JSX.Element;
2
+ export default SettingsAction;
@@ -0,0 +1,7 @@
1
+ import type { Ref } from 'react';
2
+ export type SoundProps = {
3
+ /** Lands on the button, which is what the control bar attaches its wheel listener to. */
4
+ ref?: Ref<HTMLButtonElement> | ((element: HTMLButtonElement | null) => void);
5
+ };
6
+ export declare const Sound: ({ ref }: SoundProps) => import("@emotion/react/jsx-runtime").JSX.Element;
7
+ export default Sound;
@@ -1,5 +1,10 @@
1
- import { ReactNode } from 'react';
1
+ import type { ReactNode } from 'react';
2
2
  import { PlacesType } from 'react-tooltip';
3
+ export declare enum buttonSize {
4
+ sm = "sm",
5
+ md = "md",
6
+ lg = "lg"
7
+ }
3
8
  interface TooltipDisplayProps {
4
9
  id: string;
5
10
  toolTipText: ReactNode;
@@ -11,10 +16,5 @@ interface TooltipDisplayProps {
11
16
  size?: buttonSize;
12
17
  disabled?: boolean;
13
18
  }
14
- export declare enum buttonSize {
15
- sm = "sm",
16
- md = "md",
17
- lg = "lg"
18
- }
19
- export declare const TooltipDisplay: ({ id, toolTipText, text, delayShow, closeDelay, offset, tooltipPlace, disabled, size }: TooltipDisplayProps) => import("react/jsx-runtime").JSX.Element;
20
- export {};
19
+ export declare const TooltipDisplay: ({ id, toolTipText, text, delayShow, closeDelay, offset, tooltipPlace, disabled, size }: TooltipDisplayProps) => import("@emotion/react/jsx-runtime").JSX.Element;
20
+ export default TooltipDisplay;
@@ -0,0 +1,6 @@
1
+ type VolumeSliderType = {
2
+ value: number;
3
+ onChange: (v: number) => void;
4
+ };
5
+ export declare const VolumeSlider: ({ value, onChange }: VolumeSliderType) => import("@emotion/react/jsx-runtime").JSX.Element;
6
+ export default VolumeSlider;
@@ -0,0 +1,23 @@
1
+ import type { PointerEvent as ReactPointerEvent, RefObject } from 'react';
2
+ export type UseDragValueOptions = {
3
+ /** The element the fraction is measured across. */
4
+ ref: RefObject<HTMLElement | null>;
5
+ /** Called with a 0..1 fraction on press and on every move, and once more on release. */
6
+ onChange: (fraction: number) => void;
7
+ orientation?: 'horizontal' | 'vertical';
8
+ disabled?: boolean;
9
+ };
10
+ /** Press-and-drag over an element, reported as a 0..1 fraction. */
11
+ export declare const useDragValue: ({ ref, onChange, orientation, disabled }: UseDragValueOptions) => {
12
+ dragging: boolean;
13
+ /** Spread onto the element that owns the gesture. */
14
+ handlers: {
15
+ onPointerDown: (event: ReactPointerEvent<HTMLElement>) => void;
16
+ onPointerMove: (event: ReactPointerEvent<HTMLElement>) => void;
17
+ onPointerUp: (event: ReactPointerEvent<HTMLElement>) => void;
18
+ onPointerCancel: (event: ReactPointerEvent<HTMLElement>) => void;
19
+ style: {
20
+ touchAction: 'none';
21
+ };
22
+ };
23
+ };
@@ -0,0 +1,2 @@
1
+ /** Picture in picture with the subtitles composited in. */
2
+ export declare const usePictureInPicture: (video: HTMLVideoElement | null, canvas: HTMLCanvasElement | null) => () => void;
@@ -0,0 +1,6 @@
1
+ import type { MediaPlayerOptions } from '../video-player';
2
+ /**
3
+ * Owns the engine for the life of a source: start, teardown, and every piece of state the pipeline
4
+ * discovers. Nothing is mirrored in React state, so the store is the only place any of it lives.
5
+ */
6
+ export declare const usePlayback: (video: HTMLVideoElement | null, canvas: HTMLCanvasElement | null, options: MediaPlayerOptions) => void;
@@ -0,0 +1,11 @@
1
+ import type { ThumbnailImage } from '../../engine';
2
+ import type { DownloadedRange } from '../source-feature';
3
+ export type UseSeekThumbnailsOptions = {
4
+ publicPath: string;
5
+ workerUrl: string;
6
+ length: number | undefined;
7
+ read: ((offset: number, size: number) => Promise<ArrayBuffer>) | undefined;
8
+ /** When omitted the whole file is treated as readable, which is the case for a local file. */
9
+ downloadedRanges?: DownloadedRange[];
10
+ };
11
+ export declare const useSeekThumbnails: ({ publicPath, workerUrl, length, read, downloadedRanges, }: UseSeekThumbnailsOptions) => ThumbnailImage[];
@@ -0,0 +1,25 @@
1
+ export declare const Player: import("@videojs/react").CreatePlayerResult<import("@videojs/react").PlayerStore<[import("@videojs/react").PlayerFeature<import("@videojs/media").MediaPlaybackState>, import("@videojs/react").PlayerFeature<import("@videojs/media").MediaPlaybackRateState>, import("@videojs/react").PlayerFeature<import("@videojs/media").MediaQualityState>, import("@videojs/react").PlayerFeature<import("@videojs/media").MediaAudioTrackState>, import("@videojs/react").PlayerFeature<import("@videojs/media").MediaVolumeState>, import("@videojs/react").PlayerFeature<import("@videojs/media").MediaTimeState>, import("@videojs/react").PlayerFeature<import("@videojs/media").MediaSourceState>, import("@videojs/react").PlayerFeature<import("@videojs/media").MediaBufferState>, import("@videojs/react").PlayerFeature<import("@videojs/media").MediaFullscreenState>, import("@videojs/react").PlayerFeature<import("@videojs/media").MediaPictureInPictureState>, import("@videojs/react").PlayerFeature<import("@videojs/media").MediaRemotePlaybackState>, import("@videojs/react").PlayerFeature<import("@videojs/media").MediaControlsState>, import("@videojs/react").PlayerFeature<import("@videojs/media").MediaTextTrackState>, import("@videojs/react").PlayerFeature<import("@videojs/media").MediaErrorState>, import("@videojs/react").PlayerFeature<{
2
+ title?: string;
3
+ size?: number;
4
+ downloadedRanges?: import("./source-feature").DownloadedRange[];
5
+ indexes: import("..").MediaIndex[];
6
+ thumbnails: import("..").ThumbnailImage[];
7
+ subtitleStreams: import("..").SubtitleStream[];
8
+ selectedSubtitleStream: number | undefined;
9
+ selectSubtitleStream: (streamIndex: number | undefined) => void;
10
+ audioStreams: import("libav-wasm/build/worker").AudioStream[];
11
+ selectedAudioStream: number;
12
+ selectAudioStream: (streamIndex: number) => void;
13
+ hideUI: boolean;
14
+ setHideUI: (hide: boolean) => void;
15
+ togglePictureInPicture: () => void;
16
+ playbackError: unknown;
17
+ ready: boolean;
18
+ setSourceState: (partial: Partial<import("./source-feature").SourceState>) => void;
19
+ }>]>>;
20
+ /**
21
+ * Typed player state, to be used instead of the `usePlayer` from `@videojs/react`, whose fields come
22
+ * back as `unknown`. With no selector it returns the store without subscribing; with one it subscribes.
23
+ */
24
+ export declare const usePlayer: typeof Player.usePlayer;
25
+ export type PlayerStore = ReturnType<typeof Player.usePlayer>;
@@ -0,0 +1,84 @@
1
+ import type { AudioStream, MediaIndex, SubtitleStream, ThumbnailImage } from '../engine';
2
+ /**
3
+ * A byte span of the file the consumer has in hand, mapped onto the timeline through the keyframe
4
+ * index, because a file's download percentage is not its playback percentage.
5
+ */
6
+ export type DownloadedRange = {
7
+ startByteOffset: number;
8
+ endByteOffset: number;
9
+ };
10
+ /**
11
+ * Everything about the source that the chrome reads, carried on the player store next to the built-in
12
+ * playback state so a component never has to know which of two channels owns a field.
13
+ *
14
+ * The store is the single reader surface; the React layer is the single writer, through
15
+ * `setSourceState`.
16
+ */
17
+ export type SourceState = {
18
+ /** Shown top left over the video. */
19
+ title?: string;
20
+ /** Total byte length of the source. */
21
+ size?: number;
22
+ downloadedRanges?: DownloadedRange[];
23
+ /** Keyframe index of the input, which turns a downloaded byte range into a time range. */
24
+ indexes: MediaIndex[];
25
+ thumbnails: ThumbnailImage[];
26
+ subtitleStreams: SubtitleStream[];
27
+ /** undefined means subtitles are off. */
28
+ selectedSubtitleStream: number | undefined;
29
+ selectSubtitleStream: (streamIndex: number | undefined) => void;
30
+ audioStreams: AudioStream[];
31
+ selectedAudioStream: number;
32
+ selectAudioStream: (streamIndex: number) => void;
33
+ /** Chrome auto-hide. True means the controls, title and cursor are hidden. */
34
+ hideUI: boolean;
35
+ setHideUI: (hide: boolean) => void;
36
+ /** Owned here, not by `pip`: that watches the media element, and the window holds a mirror. */
37
+ togglePictureInPicture: () => void;
38
+ /** Set when the pipeline fails. Cleared when it recovers. */
39
+ playbackError: unknown;
40
+ /** Whether the engine has produced its first media segment. */
41
+ ready: boolean;
42
+ /**
43
+ * The write seam, wired in `attach`. Only the React layer calls it.
44
+ *
45
+ * It is a no-op until the media element attaches. Every caller writes either from an engine
46
+ * callback or after `startPlayback` resolves, both of which are far later than attach, and the one
47
+ * synchronous write is a reset to the values the defaults below already hold.
48
+ */
49
+ setSourceState: (partial: Partial<SourceState>) => void;
50
+ };
51
+ export declare const sourceFeature: import("@videojs/react").PlayerFeature<{
52
+ /** Shown top left over the video. */
53
+ title?: string;
54
+ /** Total byte length of the source. */
55
+ size?: number;
56
+ downloadedRanges?: DownloadedRange[];
57
+ /** Keyframe index of the input, which turns a downloaded byte range into a time range. */
58
+ indexes: MediaIndex[];
59
+ thumbnails: ThumbnailImage[];
60
+ subtitleStreams: SubtitleStream[];
61
+ /** undefined means subtitles are off. */
62
+ selectedSubtitleStream: number | undefined;
63
+ selectSubtitleStream: (streamIndex: number | undefined) => void;
64
+ audioStreams: AudioStream[];
65
+ selectedAudioStream: number;
66
+ selectAudioStream: (streamIndex: number) => void;
67
+ /** Chrome auto-hide. True means the controls, title and cursor are hidden. */
68
+ hideUI: boolean;
69
+ setHideUI: (hide: boolean) => void;
70
+ /** Owned here, not by `pip`: that watches the media element, and the window holds a mirror. */
71
+ togglePictureInPicture: () => void;
72
+ /** Set when the pipeline fails. Cleared when it recovers. */
73
+ playbackError: unknown;
74
+ /** Whether the engine has produced its first media segment. */
75
+ ready: boolean;
76
+ /**
77
+ * The write seam, wired in `attach`. Only the React layer calls it.
78
+ *
79
+ * It is a no-op until the media element attaches. Every caller writes either from an engine
80
+ * callback or after `startPlayback` resolves, both of which are far later than attach, and the one
81
+ * synchronous write is a reset to the values the defaults below already hold.
82
+ */
83
+ setSourceState: (partial: Partial<SourceState>) => void;
84
+ }>;
@@ -0,0 +1,43 @@
1
+ import type { ReactNode } from 'react';
2
+ import type { DownloadedRange } from './source-feature';
3
+ /**
4
+ * The source, read a range at a time: the player never downloads the whole file. Both fields travel
5
+ * together, so passing one without the other is a type error.
6
+ */
7
+ export type MediaPlayerSource = {
8
+ read: (offset: number, size: number) => Promise<ArrayBuffer>;
9
+ size: number;
10
+ } | {
11
+ read?: undefined;
12
+ size?: undefined;
13
+ };
14
+ export type MediaPlayerOptions = MediaPlayerSource & {
15
+ /**
16
+ * Where libav's wasm is served from. BOTH `libav.wasm` and `libav-jspi.wasm` have to be there:
17
+ * libav-wasm picks between them on `WebAssembly.Suspending`, so serving one fails only on the
18
+ * browsers that pick the other.
19
+ */
20
+ publicPath: string;
21
+ libavWorkerUrl: string;
22
+ jassubWorkerUrl: string;
23
+ /** jassub's SIMD build, `jassub-worker-modern.wasm`. */
24
+ jassubWasmUrl: string;
25
+ /**
26
+ * jassub's non-SIMD build, `jassub-worker.wasm`, for Safari before 16.4.
27
+ * Without it subtitles fail outright on those browsers rather than falling back to the slower build.
28
+ */
29
+ jassubLegacyWasmUrl?: string;
30
+ /** Fallback face for `liberation sans`, used when a subtitle track names a font the file does not carry. */
31
+ defaultFontUrl?: string;
32
+ bufferSize?: number;
33
+ autoplay?: boolean;
34
+ title?: string;
35
+ /** Byte spans available, painted on the seekbar and informing the thumbnail generator. */
36
+ downloadedRanges?: DownloadedRange[];
37
+ onSeek?: (fraction: number) => void;
38
+ onPlaybackError?: (error: unknown) => void;
39
+ };
40
+ export declare const MediaPlayer: (options: MediaPlayerOptions & {
41
+ children?: ReactNode;
42
+ }) => import("@emotion/react/jsx-runtime").JSX.Element;
43
+ export default MediaPlayer;
@@ -0,0 +1,30 @@
1
+ declare const fromBlob: ({ blob, name }: {
2
+ blob: Blob;
3
+ name?: string;
4
+ }) => {
5
+ length: number;
6
+ name: string | undefined;
7
+ read: (offset: number, size: number) => Promise<ArrayBuffer>;
8
+ };
9
+ declare const fromUrl: ({ url, length: _length, name, credentials }: {
10
+ url: string;
11
+ length?: number;
12
+ name?: string;
13
+ credentials?: RequestCredentials;
14
+ }) => Promise<{
15
+ length: number;
16
+ name: string | undefined;
17
+ read: (offset: number, size: number) => Promise<ArrayBuffer>;
18
+ }>;
19
+ /** A source resolved down to what the remuxer needs: a total length and a byte-range reader. */
20
+ export type RemuxerInput = {
21
+ length: number;
22
+ name?: string;
23
+ read: (offset: number, size: number) => Promise<ArrayBuffer>;
24
+ };
25
+ export declare const inputToRemuxerInput: (params: Parameters<typeof fromBlob | typeof fromUrl>[0] | {
26
+ length: number;
27
+ name?: string;
28
+ read: (offset: number, size: number) => Promise<ArrayBuffer>;
29
+ }) => Promise<RemuxerInput>;
30
+ export {};
@@ -0,0 +1,19 @@
1
+ export type LabelledTrack = {
2
+ streamIndex: number;
3
+ title: string;
4
+ language: string;
5
+ };
6
+ /**
7
+ * Human name for a track's language tag. `fallback: 'none'` is what makes an unknown tag come back
8
+ * undefined instead of echoing itself, so the caller can fall through to the title.
9
+ */
10
+ export declare const displayLanguage: (language: string | undefined) => string | undefined;
11
+ /**
12
+ * Names a set of tracks for a menu, by language, falling back to the title then the stream index.
13
+ * The title is appended only to break a tie, because on a MultiSub release every title is the same
14
+ * source tag and titling every row gives nine identical entries.
15
+ */
16
+ export declare const labelTracks: <T extends LabelledTrack>(tracks: T[]) => {
17
+ track: T;
18
+ label: string;
19
+ }[];
@@ -0,0 +1,6 @@
1
+ /** Higher values put more of the slider's travel at the quiet end. */
2
+ export declare const VOLUME_EXPONENT = 2;
3
+ /** Slider position (0-1) to gain, on a curve that matches how loudness is perceived. */
4
+ export declare const linearToLogVolume: (linearValue: number) => number;
5
+ /** Gain (0-1) back to slider position. */
6
+ export declare const logToLinearVolume: (logVolume: number) => number;
package/package.json CHANGED
@@ -1,51 +1,63 @@
1
1
  {
2
2
  "name": "@banou/media-player",
3
- "version": "0.6.2",
4
- "description": "",
3
+ "version": "0.7.0",
4
+ "description": "A video player for containers and codecs the browser cannot play natively, remuxed on the fly",
5
5
  "type": "module",
6
- "main": "build/index.js",
6
+ "main": "dist/index.js",
7
+ "types": "dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/index.d.ts",
11
+ "import": "./dist/index.js"
12
+ },
13
+ "./engine": {
14
+ "types": "./dist/engine/index.d.ts",
15
+ "import": "./dist/engine/index.js"
16
+ },
17
+ "./package.json": "./package.json"
18
+ },
7
19
  "files": [
8
- "build",
9
- "tsconfig.json",
10
- "tsconfig.node.json",
11
- "src"
20
+ "dist",
21
+ "src/lib"
12
22
  ],
13
23
  "scripts": {
14
- "dev": "vite --port 4560",
15
- "build-dev": "vite build --watch",
16
- "build": "vite build && npm run types",
17
- "build-for-dev": "vite build && npm run copy-dependencies && npm run types",
18
- "copy-dependencies": "npm run copy-libass && npm run copy-worker && npm run copy-worker-wasm",
19
- "copy-worker": "shx cp node_modules/libav-wasm/build/worker.js build/libav.js",
20
- "copy-worker-wasm": "shx cp node_modules/libav-wasm/build/libav.wasm build/libav.wasm",
21
- "copy-libass": "copyfiles -u 3 ./node_modules/jassub/dist/* build",
22
- "types": "tsc"
24
+ "dev": "npm run copy-assets && vp dev --port 4560",
25
+ "build": "shx rm -rf build/ && npm run copy-assets && vp build",
26
+ "preview": "vp preview",
27
+ "build-lib": "shx rm -rf dist/ && vp build -c vite.lib.config.ts && npm run types",
28
+ "types": "tsc -p tsconfig.lib.json",
29
+ "copy-assets": "shx mkdir -p public && npm run copy-libav && npm run copy-libass",
30
+ "copy-libav": "shx cp node_modules/libav-wasm/build/worker.js public/libav-worker.js && shx cp node_modules/libav-wasm/build/libav.wasm public/libav.wasm && shx cp node_modules/libav-wasm/build/libav-jspi.wasm public/libav-jspi.wasm",
31
+ "copy-libass": "shx cp node_modules/jassub/dist/jassub-worker.js public/jassub-worker.js && shx cp node_modules/jassub/dist/jassub-worker.wasm public/jassub-worker.wasm && shx cp node_modules/jassub/dist/jassub-worker-modern.wasm public/jassub-worker-modern.wasm && shx cp node_modules/jassub/dist/default.woff2 public/default.woff2"
23
32
  },
24
33
  "author": "Banou26",
25
- "devDependencies": {
26
- "@types/node": "^18.11.18",
27
- "@types/react": "^18.0.27",
28
- "@types/react-dom": "^18.0.10",
29
- "@vitejs/plugin-react": "^4.3.4",
30
- "concurrently": "^7.6.0",
31
- "copyfiles": "^2.4.1",
32
- "mime": "^3.0.0",
33
- "shx": "^0.3.4",
34
- "typescript": "^5.8.2",
35
- "vite": "^6.2.1"
36
- },
37
34
  "dependencies": {
35
+ "@videojs/core": "10.0.0-beta.26",
36
+ "@videojs/react": "10.0.0-beta.26",
37
+ "ass-compiler": "^0.1.16",
38
+ "jassub": "^1.8.6",
39
+ "libav-wasm": "^0.8.4",
40
+ "react-feather": "^2.0.10",
41
+ "react-tooltip": "^5.28.0"
42
+ },
43
+ "peerDependencies": {
38
44
  "@emotion/react": "^11.14.0",
39
- "@xstate/react": "^5.0.1",
40
- "ass-compiler": "^0.1.15",
41
- "jassub": "^1.7.18",
42
- "libav-wasm": "^0.6.2",
43
- "osra": "^0.1.2",
44
- "p-queue": "^7.3.4",
45
+ "react": "^19.0.0"
46
+ },
47
+ "devDependencies": {
48
+ "@emotion/react": "^11.14.0",
49
+ "@types/node": "^22.20.1",
50
+ "@types/react": "^19.0.0",
51
+ "@types/react-dom": "^19.0.0",
52
+ "@vitejs/plugin-react": "^6.0.3",
45
53
  "react": "^19.0.0",
46
54
  "react-dom": "^19.0.0",
47
- "react-feather": "^2.0.10",
48
- "react-tooltip": "^5.28.0",
49
- "xstate": "^5.19.1"
55
+ "shx": "^0.3.4",
56
+ "typescript": "^7.0.2",
57
+ "vite": "npm:@voidzero-dev/vite-plus-core@0.2.4",
58
+ "vite-plus": "0.2.4"
59
+ },
60
+ "overrides": {
61
+ "vite": "npm:@voidzero-dev/vite-plus-core@0.2.4"
50
62
  }
51
63
  }
@@ -0,0 +1,14 @@
1
+ export { startPlayback, terminateRemuxer, DEFAULT_BUFFER_SIZE } from './playback'
2
+ export type { PlaybackOptions, PlaybackController, MediaIndex, AudioStream } from './playback'
3
+
4
+ export { createSubtitleRenderer, SUBTITLES_OFF } from './subtitles'
5
+ export type { SubtitleRenderer, SubtitleRendererOptions, SubtitleStream } from './subtitles'
6
+
7
+ export { createThumbnailGenerator } from './thumbnails'
8
+ export type { ThumbnailGenerator, ThumbnailGeneratorOptions, ThumbnailImage } from './thumbnails'
9
+
10
+ export { getTimeRanges, updateSourceBuffer } from './source-buffer'
11
+ export type { TimeRange } from './source-buffer'
12
+
13
+ export { createPictureInPicture } from './picture-in-picture'
14
+ export type { PictureInPictureController, PictureInPictureOptions } from './picture-in-picture'