@xrift/world-components 0.21.13 → 0.22.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/dist/components/LiveVideoPlayer/components/ControlPanel/LiveIndicator.d.ts +8 -0
- package/dist/components/LiveVideoPlayer/components/ControlPanel/LiveIndicator.d.ts.map +1 -0
- package/dist/components/LiveVideoPlayer/{LiveIndicator.js → components/ControlPanel/LiveIndicator.js} +5 -5
- package/dist/components/LiveVideoPlayer/components/ControlPanel/LiveIndicator.js.map +1 -0
- package/dist/components/LiveVideoPlayer/components/ControlPanel/index.d.ts +16 -0
- package/dist/components/LiveVideoPlayer/components/ControlPanel/index.d.ts.map +1 -0
- package/dist/components/LiveVideoPlayer/components/ControlPanel/index.js +28 -0
- package/dist/components/LiveVideoPlayer/components/ControlPanel/index.js.map +1 -0
- package/dist/components/LiveVideoPlayer/components/LiveVideoTexture.d.ts +14 -0
- package/dist/components/LiveVideoPlayer/components/LiveVideoTexture.d.ts.map +1 -0
- package/dist/components/LiveVideoPlayer/components/LiveVideoTexture.js +18 -0
- package/dist/components/LiveVideoPlayer/components/LiveVideoTexture.js.map +1 -0
- package/dist/components/LiveVideoPlayer/components/index.d.ts +3 -0
- package/dist/components/LiveVideoPlayer/components/index.d.ts.map +1 -0
- package/dist/components/LiveVideoPlayer/components/index.js +3 -0
- package/dist/components/LiveVideoPlayer/components/index.js.map +1 -0
- package/dist/components/LiveVideoPlayer/hooks/useHlsVideo/__tests__/utils.test.d.ts +2 -0
- package/dist/components/LiveVideoPlayer/hooks/useHlsVideo/__tests__/utils.test.d.ts.map +1 -0
- package/dist/components/LiveVideoPlayer/hooks/useHlsVideo/__tests__/utils.test.js +196 -0
- package/dist/components/LiveVideoPlayer/hooks/useHlsVideo/__tests__/utils.test.js.map +1 -0
- package/dist/components/LiveVideoPlayer/hooks/useHlsVideo/classes/HlsJsPlayer.d.ts +17 -0
- package/dist/components/LiveVideoPlayer/hooks/useHlsVideo/classes/HlsJsPlayer.d.ts.map +1 -0
- package/dist/components/LiveVideoPlayer/hooks/useHlsVideo/classes/HlsJsPlayer.js +73 -0
- package/dist/components/LiveVideoPlayer/hooks/useHlsVideo/classes/HlsJsPlayer.js.map +1 -0
- package/dist/components/LiveVideoPlayer/hooks/useHlsVideo/classes/NativeHlsPlayer.d.ts +14 -0
- package/dist/components/LiveVideoPlayer/hooks/useHlsVideo/classes/NativeHlsPlayer.d.ts.map +1 -0
- package/dist/components/LiveVideoPlayer/hooks/useHlsVideo/classes/NativeHlsPlayer.js +46 -0
- package/dist/components/LiveVideoPlayer/hooks/useHlsVideo/classes/NativeHlsPlayer.js.map +1 -0
- package/dist/components/LiveVideoPlayer/hooks/useHlsVideo/classes/RecoveryTracker.d.ts +21 -0
- package/dist/components/LiveVideoPlayer/hooks/useHlsVideo/classes/RecoveryTracker.d.ts.map +1 -0
- package/dist/components/LiveVideoPlayer/hooks/useHlsVideo/classes/RecoveryTracker.js +54 -0
- package/dist/components/LiveVideoPlayer/hooks/useHlsVideo/classes/RecoveryTracker.js.map +1 -0
- package/dist/components/LiveVideoPlayer/hooks/useHlsVideo/classes/__tests__/HlsJsPlayer.test.d.ts +2 -0
- package/dist/components/LiveVideoPlayer/hooks/useHlsVideo/classes/__tests__/HlsJsPlayer.test.d.ts.map +1 -0
- package/dist/components/LiveVideoPlayer/hooks/useHlsVideo/classes/__tests__/HlsJsPlayer.test.js +146 -0
- package/dist/components/LiveVideoPlayer/hooks/useHlsVideo/classes/__tests__/HlsJsPlayer.test.js.map +1 -0
- package/dist/components/LiveVideoPlayer/hooks/useHlsVideo/classes/__tests__/NativeHlsPlayer.test.d.ts +2 -0
- package/dist/components/LiveVideoPlayer/hooks/useHlsVideo/classes/__tests__/NativeHlsPlayer.test.d.ts.map +1 -0
- package/dist/components/LiveVideoPlayer/hooks/useHlsVideo/classes/__tests__/NativeHlsPlayer.test.js +94 -0
- package/dist/components/LiveVideoPlayer/hooks/useHlsVideo/classes/__tests__/NativeHlsPlayer.test.js.map +1 -0
- package/dist/components/LiveVideoPlayer/hooks/useHlsVideo/classes/__tests__/RecoveryTracker.test.d.ts +2 -0
- package/dist/components/LiveVideoPlayer/hooks/useHlsVideo/classes/__tests__/RecoveryTracker.test.d.ts.map +1 -0
- package/dist/components/LiveVideoPlayer/hooks/useHlsVideo/classes/__tests__/RecoveryTracker.test.js +74 -0
- package/dist/components/LiveVideoPlayer/hooks/useHlsVideo/classes/__tests__/RecoveryTracker.test.js.map +1 -0
- package/dist/components/LiveVideoPlayer/hooks/useHlsVideo/index.d.ts +31 -0
- package/dist/components/LiveVideoPlayer/hooks/useHlsVideo/index.d.ts.map +1 -0
- package/dist/components/LiveVideoPlayer/hooks/useHlsVideo/index.js +108 -0
- package/dist/components/LiveVideoPlayer/hooks/useHlsVideo/index.js.map +1 -0
- package/dist/components/LiveVideoPlayer/hooks/useHlsVideo/types.d.ts +34 -0
- package/dist/components/LiveVideoPlayer/hooks/useHlsVideo/types.d.ts.map +1 -0
- package/dist/components/LiveVideoPlayer/hooks/useHlsVideo/types.js +2 -0
- package/dist/components/LiveVideoPlayer/hooks/useHlsVideo/types.js.map +1 -0
- package/dist/components/LiveVideoPlayer/hooks/useHlsVideo/utils.d.ts +15 -0
- package/dist/components/LiveVideoPlayer/hooks/useHlsVideo/utils.d.ts.map +1 -0
- package/dist/components/LiveVideoPlayer/hooks/useHlsVideo/utils.js +62 -0
- package/dist/components/LiveVideoPlayer/hooks/useHlsVideo/utils.js.map +1 -0
- package/dist/components/LiveVideoPlayer/hooks/useLiveVideoPlayer/index.d.ts +25 -0
- package/dist/components/LiveVideoPlayer/hooks/useLiveVideoPlayer/index.d.ts.map +1 -0
- package/dist/components/LiveVideoPlayer/hooks/useLiveVideoPlayer/index.js +97 -0
- package/dist/components/LiveVideoPlayer/hooks/useLiveVideoPlayer/index.js.map +1 -0
- package/dist/components/LiveVideoPlayer/hooks/useLiveVideoPlayer.d.ts +25 -0
- package/dist/components/LiveVideoPlayer/hooks/useLiveVideoPlayer.d.ts.map +1 -0
- package/dist/components/LiveVideoPlayer/hooks/useLiveVideoPlayer.js +97 -0
- package/dist/components/LiveVideoPlayer/hooks/useLiveVideoPlayer.js.map +1 -0
- package/dist/components/LiveVideoPlayer/index.d.ts +20 -3
- package/dist/components/LiveVideoPlayer/index.d.ts.map +1 -1
- package/dist/components/LiveVideoPlayer/index.js +16 -154
- package/dist/components/LiveVideoPlayer/index.js.map +1 -1
- package/dist/components/LiveVideoPlayer/types.d.ts +0 -69
- package/dist/components/LiveVideoPlayer/types.d.ts.map +1 -1
- package/dist/components/Video180Sphere/EyeView.d.ts +14 -0
- package/dist/components/Video180Sphere/EyeView.d.ts.map +1 -0
- package/dist/components/Video180Sphere/EyeView.js +77 -0
- package/dist/components/Video180Sphere/EyeView.js.map +1 -0
- package/dist/components/Video180Sphere/index.d.ts +19 -0
- package/dist/components/Video180Sphere/index.d.ts.map +1 -0
- package/dist/components/Video180Sphere/index.js +90 -0
- package/dist/components/Video180Sphere/index.js.map +1 -0
- package/dist/components/Video180Sphere/types.d.ts +35 -0
- package/dist/components/Video180Sphere/types.d.ts.map +1 -0
- package/dist/components/Video180Sphere/types.js +2 -0
- package/dist/components/Video180Sphere/types.js.map +1 -0
- package/dist/components/VideoPlayer/ControlPanel.d.ts +1 -1
- package/dist/components/VideoPlayer/ControlPanel.d.ts.map +1 -1
- package/dist/components/VideoPlayer/ControlPanel.js +20 -9
- package/dist/components/VideoPlayer/ControlPanel.js.map +1 -1
- package/dist/components/VideoPlayer/ProgressBar.d.ts.map +1 -1
- package/dist/components/VideoPlayer/ProgressBar.js +2 -1
- package/dist/components/VideoPlayer/ProgressBar.js.map +1 -1
- package/dist/components/VideoPlayer/__tests__/utils.test.d.ts +2 -0
- package/dist/components/VideoPlayer/__tests__/utils.test.d.ts.map +1 -0
- package/dist/components/VideoPlayer/__tests__/utils.test.js +23 -0
- package/dist/components/VideoPlayer/__tests__/utils.test.js.map +1 -0
- package/dist/components/VideoPlayer/components/ControlPanel.d.ts +18 -0
- package/dist/components/VideoPlayer/components/ControlPanel.d.ts.map +1 -0
- package/dist/components/VideoPlayer/components/ControlPanel.js +34 -0
- package/dist/components/VideoPlayer/components/ControlPanel.js.map +1 -0
- package/dist/components/VideoPlayer/components/ProgressBar.d.ts +12 -0
- package/dist/components/VideoPlayer/components/ProgressBar.d.ts.map +1 -0
- package/dist/components/VideoPlayer/components/ProgressBar.js +21 -0
- package/dist/components/VideoPlayer/components/ProgressBar.js.map +1 -0
- package/dist/components/VideoPlayer/components/index.d.ts +3 -0
- package/dist/components/VideoPlayer/components/index.d.ts.map +1 -0
- package/dist/components/VideoPlayer/components/index.js +3 -0
- package/dist/components/VideoPlayer/components/index.js.map +1 -0
- package/dist/components/VideoPlayer/index.d.ts +20 -3
- package/dist/components/VideoPlayer/index.d.ts.map +1 -1
- package/dist/components/VideoPlayer/index.js +29 -89
- package/dist/components/VideoPlayer/index.js.map +1 -1
- package/dist/components/VideoPlayer/types.d.ts +1 -28
- package/dist/components/VideoPlayer/types.d.ts.map +1 -1
- package/dist/components/VideoPlayer/utils.d.ts +0 -27
- package/dist/components/VideoPlayer/utils.d.ts.map +1 -1
- package/dist/components/VideoPlayer/utils.js +0 -28
- package/dist/components/VideoPlayer/utils.js.map +1 -1
- package/dist/components/VideoPlayer/utils.test.js +1 -87
- package/dist/components/VideoPlayer/utils.test.js.map +1 -1
- package/dist/components/commons/ErrorBoundary/index.d.ts +18 -0
- package/dist/components/commons/ErrorBoundary/index.d.ts.map +1 -0
- package/dist/components/commons/ErrorBoundary/index.js +22 -0
- package/dist/components/commons/ErrorBoundary/index.js.map +1 -0
- package/dist/components/commons/IconButton/index.d.ts +23 -0
- package/dist/components/commons/IconButton/index.d.ts.map +1 -0
- package/dist/components/commons/IconButton/index.js +12 -0
- package/dist/components/commons/IconButton/index.js.map +1 -0
- package/dist/components/commons/PlaceholderScreen/index.d.ts +9 -0
- package/dist/components/commons/PlaceholderScreen/index.d.ts.map +1 -0
- package/dist/components/commons/PlaceholderScreen/index.js +6 -0
- package/dist/components/commons/PlaceholderScreen/index.js.map +1 -0
- package/dist/components/commons/VideoMesh/index.d.ts +14 -0
- package/dist/components/commons/VideoMesh/index.d.ts.map +1 -0
- package/dist/components/commons/VideoMesh/index.js +91 -0
- package/dist/components/commons/VideoMesh/index.js.map +1 -0
- package/dist/components/commons/VolumeControl/index.d.ts +9 -0
- package/dist/components/commons/VolumeControl/index.d.ts.map +1 -0
- package/dist/components/{LiveVideoPlayer/VolumeControl.js → commons/VolumeControl/index.js} +6 -3
- package/dist/components/commons/VolumeControl/index.js.map +1 -0
- package/dist/components/commons/utils.d.ts +24 -0
- package/dist/components/commons/utils.d.ts.map +1 -0
- package/dist/components/commons/utils.js +23 -0
- package/dist/components/commons/utils.js.map +1 -0
- package/dist/components/commons/utils.test.d.ts +2 -0
- package/dist/components/commons/utils.test.d.ts.map +1 -0
- package/dist/components/commons/utils.test.js +79 -0
- package/dist/components/commons/utils.test.js.map +1 -0
- package/dist/hooks/useSyncState.d.ts +8 -0
- package/dist/hooks/useSyncState.d.ts.map +1 -0
- package/dist/hooks/useSyncState.js +16 -0
- package/dist/hooks/useSyncState.js.map +1 -0
- package/dist/hooks/useVideoElement.d.ts +30 -0
- package/dist/hooks/useVideoElement.d.ts.map +1 -0
- package/dist/hooks/useVideoElement.js +182 -0
- package/dist/hooks/useVideoElement.js.map +1 -0
- package/dist/index.d.ts +3 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -2
- package/dist/index.js.map +1 -1
- package/package.json +2 -1
- package/dist/components/LiveVideoPlayer/ControlPanel.d.ts +0 -3
- package/dist/components/LiveVideoPlayer/ControlPanel.d.ts.map +0 -1
- package/dist/components/LiveVideoPlayer/ControlPanel.js +0 -17
- package/dist/components/LiveVideoPlayer/ControlPanel.js.map +0 -1
- package/dist/components/LiveVideoPlayer/LiveIndicator.d.ts +0 -3
- package/dist/components/LiveVideoPlayer/LiveIndicator.d.ts.map +0 -1
- package/dist/components/LiveVideoPlayer/LiveIndicator.js.map +0 -1
- package/dist/components/LiveVideoPlayer/PlayPauseButton.d.ts +0 -3
- package/dist/components/LiveVideoPlayer/PlayPauseButton.d.ts.map +0 -1
- package/dist/components/LiveVideoPlayer/PlayPauseButton.js +0 -9
- package/dist/components/LiveVideoPlayer/PlayPauseButton.js.map +0 -1
- package/dist/components/LiveVideoPlayer/ReloadButton.d.ts +0 -3
- package/dist/components/LiveVideoPlayer/ReloadButton.d.ts.map +0 -1
- package/dist/components/LiveVideoPlayer/ReloadButton.js +0 -9
- package/dist/components/LiveVideoPlayer/ReloadButton.js.map +0 -1
- package/dist/components/LiveVideoPlayer/UrlInputButton.d.ts +0 -3
- package/dist/components/LiveVideoPlayer/UrlInputButton.d.ts.map +0 -1
- package/dist/components/LiveVideoPlayer/UrlInputButton.js +0 -23
- package/dist/components/LiveVideoPlayer/UrlInputButton.js.map +0 -1
- package/dist/components/LiveVideoPlayer/VolumeControl.d.ts +0 -3
- package/dist/components/LiveVideoPlayer/VolumeControl.d.ts.map +0 -1
- package/dist/components/LiveVideoPlayer/VolumeControl.js.map +0 -1
- package/dist/components/VideoPlayer/PlayPauseButton.d.ts +0 -3
- package/dist/components/VideoPlayer/PlayPauseButton.d.ts.map +0 -1
- package/dist/components/VideoPlayer/PlayPauseButton.js +0 -9
- package/dist/components/VideoPlayer/PlayPauseButton.js.map +0 -1
- package/dist/components/VideoPlayer/StopButton.d.ts +0 -3
- package/dist/components/VideoPlayer/StopButton.d.ts.map +0 -1
- package/dist/components/VideoPlayer/StopButton.js +0 -9
- package/dist/components/VideoPlayer/StopButton.js.map +0 -1
- package/dist/components/VideoPlayer/UrlInputButton.d.ts +0 -3
- package/dist/components/VideoPlayer/UrlInputButton.d.ts.map +0 -1
- package/dist/components/VideoPlayer/UrlInputButton.js +0 -23
- package/dist/components/VideoPlayer/UrlInputButton.js.map +0 -1
- package/dist/components/VideoPlayer/VolumeControl.d.ts +0 -3
- package/dist/components/VideoPlayer/VolumeControl.d.ts.map +0 -1
- package/dist/components/VideoPlayer/VolumeControl.js +0 -26
- package/dist/components/VideoPlayer/VolumeControl.js.map +0 -1
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
interface Props {
|
|
2
|
+
position: [number, number, number];
|
|
3
|
+
size: number;
|
|
4
|
+
playing: boolean;
|
|
5
|
+
}
|
|
6
|
+
export declare const LiveIndicator: import("react").MemoExoticComponent<({ position, size, playing }: Props) => import("react/jsx-runtime").JSX.Element>;
|
|
7
|
+
export {};
|
|
8
|
+
//# sourceMappingURL=LiveIndicator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LiveIndicator.d.ts","sourceRoot":"","sources":["../../../../../src/components/LiveVideoPlayer/components/ControlPanel/LiveIndicator.tsx"],"names":[],"mappings":"AAGA,UAAU,KAAK;IACb,QAAQ,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAA;IAClC,IAAI,EAAE,MAAM,CAAA;IACZ,OAAO,EAAE,OAAO,CAAA;CACjB;AAED,eAAO,MAAM,aAAa,oEAAsC,KAAK,6CAuBnE,CAAA"}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { memo } from
|
|
3
|
-
import { Text } from
|
|
2
|
+
import { memo } from 'react';
|
|
3
|
+
import { Text } from '@react-three/drei';
|
|
4
4
|
export const LiveIndicator = memo(({ position, size, playing }) => {
|
|
5
5
|
const dotSize = size * 0.15;
|
|
6
6
|
const fontSize = size * 0.4;
|
|
7
|
-
const dotColor = playing ?
|
|
8
|
-
return (_jsxs("group", { position: position, children: [_jsxs("mesh", { position: [-size * 0.5, 0, 0], children: [_jsx("circleGeometry", { args: [dotSize, 16] }), _jsx("meshBasicMaterial", { color: dotColor }, playing ?
|
|
7
|
+
const dotColor = playing ? '#ff0000' : '#666666';
|
|
8
|
+
return (_jsxs("group", { position: position, children: [_jsxs("mesh", { position: [-size * 0.5, 0, 0], children: [_jsx("circleGeometry", { args: [dotSize, 16] }), _jsx("meshBasicMaterial", { color: dotColor }, playing ? 'playing' : 'paused')] }), _jsx(Text, { position: [size * 0.15, 0, 0], fontSize: fontSize, color: "#ffffff", anchorX: "center", anchorY: "middle", fontWeight: "bold", children: "LIVE" })] }));
|
|
9
9
|
});
|
|
10
|
-
LiveIndicator.displayName =
|
|
10
|
+
LiveIndicator.displayName = 'LiveIndicator';
|
|
11
11
|
//# sourceMappingURL=LiveIndicator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LiveIndicator.js","sourceRoot":"","sources":["../../../../../src/components/LiveVideoPlayer/components/ControlPanel/LiveIndicator.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,OAAO,CAAA;AAC5B,OAAO,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAA;AAQxC,MAAM,CAAC,MAAM,aAAa,GAAG,IAAI,CAAC,CAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,OAAO,EAAS,EAAE,EAAE;IACvE,MAAM,OAAO,GAAG,IAAI,GAAG,IAAI,CAAA;IAC3B,MAAM,QAAQ,GAAG,IAAI,GAAG,GAAG,CAAA;IAC3B,MAAM,QAAQ,GAAG,OAAO,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,SAAS,CAAA;IAEhD,OAAO,CACL,iBAAO,QAAQ,EAAE,QAAQ,aACvB,gBAAM,QAAQ,EAAE,CAAC,CAAC,IAAI,GAAG,GAAG,EAAE,CAAC,EAAE,CAAC,CAAC,aACjC,yBAAgB,IAAI,EAAE,CAAC,OAAO,EAAE,EAAE,CAAC,GAAI,EACvC,4BAAwD,KAAK,EAAE,QAAQ,IAA/C,OAAO,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,QAAQ,CAAqB,IACtE,EACP,KAAC,IAAI,IACH,QAAQ,EAAE,CAAC,IAAI,GAAG,IAAI,EAAE,CAAC,EAAE,CAAC,CAAC,EAC7B,QAAQ,EAAE,QAAQ,EAClB,KAAK,EAAC,SAAS,EACf,OAAO,EAAC,QAAQ,EAChB,OAAO,EAAC,QAAQ,EAChB,UAAU,EAAC,MAAM,qBAGZ,IACD,CACT,CAAA;AACH,CAAC,CAAC,CAAA;AAEF,aAAa,CAAC,WAAW,GAAG,eAAe,CAAA"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
interface Props {
|
|
2
|
+
id: string;
|
|
3
|
+
width: number;
|
|
4
|
+
screenHeight: number;
|
|
5
|
+
playing: boolean;
|
|
6
|
+
volume: number;
|
|
7
|
+
isBuffering: boolean;
|
|
8
|
+
url: string;
|
|
9
|
+
onPlayPause: () => void;
|
|
10
|
+
onStop: () => void;
|
|
11
|
+
onVolumeChange: (volume: number) => void;
|
|
12
|
+
onUrlChange: (url: string) => void;
|
|
13
|
+
}
|
|
14
|
+
export declare const ControlPanel: import("react").MemoExoticComponent<({ id, width, screenHeight, playing, volume, isBuffering, url, onPlayPause, onStop, onVolumeChange, onUrlChange, }: Props) => import("react/jsx-runtime").JSX.Element>;
|
|
15
|
+
export {};
|
|
16
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/components/LiveVideoPlayer/components/ControlPanel/index.tsx"],"names":[],"mappings":"AAOA,UAAU,KAAK;IACb,EAAE,EAAE,MAAM,CAAA;IACV,KAAK,EAAE,MAAM,CAAA;IACb,YAAY,EAAE,MAAM,CAAA;IACpB,OAAO,EAAE,OAAO,CAAA;IAChB,MAAM,EAAE,MAAM,CAAA;IACd,WAAW,EAAE,OAAO,CAAA;IACpB,GAAG,EAAE,MAAM,CAAA;IACX,WAAW,EAAE,MAAM,IAAI,CAAA;IACvB,MAAM,EAAE,MAAM,IAAI,CAAA;IAClB,cAAc,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,CAAA;IACxC,WAAW,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAA;CACnC;AAKD,eAAO,MAAM,YAAY,0JAapB,KAAK,6CAmFT,CAAA"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { memo, useCallback } from 'react';
|
|
3
|
+
import { Text } from '@react-three/drei';
|
|
4
|
+
import { IconButton } from '../../../commons/IconButton';
|
|
5
|
+
import { VolumeControl } from '../../../commons/VolumeControl';
|
|
6
|
+
import { useTextInputContext } from '../../../../contexts/TextInputContext';
|
|
7
|
+
import { LiveIndicator } from './LiveIndicator';
|
|
8
|
+
const PANEL_HEIGHT = 0.15;
|
|
9
|
+
const BUTTON_SIZE = PANEL_HEIGHT * 0.6;
|
|
10
|
+
export const ControlPanel = memo(({ id, width, screenHeight, playing, volume, isBuffering, url, onPlayPause, onStop, onVolumeChange, onUrlChange, }) => {
|
|
11
|
+
const panelY = -screenHeight / 2 - PANEL_HEIGHT / 2;
|
|
12
|
+
const { requestTextInput } = useTextInputContext();
|
|
13
|
+
const handleUrlInput = useCallback(() => {
|
|
14
|
+
requestTextInput({
|
|
15
|
+
id: `${id}-url-input`,
|
|
16
|
+
placeholder: 'ライブストリームのURLを入力',
|
|
17
|
+
initialValue: url,
|
|
18
|
+
onSubmit: (value) => {
|
|
19
|
+
if (value && value.trim() !== '') {
|
|
20
|
+
onUrlChange(value.trim());
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
});
|
|
24
|
+
}, [id, url, onUrlChange, requestTextInput]);
|
|
25
|
+
return (_jsxs("group", { position: [0, panelY, 0], children: [_jsxs("mesh", { position: [0, 0, 0], children: [_jsx("planeGeometry", { args: [width, PANEL_HEIGHT] }), _jsx("meshBasicMaterial", { color: "#1a1a2a", transparent: true, opacity: 0.9 })] }), _jsx(IconButton, { id: `${id}-url-input`, position: [-width * 0.45, 0, 0.01], size: BUTTON_SIZE, icon: "\uD83D\uDD17", interactionText: "URL\u5909\u66F4", onInteract: handleUrlInput }), _jsx(IconButton, { id: `${id}-play-pause`, position: [-width * 0.38, 0, 0.01], size: BUTTON_SIZE, icon: playing ? "||" : "▶", interactionText: playing ? "一時停止" : "再生", onInteract: onPlayPause }), _jsx(IconButton, { id: `${id}-stop`, position: [-width * 0.31, 0, 0.01], size: BUTTON_SIZE, icon: "\u25A0", interactionText: "\u505C\u6B62", onInteract: onStop }), _jsx(LiveIndicator, { position: [0, 0, 0.01], size: BUTTON_SIZE, playing: playing }), isBuffering && (_jsx(Text, { position: [0, -0.04, 0.01], fontSize: 0.02, color: "#aaaaaa", anchorX: "center", anchorY: "middle", children: "\u8AAD\u307F\u8FBC\u307F\u4E2D..." })), _jsx(VolumeControl, { id: `${id}-volume`, position: [width * 0.4, 0, 0.01], size: BUTTON_SIZE, volume: volume, onVolumeChange: onVolumeChange })] }));
|
|
26
|
+
});
|
|
27
|
+
ControlPanel.displayName = 'ControlPanel';
|
|
28
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/components/LiveVideoPlayer/components/ControlPanel/index.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,MAAM,OAAO,CAAA;AACzC,OAAO,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAA;AACxC,OAAO,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAA;AACxD,OAAO,EAAE,aAAa,EAAE,MAAM,gCAAgC,CAAA;AAC9D,OAAO,EAAE,mBAAmB,EAAE,MAAM,uCAAuC,CAAA;AAC3E,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAgB/C,MAAM,YAAY,GAAG,IAAI,CAAA;AACzB,MAAM,WAAW,GAAG,YAAY,GAAG,GAAG,CAAA;AAEtC,MAAM,CAAC,MAAM,YAAY,GAAG,I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AAc,CAAA"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
interface Props {
|
|
2
|
+
url: string;
|
|
3
|
+
cacheKey: number;
|
|
4
|
+
width: number;
|
|
5
|
+
height: number;
|
|
6
|
+
playing: boolean;
|
|
7
|
+
volume: number;
|
|
8
|
+
onError?: (error: Error) => void;
|
|
9
|
+
onBufferingChange: (buffering: boolean) => void;
|
|
10
|
+
}
|
|
11
|
+
/** ライブ動画テクスチャ(Suspense内で使用) */
|
|
12
|
+
export declare const LiveVideoTexture: import("react").MemoExoticComponent<({ url, cacheKey, width, height, playing, volume, onError, onBufferingChange, }: Props) => import("react/jsx-runtime").JSX.Element>;
|
|
13
|
+
export {};
|
|
14
|
+
//# sourceMappingURL=LiveVideoTexture.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LiveVideoTexture.d.ts","sourceRoot":"","sources":["../../../../src/components/LiveVideoPlayer/components/LiveVideoTexture.tsx"],"names":[],"mappings":"AAIA,UAAU,KAAK;IACb,GAAG,EAAE,MAAM,CAAA;IACX,QAAQ,EAAE,MAAM,CAAA;IAChB,KAAK,EAAE,MAAM,CAAA;IACb,MAAM,EAAE,MAAM,CAAA;IACd,OAAO,EAAE,OAAO,CAAA;IAChB,MAAM,EAAE,MAAM,CAAA;IACd,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAA;IAChC,iBAAiB,EAAE,CAAC,SAAS,EAAE,OAAO,KAAK,IAAI,CAAA;CAChD;AAED,+BAA+B;AAC/B,eAAO,MAAM,gBAAgB,uHAUxB,KAAK,6CAYT,CAAA"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { memo } from 'react';
|
|
3
|
+
import { useHlsVideo } from '../hooks/useHlsVideo';
|
|
4
|
+
import { VideoMesh } from '../../commons/VideoMesh';
|
|
5
|
+
/** ライブ動画テクスチャ(Suspense内で使用) */
|
|
6
|
+
export const LiveVideoTexture = memo(({ url, cacheKey, width, height, playing, volume, onError, onBufferingChange, }) => {
|
|
7
|
+
const { texture } = useHlsVideo({
|
|
8
|
+
url,
|
|
9
|
+
cacheKey,
|
|
10
|
+
playing,
|
|
11
|
+
volume,
|
|
12
|
+
onError,
|
|
13
|
+
onBufferingChange,
|
|
14
|
+
});
|
|
15
|
+
return _jsx(VideoMesh, { texture: texture, width: width, height: height });
|
|
16
|
+
});
|
|
17
|
+
LiveVideoTexture.displayName = 'LiveVideoTexture';
|
|
18
|
+
//# sourceMappingURL=LiveVideoTexture.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LiveVideoTexture.js","sourceRoot":"","sources":["../../../../src/components/LiveVideoPlayer/components/LiveVideoTexture.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,OAAO,CAAA;AAC5B,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAA;AAClD,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAA;AAanD,+BAA+B;AAC/B,MAAM,CAAC,MAAM,gBAAgB,GAAG,IAAI,CAClC,CAAC,EACC,GAAG,EACH,QAAQ,EACR,KAAK,EACL,MAAM,EACN,OAAO,EACP,MAAM,EACN,OAAO,EACP,iBAAiB,GACX,EAAE,EAAE;IACV,MAAM,EAAE,OAAO,EAAE,GAAG,WAAW,CAAC;QAC9B,GAAG;QACH,QAAQ;QACR,OAAO;QACP,MAAM;QACN,OAAO;QACP,iBAAiB;KAClB,CAAC,CAAA;IAEF,OAAO,KAAC,SAAS,IAAC,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,GAAI,CAAA;AACtE,CAAC,CACF,CAAA;AAED,gBAAgB,CAAC,WAAW,GAAG,kBAAkB,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/LiveVideoPlayer/components/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/components/LiveVideoPlayer/components/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.test.d.ts","sourceRoot":"","sources":["../../../../../../src/components/LiveVideoPlayer/hooks/useHlsVideo/__tests__/utils.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @vitest-environment jsdom
|
|
3
|
+
*/
|
|
4
|
+
import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest';
|
|
5
|
+
import { isHlsUrl, appendCacheKey, canPlayHlsNatively, createVideoTexture } from '../utils';
|
|
6
|
+
describe('isHlsUrl', () => {
|
|
7
|
+
it('.m3u8 を含む URL は true', () => {
|
|
8
|
+
expect(isHlsUrl('https://example.com/video.m3u8')).toBe(true);
|
|
9
|
+
});
|
|
10
|
+
it('.m3u8 をクエリパラメータ前に含む URL は true', () => {
|
|
11
|
+
expect(isHlsUrl('https://example.com/video.m3u8?token=abc')).toBe(true);
|
|
12
|
+
});
|
|
13
|
+
it('application/vnd.apple.mpegurl を含む URL は true', () => {
|
|
14
|
+
expect(isHlsUrl('https://example.com/video?type=application/vnd.apple.mpegurl')).toBe(true);
|
|
15
|
+
});
|
|
16
|
+
it('.mp4 URL は false', () => {
|
|
17
|
+
expect(isHlsUrl('https://example.com/video.mp4')).toBe(false);
|
|
18
|
+
});
|
|
19
|
+
it('.webm URL は false', () => {
|
|
20
|
+
expect(isHlsUrl('https://example.com/video.webm')).toBe(false);
|
|
21
|
+
});
|
|
22
|
+
it('空文字は false', () => {
|
|
23
|
+
expect(isHlsUrl('')).toBe(false);
|
|
24
|
+
});
|
|
25
|
+
});
|
|
26
|
+
describe('appendCacheKey', () => {
|
|
27
|
+
it('クエリパラメータがない URL に _ck を追加', () => {
|
|
28
|
+
expect(appendCacheKey('https://example.com/video.m3u8', 123)).toBe('https://example.com/video.m3u8?_ck=123');
|
|
29
|
+
});
|
|
30
|
+
it('既存のクエリパラメータがある URL に _ck を追加', () => {
|
|
31
|
+
expect(appendCacheKey('https://example.com/video.m3u8?token=abc', 456)).toBe('https://example.com/video.m3u8?token=abc&_ck=456');
|
|
32
|
+
});
|
|
33
|
+
it('cacheKey が 0 の場合も正しく追加', () => {
|
|
34
|
+
expect(appendCacheKey('https://example.com/video.m3u8', 0)).toBe('https://example.com/video.m3u8?_ck=0');
|
|
35
|
+
});
|
|
36
|
+
});
|
|
37
|
+
describe('canPlayHlsNatively', () => {
|
|
38
|
+
it('video.canPlayType が空文字を返す場合は false', () => {
|
|
39
|
+
const originalCreateElement = document.createElement.bind(document);
|
|
40
|
+
vi.spyOn(document, 'createElement').mockImplementation((tagName) => {
|
|
41
|
+
const element = originalCreateElement(tagName);
|
|
42
|
+
if (tagName === 'video') {
|
|
43
|
+
vi.spyOn(element, 'canPlayType').mockReturnValue('');
|
|
44
|
+
}
|
|
45
|
+
return element;
|
|
46
|
+
});
|
|
47
|
+
expect(canPlayHlsNatively()).toBe(false);
|
|
48
|
+
vi.restoreAllMocks();
|
|
49
|
+
});
|
|
50
|
+
it('video.canPlayType が "maybe" を返す場合は true', () => {
|
|
51
|
+
const originalCreateElement = document.createElement.bind(document);
|
|
52
|
+
vi.spyOn(document, 'createElement').mockImplementation((tagName) => {
|
|
53
|
+
const element = originalCreateElement(tagName);
|
|
54
|
+
if (tagName === 'video') {
|
|
55
|
+
vi.spyOn(element, 'canPlayType').mockReturnValue('maybe');
|
|
56
|
+
}
|
|
57
|
+
return element;
|
|
58
|
+
});
|
|
59
|
+
expect(canPlayHlsNatively()).toBe(true);
|
|
60
|
+
vi.restoreAllMocks();
|
|
61
|
+
});
|
|
62
|
+
it('video.canPlayType が "probably" を返す場合は true', () => {
|
|
63
|
+
const originalCreateElement = document.createElement.bind(document);
|
|
64
|
+
vi.spyOn(document, 'createElement').mockImplementation((tagName) => {
|
|
65
|
+
const element = originalCreateElement(tagName);
|
|
66
|
+
if (tagName === 'video') {
|
|
67
|
+
vi.spyOn(element, 'canPlayType').mockReturnValue('probably');
|
|
68
|
+
}
|
|
69
|
+
return element;
|
|
70
|
+
});
|
|
71
|
+
expect(canPlayHlsNatively()).toBe(true);
|
|
72
|
+
vi.restoreAllMocks();
|
|
73
|
+
});
|
|
74
|
+
});
|
|
75
|
+
describe('createVideoTexture', () => {
|
|
76
|
+
it('video 要素と VideoTexture を返す', () => {
|
|
77
|
+
const result = createVideoTexture();
|
|
78
|
+
expect(result.video).toBeInstanceOf(HTMLVideoElement);
|
|
79
|
+
expect(result.texture).toBeDefined();
|
|
80
|
+
});
|
|
81
|
+
it('video 要素に正しい属性が設定される', () => {
|
|
82
|
+
const { video } = createVideoTexture();
|
|
83
|
+
expect(video.crossOrigin).toBe('anonymous');
|
|
84
|
+
expect(video.playsInline).toBe(true);
|
|
85
|
+
expect(video.muted).toBe(false);
|
|
86
|
+
});
|
|
87
|
+
it('texture に正しいフィルター設定がされる', () => {
|
|
88
|
+
const { texture } = createVideoTexture();
|
|
89
|
+
// LinearFilter = 1006 in Three.js
|
|
90
|
+
expect(texture.minFilter).toBe(1006);
|
|
91
|
+
expect(texture.magFilter).toBe(1006);
|
|
92
|
+
});
|
|
93
|
+
});
|
|
94
|
+
describe('createHlsPlayer', () => {
|
|
95
|
+
beforeEach(() => {
|
|
96
|
+
vi.resetModules();
|
|
97
|
+
});
|
|
98
|
+
afterEach(() => {
|
|
99
|
+
vi.restoreAllMocks();
|
|
100
|
+
});
|
|
101
|
+
it('hls.js がサポートされている場合は HlsJsPlayer を返す', async () => {
|
|
102
|
+
vi.doMock('hls.js', () => {
|
|
103
|
+
var _a;
|
|
104
|
+
return ({
|
|
105
|
+
default: (_a = class MockHls {
|
|
106
|
+
constructor() {
|
|
107
|
+
this.on = vi.fn();
|
|
108
|
+
this.attachMedia = vi.fn();
|
|
109
|
+
this.loadSource = vi.fn();
|
|
110
|
+
this.destroy = vi.fn();
|
|
111
|
+
}
|
|
112
|
+
},
|
|
113
|
+
_a.isSupported = () => true,
|
|
114
|
+
_a.Events = {
|
|
115
|
+
ERROR: 'hlsError',
|
|
116
|
+
FRAG_BUFFERED: 'hlsFragBuffered',
|
|
117
|
+
MANIFEST_PARSED: 'hlsManifestParsed',
|
|
118
|
+
},
|
|
119
|
+
_a.ErrorTypes = {
|
|
120
|
+
MEDIA_ERROR: 'mediaError',
|
|
121
|
+
NETWORK_ERROR: 'networkError',
|
|
122
|
+
},
|
|
123
|
+
_a),
|
|
124
|
+
});
|
|
125
|
+
});
|
|
126
|
+
const { createHlsPlayer } = await import('../utils');
|
|
127
|
+
const { RecoveryTracker } = await import('../classes/RecoveryTracker');
|
|
128
|
+
const result = await createHlsPlayer({
|
|
129
|
+
video: document.createElement('video'),
|
|
130
|
+
tracker: new RecoveryTracker(),
|
|
131
|
+
callbacks: {},
|
|
132
|
+
});
|
|
133
|
+
expect(result.type).toBe('hlsjs');
|
|
134
|
+
expect(result.player).not.toBeNull();
|
|
135
|
+
});
|
|
136
|
+
it('hls.js がサポートされていない & ネイティブ HLS 対応の場合は NativeHlsPlayer を返す', async () => {
|
|
137
|
+
vi.doMock('hls.js', () => {
|
|
138
|
+
var _a;
|
|
139
|
+
return ({
|
|
140
|
+
default: (_a = class MockHls {
|
|
141
|
+
},
|
|
142
|
+
_a.isSupported = () => false,
|
|
143
|
+
_a),
|
|
144
|
+
});
|
|
145
|
+
});
|
|
146
|
+
const originalCreateElement = document.createElement.bind(document);
|
|
147
|
+
vi.spyOn(document, 'createElement').mockImplementation((tagName) => {
|
|
148
|
+
const element = originalCreateElement(tagName);
|
|
149
|
+
if (tagName === 'video') {
|
|
150
|
+
vi.spyOn(element, 'canPlayType').mockReturnValue('maybe');
|
|
151
|
+
}
|
|
152
|
+
return element;
|
|
153
|
+
});
|
|
154
|
+
const { createHlsPlayer } = await import('../utils');
|
|
155
|
+
const { RecoveryTracker } = await import('../classes/RecoveryTracker');
|
|
156
|
+
const result = await createHlsPlayer({
|
|
157
|
+
video: document.createElement('video'),
|
|
158
|
+
tracker: new RecoveryTracker(),
|
|
159
|
+
callbacks: {},
|
|
160
|
+
});
|
|
161
|
+
expect(result.type).toBe('native');
|
|
162
|
+
expect(result.player).not.toBeNull();
|
|
163
|
+
});
|
|
164
|
+
it('どちらもサポートされていない場合は unsupported を返す', async () => {
|
|
165
|
+
vi.doMock('hls.js', () => {
|
|
166
|
+
var _a;
|
|
167
|
+
return ({
|
|
168
|
+
default: (_a = class MockHls {
|
|
169
|
+
},
|
|
170
|
+
_a.isSupported = () => false,
|
|
171
|
+
_a),
|
|
172
|
+
});
|
|
173
|
+
});
|
|
174
|
+
const originalCreateElement = document.createElement.bind(document);
|
|
175
|
+
vi.spyOn(document, 'createElement').mockImplementation((tagName) => {
|
|
176
|
+
const element = originalCreateElement(tagName);
|
|
177
|
+
if (tagName === 'video') {
|
|
178
|
+
vi.spyOn(element, 'canPlayType').mockReturnValue('');
|
|
179
|
+
}
|
|
180
|
+
return element;
|
|
181
|
+
});
|
|
182
|
+
const { createHlsPlayer } = await import('../utils');
|
|
183
|
+
const { RecoveryTracker } = await import('../classes/RecoveryTracker');
|
|
184
|
+
const result = await createHlsPlayer({
|
|
185
|
+
video: document.createElement('video'),
|
|
186
|
+
tracker: new RecoveryTracker(),
|
|
187
|
+
callbacks: {},
|
|
188
|
+
});
|
|
189
|
+
expect(result.type).toBe('unsupported');
|
|
190
|
+
expect(result.player).toBeNull();
|
|
191
|
+
if (result.type === 'unsupported') {
|
|
192
|
+
expect(result.error).toBeInstanceOf(Error);
|
|
193
|
+
}
|
|
194
|
+
});
|
|
195
|
+
});
|
|
196
|
+
//# sourceMappingURL=utils.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.test.js","sourceRoot":"","sources":["../../../../../../src/components/LiveVideoPlayer/hooks/useHlsVideo/__tests__/utils.test.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAA;AACxE,OAAO,EAAE,QAAQ,EAAE,cAAc,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAA;AAE3F,QAAQ,CAAC,UAAU,EAAE,GAAG,EAAE;IACxB,EAAE,CAAC,sBAAsB,EAAE,GAAG,EAAE;QAC9B,MAAM,CAAC,QAAQ,CAAC,gCAAgC,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;IAC/D,CAAC,CAAC,CAAA;IAEF,EAAE,CAAC,gCAAgC,EAAE,GAAG,EAAE;QACxC,MAAM,CAAC,QAAQ,CAAC,0CAA0C,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;IACzE,CAAC,CAAC,CAAA;IAEF,EAAE,CAAC,8CAA8C,EAAE,GAAG,EAAE;QACtD,MAAM,CAAC,QAAQ,CAAC,8DAA8D,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;IAC7F,CAAC,CAAC,CAAA;IAEF,EAAE,CAAC,kBAAkB,EAAE,GAAG,EAAE;QAC1B,MAAM,CAAC,QAAQ,CAAC,+BAA+B,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;IAC/D,CAAC,CAAC,CAAA;IAEF,EAAE,CAAC,mBAAmB,EAAE,GAAG,EAAE;QAC3B,MAAM,CAAC,QAAQ,CAAC,gCAAgC,CAAC,CAAC,CAAC,IA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AAM,CAAC,MAAM,CAAC,CAAC,QAAQ,EAAE,CAAA;QAChC,IAAI,MAAM,CAAC,IAAI,KAAK,aAAa,EAAE,CAAC;YAClC,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,cAAc,CAAC,KAAK,CAAC,CAAA;QAC5C,CAAC;IACH,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type Hls from 'hls.js';
|
|
2
|
+
import type { HlsPlayerStrategy, HlsPlayerOptions } from '../types';
|
|
3
|
+
/** hls.js を使用した HLS プレイヤー */
|
|
4
|
+
export declare class HlsJsPlayer implements HlsPlayerStrategy {
|
|
5
|
+
private hls;
|
|
6
|
+
private video;
|
|
7
|
+
private tracker;
|
|
8
|
+
private callbacks;
|
|
9
|
+
constructor(HlsClass: typeof Hls, options: HlsPlayerOptions);
|
|
10
|
+
private setupEventListeners;
|
|
11
|
+
load(url: string): void;
|
|
12
|
+
destroy(): void;
|
|
13
|
+
attemptRecovery(): boolean;
|
|
14
|
+
/** hls.js インスタンスへの参照を取得 */
|
|
15
|
+
get instance(): Hls;
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=HlsJsPlayer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"HlsJsPlayer.d.ts","sourceRoot":"","sources":["../../../../../../src/components/LiveVideoPlayer/hooks/useHlsVideo/classes/HlsJsPlayer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,GAAG,MAAM,QAAQ,CAAA;AAC7B,OAAO,KAAK,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAA;AAEnE,6BAA6B;AAC7B,qBAAa,WAAY,YAAW,iBAAiB;IACnD,OAAO,CAAC,GAAG,CAAK;IAChB,OAAO,CAAC,KAAK,CAAkB;IAC/B,OAAO,CAAC,OAAO,CAA6B;IAC5C,OAAO,CAAC,SAAS,CAA+B;gBAEpC,QAAQ,EAAE,OAAO,GAAG,EAAE,OAAO,EAAE,gBAAgB;IAgB3D,OAAO,CAAC,mBAAmB;IAqC3B,IAAI,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI;IAIvB,OAAO,IAAI,IAAI;IAKf,eAAe,IAAI,OAAO;IAc1B,2BAA2B;IAC3B,IAAI,QAAQ,IAAI,GAAG,CAElB;CACF"}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/** hls.js を使用した HLS プレイヤー */
|
|
2
|
+
export class HlsJsPlayer {
|
|
3
|
+
constructor(HlsClass, options) {
|
|
4
|
+
this.video = options.video;
|
|
5
|
+
this.tracker = options.tracker;
|
|
6
|
+
this.callbacks = options.callbacks;
|
|
7
|
+
this.hls = new HlsClass({
|
|
8
|
+
enableWorker: true,
|
|
9
|
+
lowLatencyMode: true,
|
|
10
|
+
});
|
|
11
|
+
this.setupEventListeners(HlsClass);
|
|
12
|
+
this.hls.attachMedia(this.video);
|
|
13
|
+
console.log('[HlsJsPlayer] Initialized');
|
|
14
|
+
}
|
|
15
|
+
setupEventListeners(HlsClass) {
|
|
16
|
+
const { onError, onBufferingChange, onManifestParsed } = this.callbacks;
|
|
17
|
+
this.hls.on(HlsClass.Events.ERROR, (_event, data) => {
|
|
18
|
+
if (!data.fatal) {
|
|
19
|
+
console.log('[HlsJsPlayer] Non-fatal error:', data.details);
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
console.warn('[HlsJsPlayer] Fatal error:', data.type, data.details);
|
|
23
|
+
if (data.type === HlsClass.ErrorTypes.MEDIA_ERROR) {
|
|
24
|
+
const recovered = this.attemptRecovery();
|
|
25
|
+
if (!recovered && !this.tracker.isErrorReported) {
|
|
26
|
+
this.tracker.markErrorReported();
|
|
27
|
+
onError?.(new Error(`HLS media error: ${data.details}`));
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
else if (data.type === HlsClass.ErrorTypes.NETWORK_ERROR) {
|
|
31
|
+
console.log('[HlsJsPlayer] Network error, restarting load...');
|
|
32
|
+
this.hls.startLoad();
|
|
33
|
+
}
|
|
34
|
+
else {
|
|
35
|
+
if (!this.tracker.isErrorReported) {
|
|
36
|
+
this.tracker.markErrorReported();
|
|
37
|
+
onError?.(new Error(`HLS error: ${data.type} - ${data.details}`));
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
this.hls.on(HlsClass.Events.FRAG_BUFFERED, () => {
|
|
42
|
+
onBufferingChange?.(false);
|
|
43
|
+
});
|
|
44
|
+
this.hls.on(HlsClass.Events.MANIFEST_PARSED, () => {
|
|
45
|
+
onManifestParsed?.();
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
load(url) {
|
|
49
|
+
this.hls.loadSource(url);
|
|
50
|
+
}
|
|
51
|
+
destroy() {
|
|
52
|
+
this.hls.destroy();
|
|
53
|
+
console.log('[HlsJsPlayer] Destroyed');
|
|
54
|
+
}
|
|
55
|
+
attemptRecovery() {
|
|
56
|
+
if (!this.tracker.shouldAttemptRecovery()) {
|
|
57
|
+
return false;
|
|
58
|
+
}
|
|
59
|
+
try {
|
|
60
|
+
this.hls.recoverMediaError();
|
|
61
|
+
return true;
|
|
62
|
+
}
|
|
63
|
+
catch (e) {
|
|
64
|
+
console.error('[HlsJsPlayer] recoverMediaError() failed:', e);
|
|
65
|
+
return false;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
/** hls.js インスタンスへの参照を取得 */
|
|
69
|
+
get instance() {
|
|
70
|
+
return this.hls;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
//# sourceMappingURL=HlsJsPlayer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"HlsJsPlayer.js","sourceRoot":"","sources":["../../../../../../src/components/LiveVideoPlayer/hooks/useHlsVideo/classes/HlsJsPlayer.ts"],"names":[],"mappings":"AAGA,6BAA6B;AAC7B,MAAM,OAAO,WAAW;IAMtB,YAAY,QAAoB,EAAE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CAAA;QACd,CAAC;QAED,IAAI,CAAC;YACH,IAAI,CAAC,GAAG,CAAC,iBAAiB,EAAE,CAAA;YAC5B,OAAO,IAAI,CAAA;QACb,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC;YACX,OAAO,CAAC,KAAK,CAAC,2CAA2C,EAAE,CAAC,CAAC,CAAA;YAC7D,OAAO,KAAK,CAAA;QACd,CAAC;IACH,CAAC;IAED,2BAA2B;IAC3B,IAAI,QAAQ;QACV,OAAO,IAAI,CAAC,GAAG,CAAA;IACjB,CAAC;CACF"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { HlsPlayerStrategy, HlsPlayerOptions } from '../types';
|
|
2
|
+
/** ブラウザネイティブの HLS 再生を使用するプレイヤー(主に Safari 向け) */
|
|
3
|
+
export declare class NativeHlsPlayer implements HlsPlayerStrategy {
|
|
4
|
+
private video;
|
|
5
|
+
private tracker;
|
|
6
|
+
private callbacks;
|
|
7
|
+
private handleError;
|
|
8
|
+
constructor(options: HlsPlayerOptions);
|
|
9
|
+
private onError;
|
|
10
|
+
load(url: string): void;
|
|
11
|
+
destroy(): void;
|
|
12
|
+
attemptRecovery(): boolean;
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=NativeHlsPlayer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NativeHlsPlayer.d.ts","sourceRoot":"","sources":["../../../../../../src/components/LiveVideoPlayer/hooks/useHlsVideo/classes/NativeHlsPlayer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAA;AAKnE,gDAAgD;AAChD,qBAAa,eAAgB,YAAW,iBAAiB;IACvD,OAAO,CAAC,KAAK,CAAkB;IAC/B,OAAO,CAAC,OAAO,CAA6B;IAC5C,OAAO,CAAC,SAAS,CAA+B;IAChD,OAAO,CAAC,WAAW,CAAY;gBAEnB,OAAO,EAAE,gBAAgB;IAWrC,OAAO,CAAC,OAAO;IAmBf,IAAI,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI;IAIvB,OAAO,IAAI,IAAI;IAKf,eAAe,IAAI,OAAO;CAU3B"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
// MediaError.MEDIA_ERR_DECODE の値(テスト環境での互換性のため直接定義)
|
|
2
|
+
const MEDIA_ERR_DECODE = 3;
|
|
3
|
+
/** ブラウザネイティブの HLS 再生を使用するプレイヤー(主に Safari 向け) */
|
|
4
|
+
export class NativeHlsPlayer {
|
|
5
|
+
constructor(options) {
|
|
6
|
+
this.video = options.video;
|
|
7
|
+
this.tracker = options.tracker;
|
|
8
|
+
this.callbacks = options.callbacks;
|
|
9
|
+
this.handleError = this.onError.bind(this);
|
|
10
|
+
this.video.addEventListener('error', this.handleError);
|
|
11
|
+
console.log('[NativeHlsPlayer] Initialized');
|
|
12
|
+
}
|
|
13
|
+
onError() {
|
|
14
|
+
const error = this.video.error;
|
|
15
|
+
if (!error)
|
|
16
|
+
return;
|
|
17
|
+
const { onError } = this.callbacks;
|
|
18
|
+
if (error.code === MEDIA_ERR_DECODE) {
|
|
19
|
+
if (this.attemptRecovery()) {
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
if (!this.tracker.isErrorReported) {
|
|
24
|
+
this.tracker.markErrorReported();
|
|
25
|
+
console.error('[NativeHlsPlayer] Video error:', error.message);
|
|
26
|
+
onError?.(new Error(error.message));
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
load(url) {
|
|
30
|
+
this.video.src = url;
|
|
31
|
+
}
|
|
32
|
+
destroy() {
|
|
33
|
+
this.video.removeEventListener('error', this.handleError);
|
|
34
|
+
console.log('[NativeHlsPlayer] Destroyed');
|
|
35
|
+
}
|
|
36
|
+
attemptRecovery() {
|
|
37
|
+
if (!this.tracker.shouldAttemptRecovery()) {
|
|
38
|
+
return false;
|
|
39
|
+
}
|
|
40
|
+
console.log('[NativeHlsPlayer] Attempting recovery by skipping segment');
|
|
41
|
+
this.video.currentTime = this.video.currentTime + 0.5;
|
|
42
|
+
this.video.play().catch(() => { });
|
|
43
|
+
return true;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
//# sourceMappingURL=NativeHlsPlayer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NativeHlsPlayer.js","sourceRoot":"","sources":["../../../../../../src/components/LiveVideoPlayer/hooks/useHlsVideo/classes/NativeHlsPlayer.ts"],"names":[],"mappings":"AAEA,oDAAoD;AACpD,MAAM,gBAAgB,GAAG,CAAC,CAAA;AAE1B,gDAAgD;AAChD,MAAM,OAAO,eAAe;IAM1B,YAAY,OAAyB;QACnC,IAAI,CAAC,KAAK,GAAG,OAAO,CAAC,KAAK,CAAA;QAC1B,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC,OAAO,CAAA;QAC9B,IAAI,CAAC,SAAS,GAAG,OAAO,CAAC,SAAS,CAAA;QAElC,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;QAC1C,IAAI,CAAC,KAAK,CAAC,gBAAgB,CAAC,OAAO,EAAE,IAAI,CAAC,WAAW,CAAC,CAAA;QAEtD,OAAO,CAAC,GAAG,CAAC,+BAA+B,CAAC,CAAA;IAC9C,CAAC;IAEO,OAAO;QACb,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,CAAA;QAC9B,IAAI,CAAC,KAAK;YAAE,OAAM;QAElB,MAAM,EAAE,OAAO,EAAE,GAAG,IAAI,CAAC,SAAS,CAAA;QAElC,IAAI,KAAK,CAAC,IAAI,KAAK,gBAAgB,EAAE,CAAC;YACpC,IAAI,IAAI,CAAC,eAAe,EAAE,EAAE,CAAC;gBAC3B,OAAM;YACR,CAAC;QACH,CAAC;QAED,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,eAAe,EAAE,CAAC;YAClC,IAAI,CAAC,OAAO,CAAC,iBAAiB,EAAE,CAAA;YAChC,OAAO,CAAC,KAAK,CAAC,gCAAgC,EAAE,KAAK,CAAC,OAAO,CAAC,CAAA;YAC9D,OAAO,EAAE,CAAC,IAAI,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAA;QACrC,CAAC;IACH,CAAC;IAED,IAAI,CAAC,GAAW;QACd,IAAI,CAAC,KAAK,CAAC,GAAG,GAAG,GAAG,CAAA;IACtB,CAAC;IAED,OAAO;QACL,IAAI,CAAC,KAAK,CAAC,mBAAmB,CAAC,OAAO,EAAE,IAAI,CAAC,WAAW,CAAC,CAAA;QACzD,OAAO,CAAC,GAAG,CAAC,6BAA6B,CAAC,CAAA;IAC5C,CAAC;IAED,eAAe;QACb,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,qBAAqB,EAAE,EAAE,CAAC;YAC1C,OAAO,KAAK,CAAA;QACd,CAAC;QAED,OAAO,CAAC,GAAG,CAAC,2DAA2D,CAAC,CAAA;QACxE,IAAI,CAAC,KAAK,CAAC,WAAW,GAAG,IAAI,CAAC,KAAK,CAAC,WAAW,GAAG,GAAG,CAAA;QACrD,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC,CAAA;QACjC,OAAO,IAAI,CAAA;IACb,CAAC;CACF"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* エラーリカバリの試行を追跡するクラス
|
|
3
|
+
* スロットリングと試行回数制限を管理
|
|
4
|
+
*/
|
|
5
|
+
export declare class RecoveryTracker {
|
|
6
|
+
private lastRecoveryTime;
|
|
7
|
+
private recoveryAttempts;
|
|
8
|
+
private errorReported;
|
|
9
|
+
/** 状態をリセット */
|
|
10
|
+
reset(): void;
|
|
11
|
+
/** エラーが既に報告済みかどうか */
|
|
12
|
+
get isErrorReported(): boolean;
|
|
13
|
+
/** エラーを報告済みとしてマーク */
|
|
14
|
+
markErrorReported(): void;
|
|
15
|
+
/**
|
|
16
|
+
* リカバリを試行可能かどうかを判定し、カウンターを更新
|
|
17
|
+
* @returns リカバリを試行すべきかどうか
|
|
18
|
+
*/
|
|
19
|
+
shouldAttemptRecovery(): boolean;
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=RecoveryTracker.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RecoveryTracker.d.ts","sourceRoot":"","sources":["../../../../../../src/components/LiveVideoPlayer/hooks/useHlsVideo/classes/RecoveryTracker.ts"],"names":[],"mappings":"AAKA;;;GAGG;AACH,qBAAa,eAAe;IAC1B,OAAO,CAAC,gBAAgB,CAAI;IAC5B,OAAO,CAAC,gBAAgB,CAAI;IAC5B,OAAO,CAAC,aAAa,CAAQ;IAE7B,cAAc;IACd,KAAK,IAAI,IAAI;IAMb,qBAAqB;IACrB,IAAI,eAAe,IAAI,OAAO,CAE7B;IAED,qBAAqB;IACrB,iBAAiB,IAAI,IAAI;IAIzB;;;OAGG;IACH,qBAAqB,IAAI,OAAO;CA2BjC"}
|