softbuilders-react-video-player 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- package/LICENSE +21 -0
- package/README.md +126 -0
- package/dist/components/BigPlayButton/index.d.ts +9 -0
- package/dist/components/BigPlayButton/index.js +15 -0
- package/dist/components/BigPlayButton/index.js.map +1 -0
- package/dist/components/BufferTracker/index.d.ts +3 -0
- package/dist/components/BufferTracker/index.js +16 -0
- package/dist/components/BufferTracker/index.js.map +1 -0
- package/dist/components/ChapterTooltip/index.d.ts +11 -0
- package/dist/components/ChapterTooltip/index.js +36 -0
- package/dist/components/ChapterTooltip/index.js.map +1 -0
- package/dist/components/ChaptersPanal/index.d.ts +7 -0
- package/dist/components/ChaptersPanal/index.js +19 -0
- package/dist/components/ChaptersPanal/index.js.map +1 -0
- package/dist/components/ControlBar/index.d.ts +15 -0
- package/dist/components/ControlBar/index.js +64 -0
- package/dist/components/ControlBar/index.js.map +1 -0
- package/dist/components/CreateNoteMenu/index.d.ts +6 -0
- package/dist/components/CreateNoteMenu/index.js +29 -0
- package/dist/components/CreateNoteMenu/index.js.map +1 -0
- package/dist/components/CurrentTimeLabel/index.d.ts +4 -0
- package/dist/components/CurrentTimeLabel/index.js +10 -0
- package/dist/components/CurrentTimeLabel/index.js.map +1 -0
- package/dist/components/CurrentTimeTracker/index.d.ts +3 -0
- package/dist/components/CurrentTimeTracker/index.js +15 -0
- package/dist/components/CurrentTimeTracker/index.js.map +1 -0
- package/dist/components/Menu/index.d.ts +6 -0
- package/dist/components/Menu/index.js +11 -0
- package/dist/components/Menu/index.js.map +1 -0
- package/dist/components/MenuButton/index.d.ts +8 -0
- package/dist/components/MenuButton/index.js +31 -0
- package/dist/components/MenuButton/index.js.map +1 -0
- package/dist/components/NoteTooltip/index.d.ts +10 -0
- package/dist/components/NoteTooltip/index.js +24 -0
- package/dist/components/NoteTooltip/index.js.map +1 -0
- package/dist/components/NotesPanal/index.d.ts +7 -0
- package/dist/components/NotesPanal/index.js +17 -0
- package/dist/components/NotesPanal/index.js.map +1 -0
- package/dist/components/QualityMenu/index.d.ts +4 -0
- package/dist/components/QualityMenu/index.js +53 -0
- package/dist/components/QualityMenu/index.js.map +1 -0
- package/dist/components/Slider/index.d.ts +10 -0
- package/dist/components/Slider/index.js +22 -0
- package/dist/components/Slider/index.js.map +1 -0
- package/dist/components/Slider/style.css +15 -0
- package/dist/components/SoftBuildersVideoPlayer/index.d.ts +13 -0
- package/dist/components/SoftBuildersVideoPlayer/index.js +55 -0
- package/dist/components/SoftBuildersVideoPlayer/index.js.map +1 -0
- package/dist/components/SubtitleMenu/index.d.ts +4 -0
- package/dist/components/SubtitleMenu/index.js +54 -0
- package/dist/components/SubtitleMenu/index.js.map +1 -0
- package/dist/components/TimeSlider/index.d.ts +7 -0
- package/dist/components/TimeSlider/index.js +69 -0
- package/dist/components/TimeSlider/index.js.map +1 -0
- package/dist/components/TimeSliderContainer/index.d.ts +8 -0
- package/dist/components/TimeSliderContainer/index.js +14 -0
- package/dist/components/TimeSliderContainer/index.js.map +1 -0
- package/dist/components/Tooltip/index.d.ts +7 -0
- package/dist/components/Tooltip/index.js +8 -0
- package/dist/components/Tooltip/index.js.map +1 -0
- package/dist/components/VideoPlayerComponent/index.d.ts +17 -0
- package/dist/components/VideoPlayerComponent/index.js +140 -0
- package/dist/components/VideoPlayerComponent/index.js.map +1 -0
- package/dist/components/VideoPlayerComponent/provider.d.ts +18 -0
- package/dist/components/VideoPlayerComponent/provider.js +36 -0
- package/dist/components/VideoPlayerComponent/provider.js.map +1 -0
- package/dist/components/VideoPlayerComponent/style/style.css +36 -0
- package/dist/components/VolumeSlider/index.d.ts +4 -0
- package/dist/components/VolumeSlider/index.js +28 -0
- package/dist/components/VolumeSlider/index.js.map +1 -0
- package/dist/icons/index.d.ts +14 -0
- package/dist/icons/index.js +15 -0
- package/dist/icons/index.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -0
- package/dist/styles/tailwind.css +778 -0
- package/dist/types.d.ts +33 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/dist/utils/index.d.ts +2 -0
- package/dist/utils/index.js +51 -0
- package/dist/utils/index.js.map +1 -0
- package/package.json +37 -0
package/dist/types.d.ts
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
export type SoftBuildersVideoPlayerSource = {
|
2
|
+
src: string;
|
3
|
+
type?: string;
|
4
|
+
label: string;
|
5
|
+
};
|
6
|
+
export type SoftBuildersVideoPlayerTrack = {
|
7
|
+
kind: "captions";
|
8
|
+
src: string;
|
9
|
+
srclang: string;
|
10
|
+
label: string;
|
11
|
+
memeType: "text/vtt" | "text/srt";
|
12
|
+
default?: boolean;
|
13
|
+
};
|
14
|
+
export type SoftBuildersVideoPlayerOptions = {
|
15
|
+
autoplay?: boolean;
|
16
|
+
controls?: boolean;
|
17
|
+
fluid?: boolean;
|
18
|
+
muted?: boolean;
|
19
|
+
poster?: string;
|
20
|
+
sources: SoftBuildersVideoPlayerSource[];
|
21
|
+
tracks: SoftBuildersVideoPlayerTrack[];
|
22
|
+
width?: number;
|
23
|
+
height?: number;
|
24
|
+
};
|
25
|
+
export interface SoftBuildersVideoPlayerNote {
|
26
|
+
time: number;
|
27
|
+
label: string;
|
28
|
+
}
|
29
|
+
export interface SoftBuildersVideoPlayerChapter {
|
30
|
+
startTime: number;
|
31
|
+
endTime: number;
|
32
|
+
title: string;
|
33
|
+
}
|
package/dist/types.js
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""}
|
@@ -0,0 +1,51 @@
|
|
1
|
+
export const durationFormater = (seconds) => {
|
2
|
+
seconds = Math.floor(seconds);
|
3
|
+
const hours = Math.floor(seconds / 3600);
|
4
|
+
const minutes = Math.floor((seconds % 3600) / 60);
|
5
|
+
const secs = seconds % 60;
|
6
|
+
if (hours > 0) {
|
7
|
+
return `${String(hours).padStart(2, "0")}:${String(minutes).padStart(2, "0")}:${String(secs).padStart(2, "0")}`;
|
8
|
+
}
|
9
|
+
else {
|
10
|
+
return `${String(minutes).padStart(2, "0")}:${String(secs).padStart(2, "0")}`;
|
11
|
+
}
|
12
|
+
};
|
13
|
+
const SRTtoVTT = (srt) => {
|
14
|
+
// Normalize line breaks and split into lines
|
15
|
+
const lines = srt.split(/\r?\n/).filter((line) => line.trim() !== "");
|
16
|
+
// Prepare VTT content
|
17
|
+
let vttContent = "WEBVTT\n\n";
|
18
|
+
let currentEntry = "";
|
19
|
+
lines.forEach((line) => {
|
20
|
+
if (/^\d+$/.test(line)) {
|
21
|
+
// Ignore index lines
|
22
|
+
return;
|
23
|
+
}
|
24
|
+
const timestampMatch = line.match(/(\d{2}:\d{2}:\d{2}),(\d{3}) --> (\d{2}:\d{2}:\d{2}),(\d{3})/);
|
25
|
+
if (timestampMatch) {
|
26
|
+
if (currentEntry) {
|
27
|
+
vttContent += currentEntry.trim() + "\n\n"; // Add previous entry
|
28
|
+
}
|
29
|
+
// Replace commas with dots in timestamps and concatenate the groups
|
30
|
+
currentEntry = `${timestampMatch[1]}.${timestampMatch[2]} --> ${timestampMatch[3]}.${timestampMatch[4]}\n`;
|
31
|
+
}
|
32
|
+
else if (currentEntry) {
|
33
|
+
// Add subtitle line to the current entry
|
34
|
+
currentEntry += line + "\n";
|
35
|
+
}
|
36
|
+
});
|
37
|
+
if (currentEntry) {
|
38
|
+
vttContent += currentEntry.trim(); // Add last entry
|
39
|
+
}
|
40
|
+
return vttContent.trim();
|
41
|
+
};
|
42
|
+
export const convertSRTtoVTT = async (srtLink) => {
|
43
|
+
const response = await fetch(srtLink);
|
44
|
+
const srtText = await response.text();
|
45
|
+
const vttText = SRTtoVTT(srtText);
|
46
|
+
// Create a Blob URL for the VTT
|
47
|
+
const blob = new Blob([vttText], { type: "text/vtt" });
|
48
|
+
const vttUrl = URL.createObjectURL(blob);
|
49
|
+
return vttUrl;
|
50
|
+
};
|
51
|
+
//# sourceMappingURL=index.js.map
|
@@ -0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AM,MAAM,GAAG,GAAG,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC;IACzC,OAAO,MAAM,CAAC;AAChB,CAAC,CAAC"}
|
package/package.json
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
{
|
2
|
+
"name": "softbuilders-react-video-player",
|
3
|
+
"description": "Standalone video player component",
|
4
|
+
"version": "1.0.0",
|
5
|
+
"main": "dist/index.js",
|
6
|
+
"types": "dist/index.d.ts",
|
7
|
+
"files": [
|
8
|
+
"dist",
|
9
|
+
"dist/styles/tailwind.css"
|
10
|
+
],
|
11
|
+
"scripts": {
|
12
|
+
"build:css": "npx postcss src/styles/tailwind.css -o dist/styles/tailwind.css && npx postcss src/components/Slider/style.css -o dist/components/Slider/style.css && npx postcss src/components/VideoPlayerComponent/style/style.css -o dist/components/VideoPlayerComponent/style/style.css",
|
13
|
+
"build:css:watch": "npx postcss src/styles/tailwind.css -o dist/styles/tailwind.css --watch && npx postcss src/components/Slider/style.css -o dist/components/Slider/style.css --watch && npx postcss src/components/VideoPlayerComponent/style/style.css -o dist/components/VideoPlayerComponent/style/style.css --watch",
|
14
|
+
"build": "npm run build:css && tsc",
|
15
|
+
"build:watch": "tsc --watch",
|
16
|
+
"start": "concurrently \"npm run build:css:watch\" \"npm run build:watch\""
|
17
|
+
},
|
18
|
+
"keywords": [],
|
19
|
+
"author": "",
|
20
|
+
"license": "ISC",
|
21
|
+
"peerDependencies": {
|
22
|
+
"react": "^18.3.1",
|
23
|
+
"react-dom": "^18.3.1",
|
24
|
+
"video.js": "^8.18.0"
|
25
|
+
},
|
26
|
+
"devDependencies": {
|
27
|
+
"@svgr/webpack": "^8.1.0",
|
28
|
+
"@types/react": "^18.3.5",
|
29
|
+
"@types/react-dom": "^18.3.0",
|
30
|
+
"autoprefixer": "^10.4.20",
|
31
|
+
"concurrently": "^9.0.1",
|
32
|
+
"postcss": "^8.4.45",
|
33
|
+
"postcss-cli": "^11.0.0",
|
34
|
+
"tailwindcss": "^3.4.11",
|
35
|
+
"typescript": "^5.6.2"
|
36
|
+
}
|
37
|
+
}
|