@scalemule/gallop 0.0.1
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/LICENSE +21 -0
- package/README.md +201 -0
- package/dist/EventEmitter-CiUv3YL_.d.cts +12 -0
- package/dist/EventEmitter-CkfpgRij.d.ts +12 -0
- package/dist/chunk-2JQGJ7NX.cjs +40 -0
- package/dist/chunk-PKRNWEEX.cjs +265 -0
- package/dist/chunk-QTV4W7FA.js +2886 -0
- package/dist/chunk-SQPWH6EI.js +38 -0
- package/dist/chunk-UFFGSURS.js +263 -0
- package/dist/chunk-VCNMR5AB.cjs +2893 -0
- package/dist/element.cjs +342 -0
- package/dist/element.d.cts +38 -0
- package/dist/element.d.ts +38 -0
- package/dist/element.js +340 -0
- package/dist/gallop.embed.global.js +568 -0
- package/dist/gallop.umd.global.js +568 -0
- package/dist/iframe.cjs +11 -0
- package/dist/iframe.d.cts +50 -0
- package/dist/iframe.d.ts +50 -0
- package/dist/iframe.js +2 -0
- package/dist/index.cjs +11 -0
- package/dist/index.d.cts +74 -0
- package/dist/index.d.ts +74 -0
- package/dist/index.js +2 -0
- package/dist/react.cjs +77 -0
- package/dist/react.d.cts +34 -0
- package/dist/react.d.ts +34 -0
- package/dist/react.js +74 -0
- package/dist/types-D9Oqcpr1.d.cts +235 -0
- package/dist/types-D9Oqcpr1.d.ts +235 -0
- package/package.json +93 -0
package/dist/iframe.cjs
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var chunkPKRNWEEX_cjs = require('./chunk-PKRNWEEX.cjs');
|
|
4
|
+
require('./chunk-2JQGJ7NX.cjs');
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
Object.defineProperty(exports, "GallopIframeController", {
|
|
9
|
+
enumerable: true,
|
|
10
|
+
get: function () { return chunkPKRNWEEX_cjs.GallopIframeController; }
|
|
11
|
+
});
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { E as EventEmitter } from './EventEmitter-CiUv3YL_.cjs';
|
|
2
|
+
import { e as GallopPlayer, b as GallopConfig, P as PlayerStatus, Q as QualityLevel, a as GallopDiagnostics, G as GallopQueryMap } from './types-D9Oqcpr1.cjs';
|
|
3
|
+
|
|
4
|
+
declare class GallopIframeController extends EventEmitter implements GallopPlayer {
|
|
5
|
+
private container;
|
|
6
|
+
private config;
|
|
7
|
+
private iframe;
|
|
8
|
+
private targetOrigin;
|
|
9
|
+
private isConnected;
|
|
10
|
+
private pendingCalls;
|
|
11
|
+
private stateCache;
|
|
12
|
+
private cachedQualityLevels;
|
|
13
|
+
private cachedCurrentQuality;
|
|
14
|
+
private cachedDiagnostics;
|
|
15
|
+
private sessionId;
|
|
16
|
+
private boundHandler;
|
|
17
|
+
private handshakeInterval;
|
|
18
|
+
constructor(container: HTMLElement, config: GallopConfig);
|
|
19
|
+
private createIframe;
|
|
20
|
+
private startHandshake;
|
|
21
|
+
private handleMessage;
|
|
22
|
+
private handleResponse;
|
|
23
|
+
private sendMessage;
|
|
24
|
+
private callMethod;
|
|
25
|
+
get currentTime(): number;
|
|
26
|
+
get duration(): number;
|
|
27
|
+
get paused(): boolean;
|
|
28
|
+
get status(): PlayerStatus;
|
|
29
|
+
get isFullscreen(): boolean;
|
|
30
|
+
get volume(): number;
|
|
31
|
+
set volume(v: number);
|
|
32
|
+
get muted(): boolean;
|
|
33
|
+
set muted(m: boolean);
|
|
34
|
+
get playbackRate(): number;
|
|
35
|
+
set playbackRate(r: number);
|
|
36
|
+
play(): Promise<void>;
|
|
37
|
+
pause(): Promise<void>;
|
|
38
|
+
seek(time: number): Promise<void>;
|
|
39
|
+
setQualityLevel(index: number): Promise<void>;
|
|
40
|
+
setAutoQuality(): Promise<void>;
|
|
41
|
+
toggleFullscreen(): Promise<void>;
|
|
42
|
+
getQualityLevels(): QualityLevel[];
|
|
43
|
+
getCurrentQuality(): number;
|
|
44
|
+
getDiagnostics(): GallopDiagnostics;
|
|
45
|
+
query<K extends keyof GallopQueryMap>(key: K): Promise<GallopQueryMap[K]>;
|
|
46
|
+
get connected(): boolean;
|
|
47
|
+
destroy(): void;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export { GallopIframeController };
|
package/dist/iframe.d.ts
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { E as EventEmitter } from './EventEmitter-CkfpgRij.js';
|
|
2
|
+
import { e as GallopPlayer, b as GallopConfig, P as PlayerStatus, Q as QualityLevel, a as GallopDiagnostics, G as GallopQueryMap } from './types-D9Oqcpr1.js';
|
|
3
|
+
|
|
4
|
+
declare class GallopIframeController extends EventEmitter implements GallopPlayer {
|
|
5
|
+
private container;
|
|
6
|
+
private config;
|
|
7
|
+
private iframe;
|
|
8
|
+
private targetOrigin;
|
|
9
|
+
private isConnected;
|
|
10
|
+
private pendingCalls;
|
|
11
|
+
private stateCache;
|
|
12
|
+
private cachedQualityLevels;
|
|
13
|
+
private cachedCurrentQuality;
|
|
14
|
+
private cachedDiagnostics;
|
|
15
|
+
private sessionId;
|
|
16
|
+
private boundHandler;
|
|
17
|
+
private handshakeInterval;
|
|
18
|
+
constructor(container: HTMLElement, config: GallopConfig);
|
|
19
|
+
private createIframe;
|
|
20
|
+
private startHandshake;
|
|
21
|
+
private handleMessage;
|
|
22
|
+
private handleResponse;
|
|
23
|
+
private sendMessage;
|
|
24
|
+
private callMethod;
|
|
25
|
+
get currentTime(): number;
|
|
26
|
+
get duration(): number;
|
|
27
|
+
get paused(): boolean;
|
|
28
|
+
get status(): PlayerStatus;
|
|
29
|
+
get isFullscreen(): boolean;
|
|
30
|
+
get volume(): number;
|
|
31
|
+
set volume(v: number);
|
|
32
|
+
get muted(): boolean;
|
|
33
|
+
set muted(m: boolean);
|
|
34
|
+
get playbackRate(): number;
|
|
35
|
+
set playbackRate(r: number);
|
|
36
|
+
play(): Promise<void>;
|
|
37
|
+
pause(): Promise<void>;
|
|
38
|
+
seek(time: number): Promise<void>;
|
|
39
|
+
setQualityLevel(index: number): Promise<void>;
|
|
40
|
+
setAutoQuality(): Promise<void>;
|
|
41
|
+
toggleFullscreen(): Promise<void>;
|
|
42
|
+
getQualityLevels(): QualityLevel[];
|
|
43
|
+
getCurrentQuality(): number;
|
|
44
|
+
getDiagnostics(): GallopDiagnostics;
|
|
45
|
+
query<K extends keyof GallopQueryMap>(key: K): Promise<GallopQueryMap[K]>;
|
|
46
|
+
get connected(): boolean;
|
|
47
|
+
destroy(): void;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export { GallopIframeController };
|
package/dist/iframe.js
ADDED
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var chunkVCNMR5AB_cjs = require('./chunk-VCNMR5AB.cjs');
|
|
4
|
+
require('./chunk-2JQGJ7NX.cjs');
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
Object.defineProperty(exports, "GallopPlayerCore", {
|
|
9
|
+
enumerable: true,
|
|
10
|
+
get: function () { return chunkVCNMR5AB_cjs.GallopPlayerCore; }
|
|
11
|
+
});
|
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { e as GallopPlayer, b as GallopConfig, a as GallopDiagnostics, G as GallopQueryMap, Q as QualityLevel, P as PlayerStatus } from './types-D9Oqcpr1.cjs';
|
|
2
|
+
export { c as GallopEventCallback, d as GallopEventMap, f as GallopTheme, S as StreamingEngine, V as VideoMetadata } from './types-D9Oqcpr1.cjs';
|
|
3
|
+
import { E as EventEmitter } from './EventEmitter-CiUv3YL_.cjs';
|
|
4
|
+
|
|
5
|
+
declare class GallopPlayerCore extends EventEmitter implements GallopPlayer {
|
|
6
|
+
private container;
|
|
7
|
+
private config;
|
|
8
|
+
private video;
|
|
9
|
+
private wrapper;
|
|
10
|
+
private engine;
|
|
11
|
+
private state;
|
|
12
|
+
private client;
|
|
13
|
+
private controls;
|
|
14
|
+
private bigPlayButton;
|
|
15
|
+
private loadingSpinner;
|
|
16
|
+
private errorOverlay;
|
|
17
|
+
private posterImage;
|
|
18
|
+
private themeManager;
|
|
19
|
+
private contextMenu;
|
|
20
|
+
private keyboardManager;
|
|
21
|
+
private touchManager;
|
|
22
|
+
private analyticsCollector;
|
|
23
|
+
private styleEl;
|
|
24
|
+
private debugOverlay;
|
|
25
|
+
private cspStatus;
|
|
26
|
+
private nonceStatus;
|
|
27
|
+
private destroyed;
|
|
28
|
+
private engineStats;
|
|
29
|
+
constructor(container: HTMLElement, config?: GallopConfig);
|
|
30
|
+
private createDOM;
|
|
31
|
+
private mountUI;
|
|
32
|
+
private bindVideoEvents;
|
|
33
|
+
loadVideoById(videoId: string): Promise<void>;
|
|
34
|
+
loadSource(url: string): Promise<void>;
|
|
35
|
+
getDiagnostics(): GallopDiagnostics;
|
|
36
|
+
private getBufferLength;
|
|
37
|
+
query<K extends keyof GallopQueryMap>(key: K): Promise<GallopQueryMap[K]>;
|
|
38
|
+
private initializeDebugOverlay;
|
|
39
|
+
private retry;
|
|
40
|
+
play(): Promise<void>;
|
|
41
|
+
pause(): Promise<void>;
|
|
42
|
+
togglePlay(): Promise<void>;
|
|
43
|
+
seek(time: number): Promise<void>;
|
|
44
|
+
seekForward(seconds?: number): void;
|
|
45
|
+
seekBackward(seconds?: number): void;
|
|
46
|
+
get volume(): number;
|
|
47
|
+
set volume(v: number);
|
|
48
|
+
get muted(): boolean;
|
|
49
|
+
set muted(m: boolean);
|
|
50
|
+
toggleMute(): void;
|
|
51
|
+
get currentTime(): number;
|
|
52
|
+
get duration(): number;
|
|
53
|
+
get paused(): boolean;
|
|
54
|
+
get buffered(): TimeRanges;
|
|
55
|
+
getQualityLevels(): QualityLevel[];
|
|
56
|
+
setQualityLevel(index: number): Promise<void>;
|
|
57
|
+
setAutoQuality(): Promise<void>;
|
|
58
|
+
isAutoQuality(): boolean;
|
|
59
|
+
getCurrentQuality(): number;
|
|
60
|
+
get playbackRate(): number;
|
|
61
|
+
set playbackRate(rate: number);
|
|
62
|
+
toggleFullscreen(): Promise<void>;
|
|
63
|
+
enterFullscreen(): Promise<void>;
|
|
64
|
+
exitFullscreen(): Promise<void>;
|
|
65
|
+
get isFullscreen(): boolean;
|
|
66
|
+
get status(): PlayerStatus;
|
|
67
|
+
getVideoElement(): HTMLVideoElement;
|
|
68
|
+
getWrapperElement(): HTMLElement;
|
|
69
|
+
private updateUIState;
|
|
70
|
+
destroy(): void;
|
|
71
|
+
private initializeAnalytics;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
export { GallopConfig, GallopPlayerCore, PlayerStatus, QualityLevel };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { e as GallopPlayer, b as GallopConfig, a as GallopDiagnostics, G as GallopQueryMap, Q as QualityLevel, P as PlayerStatus } from './types-D9Oqcpr1.js';
|
|
2
|
+
export { c as GallopEventCallback, d as GallopEventMap, f as GallopTheme, S as StreamingEngine, V as VideoMetadata } from './types-D9Oqcpr1.js';
|
|
3
|
+
import { E as EventEmitter } from './EventEmitter-CkfpgRij.js';
|
|
4
|
+
|
|
5
|
+
declare class GallopPlayerCore extends EventEmitter implements GallopPlayer {
|
|
6
|
+
private container;
|
|
7
|
+
private config;
|
|
8
|
+
private video;
|
|
9
|
+
private wrapper;
|
|
10
|
+
private engine;
|
|
11
|
+
private state;
|
|
12
|
+
private client;
|
|
13
|
+
private controls;
|
|
14
|
+
private bigPlayButton;
|
|
15
|
+
private loadingSpinner;
|
|
16
|
+
private errorOverlay;
|
|
17
|
+
private posterImage;
|
|
18
|
+
private themeManager;
|
|
19
|
+
private contextMenu;
|
|
20
|
+
private keyboardManager;
|
|
21
|
+
private touchManager;
|
|
22
|
+
private analyticsCollector;
|
|
23
|
+
private styleEl;
|
|
24
|
+
private debugOverlay;
|
|
25
|
+
private cspStatus;
|
|
26
|
+
private nonceStatus;
|
|
27
|
+
private destroyed;
|
|
28
|
+
private engineStats;
|
|
29
|
+
constructor(container: HTMLElement, config?: GallopConfig);
|
|
30
|
+
private createDOM;
|
|
31
|
+
private mountUI;
|
|
32
|
+
private bindVideoEvents;
|
|
33
|
+
loadVideoById(videoId: string): Promise<void>;
|
|
34
|
+
loadSource(url: string): Promise<void>;
|
|
35
|
+
getDiagnostics(): GallopDiagnostics;
|
|
36
|
+
private getBufferLength;
|
|
37
|
+
query<K extends keyof GallopQueryMap>(key: K): Promise<GallopQueryMap[K]>;
|
|
38
|
+
private initializeDebugOverlay;
|
|
39
|
+
private retry;
|
|
40
|
+
play(): Promise<void>;
|
|
41
|
+
pause(): Promise<void>;
|
|
42
|
+
togglePlay(): Promise<void>;
|
|
43
|
+
seek(time: number): Promise<void>;
|
|
44
|
+
seekForward(seconds?: number): void;
|
|
45
|
+
seekBackward(seconds?: number): void;
|
|
46
|
+
get volume(): number;
|
|
47
|
+
set volume(v: number);
|
|
48
|
+
get muted(): boolean;
|
|
49
|
+
set muted(m: boolean);
|
|
50
|
+
toggleMute(): void;
|
|
51
|
+
get currentTime(): number;
|
|
52
|
+
get duration(): number;
|
|
53
|
+
get paused(): boolean;
|
|
54
|
+
get buffered(): TimeRanges;
|
|
55
|
+
getQualityLevels(): QualityLevel[];
|
|
56
|
+
setQualityLevel(index: number): Promise<void>;
|
|
57
|
+
setAutoQuality(): Promise<void>;
|
|
58
|
+
isAutoQuality(): boolean;
|
|
59
|
+
getCurrentQuality(): number;
|
|
60
|
+
get playbackRate(): number;
|
|
61
|
+
set playbackRate(rate: number);
|
|
62
|
+
toggleFullscreen(): Promise<void>;
|
|
63
|
+
enterFullscreen(): Promise<void>;
|
|
64
|
+
exitFullscreen(): Promise<void>;
|
|
65
|
+
get isFullscreen(): boolean;
|
|
66
|
+
get status(): PlayerStatus;
|
|
67
|
+
getVideoElement(): HTMLVideoElement;
|
|
68
|
+
getWrapperElement(): HTMLElement;
|
|
69
|
+
private updateUIState;
|
|
70
|
+
destroy(): void;
|
|
71
|
+
private initializeAnalytics;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
export { GallopConfig, GallopPlayerCore, PlayerStatus, QualityLevel };
|
package/dist/index.js
ADDED
package/dist/react.cjs
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var chunkVCNMR5AB_cjs = require('./chunk-VCNMR5AB.cjs');
|
|
4
|
+
require('./chunk-2JQGJ7NX.cjs');
|
|
5
|
+
var react = require('react');
|
|
6
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
7
|
+
|
|
8
|
+
var GallopPlayer = react.forwardRef(
|
|
9
|
+
function GallopPlayer2(props, ref) {
|
|
10
|
+
const containerRef = react.useRef(null);
|
|
11
|
+
const playerRef = react.useRef(null);
|
|
12
|
+
const {
|
|
13
|
+
className,
|
|
14
|
+
style,
|
|
15
|
+
onPlay,
|
|
16
|
+
onPause,
|
|
17
|
+
onEnded,
|
|
18
|
+
onTimeUpdate,
|
|
19
|
+
onVolumeChange,
|
|
20
|
+
onQualityChange,
|
|
21
|
+
onEngineStats,
|
|
22
|
+
onError,
|
|
23
|
+
onReady,
|
|
24
|
+
onFullscreenChange,
|
|
25
|
+
onStatusChange,
|
|
26
|
+
...config
|
|
27
|
+
} = props;
|
|
28
|
+
react.useImperativeHandle(ref, () => ({
|
|
29
|
+
play: () => playerRef.current?.play(),
|
|
30
|
+
pause: () => playerRef.current?.pause(),
|
|
31
|
+
seek: (time) => playerRef.current?.seek(time),
|
|
32
|
+
toggleFullscreen: () => playerRef.current?.toggleFullscreen(),
|
|
33
|
+
getCore: () => playerRef.current
|
|
34
|
+
}));
|
|
35
|
+
react.useEffect(() => {
|
|
36
|
+
const container = containerRef.current;
|
|
37
|
+
if (!container) return;
|
|
38
|
+
const player = new chunkVCNMR5AB_cjs.GallopPlayerCore(container, config);
|
|
39
|
+
playerRef.current = player;
|
|
40
|
+
if (onPlay) player.on("play", onPlay);
|
|
41
|
+
if (onPause) player.on("pause", onPause);
|
|
42
|
+
if (onEnded) player.on("ended", onEnded);
|
|
43
|
+
if (onTimeUpdate) player.on("timeupdate", onTimeUpdate);
|
|
44
|
+
if (onVolumeChange) player.on("volumechange", onVolumeChange);
|
|
45
|
+
if (onQualityChange) player.on("qualitychange", onQualityChange);
|
|
46
|
+
if (onEngineStats) player.on("enginestats", onEngineStats);
|
|
47
|
+
if (onError) player.on("error", onError);
|
|
48
|
+
if (onReady) player.on("ready", onReady);
|
|
49
|
+
if (onFullscreenChange) player.on("fullscreenchange", onFullscreenChange);
|
|
50
|
+
if (onStatusChange) player.on("statuschange", onStatusChange);
|
|
51
|
+
return () => {
|
|
52
|
+
player.destroy();
|
|
53
|
+
playerRef.current = null;
|
|
54
|
+
};
|
|
55
|
+
}, [props.videoId, props.src, props.apiKey]);
|
|
56
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { ref: containerRef, className, style });
|
|
57
|
+
}
|
|
58
|
+
);
|
|
59
|
+
function useGallopPlayer(config) {
|
|
60
|
+
const containerRef = react.useRef(null);
|
|
61
|
+
const playerRef = react.useRef(null);
|
|
62
|
+
react.useEffect(() => {
|
|
63
|
+
const container = containerRef.current;
|
|
64
|
+
if (!container) return;
|
|
65
|
+
const player = new chunkVCNMR5AB_cjs.GallopPlayerCore(container, config);
|
|
66
|
+
playerRef.current = player;
|
|
67
|
+
return () => {
|
|
68
|
+
player.destroy();
|
|
69
|
+
playerRef.current = null;
|
|
70
|
+
};
|
|
71
|
+
}, [config.videoId, config.src, config.apiKey]);
|
|
72
|
+
const getPlayer = react.useCallback(() => playerRef.current, []);
|
|
73
|
+
return { containerRef, getPlayer };
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
exports.GallopPlayer = GallopPlayer;
|
|
77
|
+
exports.useGallopPlayer = useGallopPlayer;
|
package/dist/react.d.cts
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import * as react from 'react';
|
|
2
|
+
import { GallopPlayerCore } from './index.cjs';
|
|
3
|
+
import { b as GallopConfig, c as GallopEventCallback, d as GallopEventMap } from './types-D9Oqcpr1.cjs';
|
|
4
|
+
import './EventEmitter-CiUv3YL_.cjs';
|
|
5
|
+
|
|
6
|
+
interface GallopPlayerProps extends GallopConfig {
|
|
7
|
+
className?: string;
|
|
8
|
+
style?: React.CSSProperties;
|
|
9
|
+
onPlay?: () => void;
|
|
10
|
+
onPause?: () => void;
|
|
11
|
+
onEnded?: () => void;
|
|
12
|
+
onTimeUpdate?: GallopEventCallback<GallopEventMap['timeupdate']>;
|
|
13
|
+
onVolumeChange?: GallopEventCallback<GallopEventMap['volumechange']>;
|
|
14
|
+
onQualityChange?: GallopEventCallback<GallopEventMap['qualitychange']>;
|
|
15
|
+
onEngineStats?: GallopEventCallback<GallopEventMap['enginestats']>;
|
|
16
|
+
onError?: GallopEventCallback<GallopEventMap['error']>;
|
|
17
|
+
onReady?: () => void;
|
|
18
|
+
onFullscreenChange?: GallopEventCallback<GallopEventMap['fullscreenchange']>;
|
|
19
|
+
onStatusChange?: GallopEventCallback<GallopEventMap['statuschange']>;
|
|
20
|
+
}
|
|
21
|
+
interface GallopPlayerHandle {
|
|
22
|
+
play: () => void;
|
|
23
|
+
pause: () => void;
|
|
24
|
+
seek: (time: number) => void;
|
|
25
|
+
toggleFullscreen: () => void;
|
|
26
|
+
getCore: () => GallopPlayerCore | null;
|
|
27
|
+
}
|
|
28
|
+
declare const GallopPlayer: react.ForwardRefExoticComponent<GallopPlayerProps & react.RefAttributes<GallopPlayerHandle>>;
|
|
29
|
+
declare function useGallopPlayer(config: GallopConfig): {
|
|
30
|
+
containerRef: react.RefObject<HTMLDivElement>;
|
|
31
|
+
getPlayer: () => GallopPlayerCore | null;
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
export { GallopConfig, GallopEventMap, GallopPlayer, GallopPlayerCore, type GallopPlayerHandle, type GallopPlayerProps, useGallopPlayer };
|
package/dist/react.d.ts
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import * as react from 'react';
|
|
2
|
+
import { GallopPlayerCore } from './index.js';
|
|
3
|
+
import { b as GallopConfig, c as GallopEventCallback, d as GallopEventMap } from './types-D9Oqcpr1.js';
|
|
4
|
+
import './EventEmitter-CkfpgRij.js';
|
|
5
|
+
|
|
6
|
+
interface GallopPlayerProps extends GallopConfig {
|
|
7
|
+
className?: string;
|
|
8
|
+
style?: React.CSSProperties;
|
|
9
|
+
onPlay?: () => void;
|
|
10
|
+
onPause?: () => void;
|
|
11
|
+
onEnded?: () => void;
|
|
12
|
+
onTimeUpdate?: GallopEventCallback<GallopEventMap['timeupdate']>;
|
|
13
|
+
onVolumeChange?: GallopEventCallback<GallopEventMap['volumechange']>;
|
|
14
|
+
onQualityChange?: GallopEventCallback<GallopEventMap['qualitychange']>;
|
|
15
|
+
onEngineStats?: GallopEventCallback<GallopEventMap['enginestats']>;
|
|
16
|
+
onError?: GallopEventCallback<GallopEventMap['error']>;
|
|
17
|
+
onReady?: () => void;
|
|
18
|
+
onFullscreenChange?: GallopEventCallback<GallopEventMap['fullscreenchange']>;
|
|
19
|
+
onStatusChange?: GallopEventCallback<GallopEventMap['statuschange']>;
|
|
20
|
+
}
|
|
21
|
+
interface GallopPlayerHandle {
|
|
22
|
+
play: () => void;
|
|
23
|
+
pause: () => void;
|
|
24
|
+
seek: (time: number) => void;
|
|
25
|
+
toggleFullscreen: () => void;
|
|
26
|
+
getCore: () => GallopPlayerCore | null;
|
|
27
|
+
}
|
|
28
|
+
declare const GallopPlayer: react.ForwardRefExoticComponent<GallopPlayerProps & react.RefAttributes<GallopPlayerHandle>>;
|
|
29
|
+
declare function useGallopPlayer(config: GallopConfig): {
|
|
30
|
+
containerRef: react.RefObject<HTMLDivElement>;
|
|
31
|
+
getPlayer: () => GallopPlayerCore | null;
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
export { GallopConfig, GallopEventMap, GallopPlayer, GallopPlayerCore, type GallopPlayerHandle, type GallopPlayerProps, useGallopPlayer };
|
package/dist/react.js
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { GallopPlayerCore } from './chunk-QTV4W7FA.js';
|
|
2
|
+
import './chunk-SQPWH6EI.js';
|
|
3
|
+
import { forwardRef, useRef, useImperativeHandle, useEffect, useCallback } from 'react';
|
|
4
|
+
import { jsx } from 'react/jsx-runtime';
|
|
5
|
+
|
|
6
|
+
var GallopPlayer = forwardRef(
|
|
7
|
+
function GallopPlayer2(props, ref) {
|
|
8
|
+
const containerRef = useRef(null);
|
|
9
|
+
const playerRef = useRef(null);
|
|
10
|
+
const {
|
|
11
|
+
className,
|
|
12
|
+
style,
|
|
13
|
+
onPlay,
|
|
14
|
+
onPause,
|
|
15
|
+
onEnded,
|
|
16
|
+
onTimeUpdate,
|
|
17
|
+
onVolumeChange,
|
|
18
|
+
onQualityChange,
|
|
19
|
+
onEngineStats,
|
|
20
|
+
onError,
|
|
21
|
+
onReady,
|
|
22
|
+
onFullscreenChange,
|
|
23
|
+
onStatusChange,
|
|
24
|
+
...config
|
|
25
|
+
} = props;
|
|
26
|
+
useImperativeHandle(ref, () => ({
|
|
27
|
+
play: () => playerRef.current?.play(),
|
|
28
|
+
pause: () => playerRef.current?.pause(),
|
|
29
|
+
seek: (time) => playerRef.current?.seek(time),
|
|
30
|
+
toggleFullscreen: () => playerRef.current?.toggleFullscreen(),
|
|
31
|
+
getCore: () => playerRef.current
|
|
32
|
+
}));
|
|
33
|
+
useEffect(() => {
|
|
34
|
+
const container = containerRef.current;
|
|
35
|
+
if (!container) return;
|
|
36
|
+
const player = new GallopPlayerCore(container, config);
|
|
37
|
+
playerRef.current = player;
|
|
38
|
+
if (onPlay) player.on("play", onPlay);
|
|
39
|
+
if (onPause) player.on("pause", onPause);
|
|
40
|
+
if (onEnded) player.on("ended", onEnded);
|
|
41
|
+
if (onTimeUpdate) player.on("timeupdate", onTimeUpdate);
|
|
42
|
+
if (onVolumeChange) player.on("volumechange", onVolumeChange);
|
|
43
|
+
if (onQualityChange) player.on("qualitychange", onQualityChange);
|
|
44
|
+
if (onEngineStats) player.on("enginestats", onEngineStats);
|
|
45
|
+
if (onError) player.on("error", onError);
|
|
46
|
+
if (onReady) player.on("ready", onReady);
|
|
47
|
+
if (onFullscreenChange) player.on("fullscreenchange", onFullscreenChange);
|
|
48
|
+
if (onStatusChange) player.on("statuschange", onStatusChange);
|
|
49
|
+
return () => {
|
|
50
|
+
player.destroy();
|
|
51
|
+
playerRef.current = null;
|
|
52
|
+
};
|
|
53
|
+
}, [props.videoId, props.src, props.apiKey]);
|
|
54
|
+
return /* @__PURE__ */ jsx("div", { ref: containerRef, className, style });
|
|
55
|
+
}
|
|
56
|
+
);
|
|
57
|
+
function useGallopPlayer(config) {
|
|
58
|
+
const containerRef = useRef(null);
|
|
59
|
+
const playerRef = useRef(null);
|
|
60
|
+
useEffect(() => {
|
|
61
|
+
const container = containerRef.current;
|
|
62
|
+
if (!container) return;
|
|
63
|
+
const player = new GallopPlayerCore(container, config);
|
|
64
|
+
playerRef.current = player;
|
|
65
|
+
return () => {
|
|
66
|
+
player.destroy();
|
|
67
|
+
playerRef.current = null;
|
|
68
|
+
};
|
|
69
|
+
}, [config.videoId, config.src, config.apiKey]);
|
|
70
|
+
const getPlayer = useCallback(() => playerRef.current, []);
|
|
71
|
+
return { containerRef, getPlayer };
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
export { GallopPlayer, useGallopPlayer };
|