@halibegic/react-video-player 0.0.1 → 0.0.3
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 +43 -2
- package/dist/components/live-player.d.ts +9 -1
- package/dist/components/player/live-player/live-player-event-check.d.ts +8 -0
- package/dist/components/player/live-player/live-player-go-live.d.ts +6 -0
- package/dist/components/player/live-player/live-player-playback-indicator.d.ts +2 -0
- package/dist/components/player/live-player/live-player-playback.d.ts +2 -0
- package/dist/components/player/live-player/live-player-progress.d.ts +2 -0
- package/dist/components/player/live-player/live-player-provider.d.ts +7 -0
- package/dist/components/player/live-player/live-player-remaining-time.d.ts +2 -0
- package/dist/components/player/live-player/live-player-tech.d.ts +5 -0
- package/dist/components/player/player-hls-engine.d.ts +6 -0
- package/dist/components/player/player-tech.d.ts +1 -1
- package/dist/components/player/ui/icons/arrow-right-icon.d.ts +2 -0
- package/dist/components/player/ui/icons/fullscreen-enter-icon.d.ts +2 -0
- package/dist/components/player/ui/icons/fullscreen-exit-icon.d.ts +2 -0
- package/dist/components/player/ui/icons/pause-icon.d.ts +2 -0
- package/dist/components/player/ui/icons/play-icon.d.ts +2 -0
- package/dist/components/player/ui/icons/volume-max-icon.d.ts +2 -0
- package/dist/components/player/ui/icons/volume-min-icon.d.ts +2 -0
- package/dist/components/player/ui/icons/volume-mute-icon.d.ts +2 -0
- package/dist/components/player/ui/player-button.d.ts +5 -2
- package/dist/components/player/ui/player-controls.styles.d.ts +8 -0
- package/dist/components/player/ui/player-fullscreen.d.ts +1 -1
- package/dist/components/player/ui/player-idle-check.d.ts +3 -0
- package/dist/components/player/ui/player-playback-indicator.d.ts +4 -0
- package/dist/components/player/ui/player-progress.styles.d.ts +6 -0
- package/dist/components/player/ui/player-remaining-time.styles.d.ts +6 -0
- package/dist/components/player/ui/player-slider.d.ts +3 -5
- package/dist/components/player/ui/player-spinner.d.ts +3 -0
- package/dist/components/player/ui/player-volume.d.ts +2 -0
- package/dist/components/vod-player/vod-player-playback-indicator.d.ts +2 -0
- package/dist/components/vod-player/vod-player-playback.d.ts +2 -0
- package/dist/components/vod-player/vod-player-remaining-time.d.ts +2 -0
- package/dist/components/vod-player/vod-player-watch-history.d.ts +5 -0
- package/dist/components/vod-player.d.ts +5 -1
- package/dist/config/player.d.ts +3 -5
- package/dist/hooks/use-interval.d.ts +2 -0
- package/dist/hooks/use-isomorphic-layout-effect.d.ts +3 -0
- package/dist/hooks/use-state-refresh.d.ts +2 -0
- package/dist/index-DkJtizQx.js +3265 -0
- package/dist/index-DkJtizQx.js.map +1 -0
- package/dist/react-video-player.es.js +1 -1
- package/dist/react-video-player.umd.js +235 -104
- package/dist/react-video-player.umd.js.map +1 -1
- package/dist/stores/live-player-store.d.ts +21 -0
- package/dist/stores/player-store.d.ts +1 -1
- package/dist/utils/dom.d.ts +11 -0
- package/dist/utils/player.d.ts +4 -3
- package/dist/vod-player-watch-history-D3ZHK2x3.js +37 -0
- package/dist/vod-player-watch-history-D3ZHK2x3.js.map +1 -0
- package/package.json +3 -8
- package/dist/components/player/tech/player-dash-tech.d.ts +0 -6
- package/dist/components/player/tech/player-hls-tech.d.ts +0 -6
- package/dist/index-qaN7n0xb.js +0 -1982
- package/dist/index-qaN7n0xb.js.map +0 -1
- package/dist/player-dash-tech-XlldPZU_.js +0 -50
- package/dist/player-dash-tech-XlldPZU_.js.map +0 -1
- package/dist/player-hls-tech-BKkTLteW.js +0 -29
- package/dist/player-hls-tech-BKkTLteW.js.map +0 -1
- /package/dist/{components/hooks → hooks}/use-debounce.d.ts +0 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { PropsWithChildren } from 'react';
|
|
2
|
+
type State = {
|
|
3
|
+
delay: number;
|
|
4
|
+
startDate: Date;
|
|
5
|
+
endDate: Date;
|
|
6
|
+
startTime: number;
|
|
7
|
+
endTime: number;
|
|
8
|
+
};
|
|
9
|
+
type Actions = {
|
|
10
|
+
setDelay: (delay: number) => void;
|
|
11
|
+
setStartDate: (startDate: Date) => void;
|
|
12
|
+
setEndDate: (endDate: Date) => void;
|
|
13
|
+
};
|
|
14
|
+
type LivePlayerStore = State & Actions;
|
|
15
|
+
type LivePlayerStoreProviderProps = PropsWithChildren & {
|
|
16
|
+
startDate: Date;
|
|
17
|
+
endDate: Date;
|
|
18
|
+
};
|
|
19
|
+
declare const LivePlayerStoreProvider: ({ children, startDate, endDate, }: LivePlayerStoreProviderProps) => import("react/jsx-runtime").JSX.Element;
|
|
20
|
+
declare const useLivePlayerStore: <T>(selector: (state: LivePlayerStore) => T) => T;
|
|
21
|
+
export { LivePlayerStoreProvider, useLivePlayerStore };
|
|
@@ -70,6 +70,6 @@ type RefState = {
|
|
|
70
70
|
};
|
|
71
71
|
type RefSlice = RefState;
|
|
72
72
|
type PlayerStore = PlaybackSlice & IdleLockSlice & FullscreenSlice & AssetSlice & RefSlice;
|
|
73
|
-
declare
|
|
73
|
+
declare function PlayerStoreProvider({ children }: PropsWithChildren): import("react/jsx-runtime").JSX.Element;
|
|
74
74
|
declare const usePlayerStore: <T>(selector: (state: PlayerStore) => T) => T;
|
|
75
75
|
export { PlayerStoreProvider, usePlayerStore };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
declare function offset(element: HTMLElement): DOMRect | {
|
|
2
|
+
left: number;
|
|
3
|
+
right: number;
|
|
4
|
+
top: number;
|
|
5
|
+
bottom: number;
|
|
6
|
+
width: number;
|
|
7
|
+
height: number;
|
|
8
|
+
};
|
|
9
|
+
declare function width(element: HTMLElement): number;
|
|
10
|
+
declare function height(element: HTMLElement): number;
|
|
11
|
+
export { height, offset, width };
|
package/dist/utils/player.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
declare
|
|
3
|
-
|
|
1
|
+
declare const getLiveDelay: (startTime: number, skipTime: number) => number;
|
|
2
|
+
declare const getLiveCurrentTime: (startTime: number, delay: number) => number;
|
|
3
|
+
declare const getLiveDurationTime: (startTime: number, endTime: number) => number;
|
|
4
|
+
export { getLiveCurrentTime, getLiveDelay, getLiveDurationTime };
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { u as n, a as y } from "./index-DkJtizQx.js";
|
|
2
|
+
import { useRef as T, useCallback as o, useEffect as p } from "react";
|
|
3
|
+
const h = 60, g = 95;
|
|
4
|
+
function W({ storageKey: e }) {
|
|
5
|
+
const s = n((t) => t.currentTime), a = n((t) => t.duration), f = n((t) => t.isPlaying), i = n((t) => t.setStartTime), c = T(!1), u = o(() => {
|
|
6
|
+
window.localStorage.setItem(
|
|
7
|
+
e,
|
|
8
|
+
JSON.stringify({
|
|
9
|
+
currentTime: s,
|
|
10
|
+
duration: a
|
|
11
|
+
})
|
|
12
|
+
);
|
|
13
|
+
}, [s, a, e]), l = o(() => {
|
|
14
|
+
const t = window.localStorage.getItem(e);
|
|
15
|
+
if (t) {
|
|
16
|
+
const r = JSON.parse(t);
|
|
17
|
+
return {
|
|
18
|
+
startTime: r.currentTime,
|
|
19
|
+
progress: r.currentTime / r.duration * 100
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
return { startTime: null, progress: null };
|
|
23
|
+
}, [e]), d = o(() => {
|
|
24
|
+
s < h || u();
|
|
25
|
+
}, [s, u]), m = o(() => {
|
|
26
|
+
if (c.current) return;
|
|
27
|
+
const { progress: t, startTime: r } = l();
|
|
28
|
+
r && t && t < g && (i(r), c.current = !0);
|
|
29
|
+
}, [l, i]);
|
|
30
|
+
return y(() => d(), f ? 1e3 : null), p(() => {
|
|
31
|
+
m();
|
|
32
|
+
}, [m]), null;
|
|
33
|
+
}
|
|
34
|
+
export {
|
|
35
|
+
W as default
|
|
36
|
+
};
|
|
37
|
+
//# sourceMappingURL=vod-player-watch-history-D3ZHK2x3.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vod-player-watch-history-D3ZHK2x3.js","sources":["../src/config/player.ts","../src/components/vod-player/vod-player-watch-history.tsx"],"sourcesContent":["const WatchHistoryMinTime = 60;\nconst WatchHistoryMaxPercent = 95;\n\nexport { WatchHistoryMaxPercent, WatchHistoryMinTime };\n","import { WatchHistoryMaxPercent, WatchHistoryMinTime } from \"@/config/player\";\nimport { useInterval } from \"@/hooks/use-interval\";\nimport { usePlayerStore } from \"@/stores/player-store\";\nimport { useCallback, useEffect, useRef } from \"react\";\n\ntype VodPlayerWatchHistoryProps = {\n storageKey: string;\n};\n\nfunction VodPlayerWatchHistory({ storageKey }: VodPlayerWatchHistoryProps) {\n const currentTime = usePlayerStore((s) => s.currentTime);\n const duration = usePlayerStore((s) => s.duration);\n const isPlaying = usePlayerStore((s) => s.isPlaying);\n const setStartTime = usePlayerStore((s) => s.setStartTime);\n const isReadyRef = useRef<boolean>(false);\n\n const setWatchHistory = useCallback(() => {\n window.localStorage.setItem(\n storageKey,\n JSON.stringify({\n currentTime,\n duration,\n })\n );\n }, [currentTime, duration, storageKey]);\n\n const getWatchHistory = useCallback(() => {\n const history = window.localStorage.getItem(storageKey);\n\n if (history) {\n const data = JSON.parse(history);\n\n return {\n startTime: data.currentTime,\n progress: (data.currentTime / data.duration) * 100,\n };\n }\n\n return { startTime: null, progress: null };\n }, [storageKey]);\n\n const handleWatchHistory = useCallback(() => {\n if (currentTime < WatchHistoryMinTime) return;\n\n setWatchHistory();\n }, [currentTime, setWatchHistory]);\n\n const prepareData = useCallback(() => {\n if (isReadyRef.current) return;\n\n const { progress, startTime } = getWatchHistory();\n\n if (startTime && progress && progress < WatchHistoryMaxPercent) {\n setStartTime(startTime);\n\n isReadyRef.current = true;\n }\n }, [getWatchHistory, setStartTime]);\n\n useInterval(() => handleWatchHistory(), isPlaying ? 1000 : null);\n\n useEffect(() => {\n prepareData();\n }, [prepareData]);\n\n return null;\n}\n\nexport default VodPlayerWatchHistory;\n"],"names":["WatchHistoryMinTime","WatchHistoryMaxPercent","VodPlayerWatchHistory","storageKey","currentTime","usePlayerStore","s","duration","isPlaying","setStartTime","isReadyRef","useRef","setWatchHistory","useCallback","getWatchHistory","history","data","handleWatchHistory","prepareData","progress","startTime","useInterval","useEffect"],"mappings":";;AAAA,MAAMA,IAAsB,IACtBC,IAAyB;ACQ/B,SAASC,EAAsB,EAAE,YAAAC,KAA0C;AACzE,QAAMC,IAAcC,EAAe,CAACC,MAAMA,EAAE,WAAW,GACjDC,IAAWF,EAAe,CAACC,MAAMA,EAAE,QAAQ,GAC3CE,IAAYH,EAAe,CAACC,MAAMA,EAAE,SAAS,GAC7CG,IAAeJ,EAAe,CAACC,MAAMA,EAAE,YAAY,GACnDI,IAAaC,EAAgB,EAAK,GAElCC,IAAkBC,EAAY,MAAM;AACxC,WAAO,aAAa;AAAA,MAClBV;AAAA,MACA,KAAK,UAAU;AAAA,QACb,aAAAC;AAAA,QACA,UAAAG;AAAA,MAAA,CACD;AAAA,IAAA;AAAA,EAEL,GAAG,CAACH,GAAaG,GAAUJ,CAAU,CAAC,GAEhCW,IAAkBD,EAAY,MAAM;AACxC,UAAME,IAAU,OAAO,aAAa,QAAQZ,CAAU;AAEtD,QAAIY,GAAS;AACX,YAAMC,IAAO,KAAK,MAAMD,CAAO;AAE/B,aAAO;AAAA,QACL,WAAWC,EAAK;AAAA,QAChB,UAAWA,EAAK,cAAcA,EAAK,WAAY;AAAA,MAAA;AAAA,IAEnD;AAEA,WAAO,EAAE,WAAW,MAAM,UAAU,KAAA;AAAA,EACtC,GAAG,CAACb,CAAU,CAAC,GAETc,IAAqBJ,EAAY,MAAM;AAC3C,IAAIT,IAAcJ,KAElBY,EAAA;AAAA,EACF,GAAG,CAACR,GAAaQ,CAAe,CAAC,GAE3BM,IAAcL,EAAY,MAAM;AACpC,QAAIH,EAAW,QAAS;AAExB,UAAM,EAAE,UAAAS,GAAU,WAAAC,EAAA,IAAcN,EAAA;AAEhC,IAAIM,KAAaD,KAAYA,IAAWlB,MACtCQ,EAAaW,CAAS,GAEtBV,EAAW,UAAU;AAAA,EAEzB,GAAG,CAACI,GAAiBL,CAAY,CAAC;AAElC,SAAAY,EAAY,MAAMJ,EAAA,GAAsBT,IAAY,MAAO,IAAI,GAE/Dc,EAAU,MAAM;AACd,IAAAJ,EAAA;AAAA,EACF,GAAG,CAACA,CAAW,CAAC,GAET;AACT;"}
|
package/package.json
CHANGED
|
@@ -1,15 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@halibegic/react-video-player",
|
|
3
|
-
"description": "A React video player library with HLS
|
|
4
|
-
"version": "0.0.
|
|
3
|
+
"description": "A React video player library with HLS support for VOD and Live streaming",
|
|
4
|
+
"version": "0.0.3",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"react",
|
|
8
8
|
"video-player",
|
|
9
9
|
"hls",
|
|
10
10
|
"hls.js",
|
|
11
|
-
"dash",
|
|
12
|
-
"dash.js",
|
|
13
11
|
"video-player",
|
|
14
12
|
"streaming",
|
|
15
13
|
"vod",
|
|
@@ -52,12 +50,9 @@
|
|
|
52
50
|
"react-dom": "^18.0.0 || ^19.0.0"
|
|
53
51
|
},
|
|
54
52
|
"dependencies": {
|
|
53
|
+
"@radix-ui/react-slider": "^1.3.6",
|
|
55
54
|
"@types/styled-components": "^5.1.34",
|
|
56
|
-
"dashjs": "^5.0.3",
|
|
57
55
|
"hls.js": "^1.6.11",
|
|
58
|
-
"install": "^0.13.0",
|
|
59
|
-
"lucide-react": "^0.542.0",
|
|
60
|
-
"npm": "^11.5.2",
|
|
61
56
|
"styled-components": "^6.1.19",
|
|
62
57
|
"zustand": "^5.0.8"
|
|
63
58
|
},
|