@banou/media-player 0.0.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 +13 -0
- package/build/chrome/bottom.d.ts +20 -0
- package/build/chrome/index.d.ts +26 -0
- package/build/chrome/overlay.d.ts +9 -0
- package/build/index.d.ts +48 -0
- package/build/index.js +2725 -0
- package/build/languages.d.ts +260 -0
- package/build/main.d.ts +1 -0
- package/build/mp4box.d.ts +61 -0
- package/build/use-local-storage.d.ts +6 -0
- package/build/use-scrub.d.ts +10 -0
- package/build/utils.d.ts +13 -0
- package/package.json +49 -0
- package/src/chrome/bottom.tsx +651 -0
- package/src/chrome/index.tsx +197 -0
- package/src/chrome/overlay.tsx +104 -0
- package/src/index.tsx +597 -0
- package/src/languages.ts +262 -0
- package/src/main.tsx +187 -0
- package/src/mp4box.ts +74 -0
- package/src/use-local-storage.ts +32 -0
- package/src/use-scrub.ts +39 -0
- package/src/utils.ts +385 -0
- package/src/vite-env.d.ts +1 -0
- package/tsconfig.json +26 -0
- package/tsconfig.node.json +9 -0
package/README.md
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
## Media Player
|
|
2
|
+
|
|
3
|
+
A player that somehow manages to playback MKV files
|
|
4
|
+
|
|
5
|
+
# Things to fix
|
|
6
|
+
- Everytime a new text starts being rendered by libass-wasm (JavascriptSubtitlesOctopus), we might drop a few video frames?
|
|
7
|
+
- might wanna use https://www.radix-ui.com/
|
|
8
|
+
- PRETTY IMPORTANT The player randomly stops working completly after a normal seek, no errors thrown, just happens after a seek, check it out
|
|
9
|
+
- https://9u526jgufnpw9yo6aerstjtvkh31xm.sdbx.app/watch/anilist:140596,mal:50197/mal:50197-1/nyaa:1621740 has subtitles that switch from time to time, subtitle index is kept but array items change indexes
|
|
10
|
+
|
|
11
|
+
Todo: make the UI composable components, useable without the actual video player, useful for custom UI embedding on top of players like youtube, ect...
|
|
12
|
+
|
|
13
|
+
Take inspiration from https://github.com/cookpete/react-player
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { Dispatch, HTMLAttributes, SetStateAction } from 'react';
|
|
2
|
+
import type { ChromeOptions } from '.';
|
|
3
|
+
import type { FKNVideoControl, Subtitle, TransmuxError } from '..';
|
|
4
|
+
export type BottomOptions = {
|
|
5
|
+
duration?: number;
|
|
6
|
+
currentTime?: number;
|
|
7
|
+
togglePlay: () => void;
|
|
8
|
+
isSubtitleMenuHidden: boolean;
|
|
9
|
+
setIsSubtitleMenuHidden: Dispatch<SetStateAction<boolean>>;
|
|
10
|
+
isErrorMenuHidden: boolean;
|
|
11
|
+
setIsErrorMenuHidden: Dispatch<SetStateAction<boolean>>;
|
|
12
|
+
setCurrentSubtitleTrack: Dispatch<SetStateAction<number | undefined>>;
|
|
13
|
+
isFullscreen: boolean;
|
|
14
|
+
toggleFullscreen: () => void;
|
|
15
|
+
subtitleTrack: Subtitle | undefined;
|
|
16
|
+
errors: TransmuxError[];
|
|
17
|
+
customControls?: FKNVideoControl[];
|
|
18
|
+
} & Pick<ChromeOptions, 'seek' | 'setVolume' | 'loadedTime' | 'isPlaying' | 'tracks' | 'pictureInPicture'> & HTMLAttributes<HTMLDivElement>;
|
|
19
|
+
declare const _default: ({ duration, currentTime, togglePlay, seek, setVolume, isSubtitleMenuHidden, setIsSubtitleMenuHidden, isErrorMenuHidden, setIsErrorMenuHidden, setCurrentSubtitleTrack, loadedTime, isPlaying, tracks, isFullscreen, toggleFullscreen, subtitleTrack, pictureInPicture, errors, customControls, ...rest }: BottomOptions) => JSX.Element;
|
|
20
|
+
export default _default;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { HTMLAttributes, MutableRefObject, ReactNode } from 'react';
|
|
2
|
+
import type { Attachment, FKNVideoControl, Subtitle, TransmuxError } from '..';
|
|
3
|
+
export type ChromeOptions = {
|
|
4
|
+
customOverlay?: ReactNode;
|
|
5
|
+
isPlaying?: boolean;
|
|
6
|
+
loading?: boolean;
|
|
7
|
+
duration?: number;
|
|
8
|
+
loadedTime?: [number, number];
|
|
9
|
+
currentTime?: number;
|
|
10
|
+
pictureInPicture: () => void;
|
|
11
|
+
fullscreen: () => void;
|
|
12
|
+
play: () => void;
|
|
13
|
+
seek: (time: number) => void;
|
|
14
|
+
getVolume: () => number | undefined;
|
|
15
|
+
setVolume: (volume: number) => void;
|
|
16
|
+
attachments: Attachment[] | undefined;
|
|
17
|
+
tracks: Subtitle[];
|
|
18
|
+
video: MutableRefObject<HTMLVideoElement | undefined>;
|
|
19
|
+
errors: TransmuxError[];
|
|
20
|
+
customControls?: FKNVideoControl[];
|
|
21
|
+
libassWorkerUrl: string;
|
|
22
|
+
wasmUrl: string;
|
|
23
|
+
needsInitialInteraction?: boolean;
|
|
24
|
+
} & HTMLAttributes<HTMLDivElement>;
|
|
25
|
+
declare const _default: ({ customOverlay, isPlaying, loading, duration, loadedTime, currentTime, pictureInPicture, fullscreen, play, seek, getVolume, setVolume, attachments, tracks, video, errors, customControls, libassWorkerUrl, wasmUrl, needsInitialInteraction, ...rest }: ChromeOptions) => JSX.Element;
|
|
26
|
+
export default _default;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { ClassAttributes } from 'react';
|
|
2
|
+
export type OverlayOptions = {
|
|
3
|
+
loading?: boolean;
|
|
4
|
+
togglePlay: (ev: any) => void;
|
|
5
|
+
setCanvasRef: ClassAttributes<HTMLCanvasElement>['ref'];
|
|
6
|
+
needsInitialInteraction?: boolean;
|
|
7
|
+
};
|
|
8
|
+
declare const _default: ({ loading, needsInitialInteraction, togglePlay, setCanvasRef }: OverlayOptions) => JSX.Element;
|
|
9
|
+
export default _default;
|
package/build/index.d.ts
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import type { ReactNode, VideoHTMLAttributes } from 'react';
|
|
2
|
+
import { makeTransmuxer as libavMakeTransmuxer } from 'libav-wasm';
|
|
3
|
+
export type TransmuxError = {
|
|
4
|
+
critical: boolean;
|
|
5
|
+
message: string;
|
|
6
|
+
count: number;
|
|
7
|
+
};
|
|
8
|
+
export type Subtitle = {
|
|
9
|
+
title: string;
|
|
10
|
+
language: string;
|
|
11
|
+
data: string;
|
|
12
|
+
};
|
|
13
|
+
export type Attachment = {
|
|
14
|
+
filename: string;
|
|
15
|
+
mimetype: string;
|
|
16
|
+
data: Uint8Array;
|
|
17
|
+
};
|
|
18
|
+
type Chunk = {
|
|
19
|
+
offset: number;
|
|
20
|
+
buffer: Uint8Array;
|
|
21
|
+
pts: number;
|
|
22
|
+
duration: number;
|
|
23
|
+
pos: number;
|
|
24
|
+
};
|
|
25
|
+
export type FKNVideoControlOptions = {};
|
|
26
|
+
export type FKNVideoControl = (args: FKNVideoControlOptions) => JSX.Element;
|
|
27
|
+
export type FKNVideoOptions = {
|
|
28
|
+
customOverlay?: ReactNode;
|
|
29
|
+
baseBufferSize?: number;
|
|
30
|
+
size?: number;
|
|
31
|
+
fetch: (offset: number, size: number) => Promise<Response>;
|
|
32
|
+
customControls?: FKNVideoControl[];
|
|
33
|
+
publicPath: string;
|
|
34
|
+
wasmUrl: string;
|
|
35
|
+
libavWorkerUrl: string;
|
|
36
|
+
libavWorkerOptions?: WorkerOptions;
|
|
37
|
+
libassWorkerUrl: string;
|
|
38
|
+
makeTransmuxer?: typeof libavMakeTransmuxer;
|
|
39
|
+
};
|
|
40
|
+
export type HeaderChunk = Chunk & {
|
|
41
|
+
buffer: {
|
|
42
|
+
buffer: {
|
|
43
|
+
fileStart: number;
|
|
44
|
+
};
|
|
45
|
+
};
|
|
46
|
+
};
|
|
47
|
+
declare const FKNVideo: import("react").ForwardRefExoticComponent<VideoHTMLAttributes<HTMLInputElement> & FKNVideoOptions & import("react").RefAttributes<HTMLVideoElement>>;
|
|
48
|
+
export default FKNVideo;
|