react-native-video-provider 0.1.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/AuVideo.podspec +28 -0
- package/LICENSE +20 -0
- package/README.md +183 -0
- package/android/build.gradle +59 -0
- package/android/src/main/AndroidManifest.xml +2 -0
- package/android/src/main/java/com/auvideo/AuVideoModule.kt +259 -0
- package/android/src/main/java/com/auvideo/AuVideoPackage.kt +35 -0
- package/android/src/main/java/com/auvideo/AuVideoSurfaceView.kt +40 -0
- package/android/src/main/java/com/auvideo/AuVideoSurfaceViewManager.kt +38 -0
- package/android/src/main/java/com/auvideo/PlayerCore.kt +366 -0
- package/android/src/main/java/com/auvideo/SurfaceRegistry.kt +26 -0
- package/android/src/main/res/layout/au_video_player_view.xml +10 -0
- package/ios/AuVideo.h +10 -0
- package/ios/AuVideo.mm +232 -0
- package/ios/AuVideoOrientation.swift +59 -0
- package/ios/AuVideoPlayerCore.swift +415 -0
- package/ios/AuVideoSurfaceRegistry.swift +30 -0
- package/ios/AuVideoSurfaceView.h +15 -0
- package/ios/AuVideoSurfaceView.mm +63 -0
- package/lib/module/AuVideoSurfaceNativeComponent.ts +8 -0
- package/lib/module/NativeAuVideo.js +5 -0
- package/lib/module/NativeAuVideo.js.map +1 -0
- package/lib/module/components/FloatingPlayer.js +119 -0
- package/lib/module/components/FloatingPlayer.js.map +1 -0
- package/lib/module/components/FullscreenPlayer.js +59 -0
- package/lib/module/components/FullscreenPlayer.js.map +1 -0
- package/lib/module/components/GestureOverlay.js +56 -0
- package/lib/module/components/GestureOverlay.js.map +1 -0
- package/lib/module/components/MiniPlayer.js +89 -0
- package/lib/module/components/MiniPlayer.js.map +1 -0
- package/lib/module/components/VideoControls.js +191 -0
- package/lib/module/components/VideoControls.js.map +1 -0
- package/lib/module/components/VideoPlayer.js +65 -0
- package/lib/module/components/VideoPlayer.js.map +1 -0
- package/lib/module/components/VideoSurface.js +35 -0
- package/lib/module/components/VideoSurface.js.map +1 -0
- package/lib/module/core/VideoManager.js +436 -0
- package/lib/module/core/VideoManager.js.map +1 -0
- package/lib/module/hooks/useFullscreen.js +19 -0
- package/lib/module/hooks/useFullscreen.js.map +1 -0
- package/lib/module/hooks/usePiP.js +17 -0
- package/lib/module/hooks/usePiP.js.map +1 -0
- package/lib/module/hooks/usePlayback.js +21 -0
- package/lib/module/hooks/usePlayback.js.map +1 -0
- package/lib/module/hooks/useVideo.js +17 -0
- package/lib/module/hooks/useVideo.js.map +1 -0
- package/lib/module/hooks/useVideoEvents.js +26 -0
- package/lib/module/hooks/useVideoEvents.js.map +1 -0
- package/lib/module/index.js +19 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/package.json +1 -0
- package/lib/module/provider/VideoContext.js +14 -0
- package/lib/module/provider/VideoContext.js.map +1 -0
- package/lib/module/provider/VideoProvider.js +36 -0
- package/lib/module/provider/VideoProvider.js.map +1 -0
- package/lib/module/state/createVideoStore.js +33 -0
- package/lib/module/state/createVideoStore.js.map +1 -0
- package/lib/module/types/events.js +4 -0
- package/lib/module/types/events.js.map +1 -0
- package/lib/module/types/index.js +2 -0
- package/lib/module/types/index.js.map +1 -0
- package/lib/module/types/video.js +2 -0
- package/lib/module/types/video.js.map +1 -0
- package/lib/module/utils/Emitter.js +39 -0
- package/lib/module/utils/Emitter.js.map +1 -0
- package/lib/module/utils/formatTime.js +15 -0
- package/lib/module/utils/formatTime.js.map +1 -0
- package/lib/typescript/package.json +1 -0
- package/lib/typescript/src/AuVideoSurfaceNativeComponent.d.ts +8 -0
- package/lib/typescript/src/AuVideoSurfaceNativeComponent.d.ts.map +1 -0
- package/lib/typescript/src/NativeAuVideo.d.ts +85 -0
- package/lib/typescript/src/NativeAuVideo.d.ts.map +1 -0
- package/lib/typescript/src/components/FloatingPlayer.d.ts +12 -0
- package/lib/typescript/src/components/FloatingPlayer.d.ts.map +1 -0
- package/lib/typescript/src/components/FullscreenPlayer.d.ts +12 -0
- package/lib/typescript/src/components/FullscreenPlayer.d.ts.map +1 -0
- package/lib/typescript/src/components/GestureOverlay.d.ts +14 -0
- package/lib/typescript/src/components/GestureOverlay.d.ts.map +1 -0
- package/lib/typescript/src/components/MiniPlayer.d.ts +16 -0
- package/lib/typescript/src/components/MiniPlayer.d.ts.map +1 -0
- package/lib/typescript/src/components/VideoControls.d.ts +17 -0
- package/lib/typescript/src/components/VideoControls.d.ts.map +1 -0
- package/lib/typescript/src/components/VideoPlayer.d.ts +27 -0
- package/lib/typescript/src/components/VideoPlayer.d.ts.map +1 -0
- package/lib/typescript/src/components/VideoSurface.d.ts +18 -0
- package/lib/typescript/src/components/VideoSurface.d.ts.map +1 -0
- package/lib/typescript/src/core/VideoManager.d.ts +88 -0
- package/lib/typescript/src/core/VideoManager.d.ts.map +1 -0
- package/lib/typescript/src/hooks/useFullscreen.d.ts +7 -0
- package/lib/typescript/src/hooks/useFullscreen.d.ts.map +1 -0
- package/lib/typescript/src/hooks/usePiP.d.ts +6 -0
- package/lib/typescript/src/hooks/usePiP.d.ts.map +1 -0
- package/lib/typescript/src/hooks/usePlayback.d.ts +13 -0
- package/lib/typescript/src/hooks/usePlayback.d.ts.map +1 -0
- package/lib/typescript/src/hooks/useVideo.d.ts +13 -0
- package/lib/typescript/src/hooks/useVideo.d.ts.map +1 -0
- package/lib/typescript/src/hooks/useVideoEvents.d.ts +14 -0
- package/lib/typescript/src/hooks/useVideoEvents.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +18 -0
- package/lib/typescript/src/index.d.ts.map +1 -0
- package/lib/typescript/src/provider/VideoContext.d.ts +8 -0
- package/lib/typescript/src/provider/VideoContext.d.ts.map +1 -0
- package/lib/typescript/src/provider/VideoProvider.d.ts +18 -0
- package/lib/typescript/src/provider/VideoProvider.d.ts.map +1 -0
- package/lib/typescript/src/state/createVideoStore.d.ts +6 -0
- package/lib/typescript/src/state/createVideoStore.d.ts.map +1 -0
- package/lib/typescript/src/types/events.d.ts +46 -0
- package/lib/typescript/src/types/events.d.ts.map +1 -0
- package/lib/typescript/src/types/index.d.ts +3 -0
- package/lib/typescript/src/types/index.d.ts.map +1 -0
- package/lib/typescript/src/types/video.d.ts +70 -0
- package/lib/typescript/src/types/video.d.ts.map +1 -0
- package/lib/typescript/src/utils/Emitter.d.ts +15 -0
- package/lib/typescript/src/utils/Emitter.d.ts.map +1 -0
- package/lib/typescript/src/utils/formatTime.d.ts +2 -0
- package/lib/typescript/src/utils/formatTime.d.ts.map +1 -0
- package/package.json +154 -0
- package/src/AuVideoSurfaceNativeComponent.ts +8 -0
- package/src/NativeAuVideo.ts +106 -0
- package/src/components/FloatingPlayer.tsx +130 -0
- package/src/components/FullscreenPlayer.tsx +64 -0
- package/src/components/GestureOverlay.tsx +76 -0
- package/src/components/MiniPlayer.tsx +93 -0
- package/src/components/VideoControls.tsx +213 -0
- package/src/components/VideoPlayer.tsx +77 -0
- package/src/components/VideoSurface.tsx +39 -0
- package/src/core/VideoManager.ts +441 -0
- package/src/hooks/useFullscreen.ts +14 -0
- package/src/hooks/usePiP.ts +13 -0
- package/src/hooks/usePlayback.ts +26 -0
- package/src/hooks/useVideo.ts +16 -0
- package/src/hooks/useVideoEvents.ts +33 -0
- package/src/index.ts +54 -0
- package/src/provider/VideoContext.ts +12 -0
- package/src/provider/VideoProvider.tsx +41 -0
- package/src/state/createVideoStore.ts +33 -0
- package/src/types/events.ts +22 -0
- package/src/types/index.ts +11 -0
- package/src/types/video.ts +85 -0
- package/src/utils/Emitter.ts +51 -0
- package/src/utils/formatTime.ts +12 -0
|
@@ -0,0 +1,436 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import NativeAuVideo from "../NativeAuVideo.js";
|
|
4
|
+
import { createVideoStore, initialVideoState } from "../state/createVideoStore.js";
|
|
5
|
+
import { Emitter } from "../utils/Emitter.js";
|
|
6
|
+
|
|
7
|
+
/** Surface id used by the built-in fullscreen host. */
|
|
8
|
+
export const FULLSCREEN_SURFACE_ID = '__au_fullscreen__';
|
|
9
|
+
/** Surface id used by the built-in floating host. */
|
|
10
|
+
export const FLOATING_SURFACE_ID = '__au_floating__';
|
|
11
|
+
const RESERVED_SURFACES = new Set([FULLSCREEN_SURFACE_ID, FLOATING_SURFACE_ID]);
|
|
12
|
+
function toNativeSource(source) {
|
|
13
|
+
return {
|
|
14
|
+
id: source.id,
|
|
15
|
+
uri: source.uri,
|
|
16
|
+
headers: source.headers,
|
|
17
|
+
title: source.title,
|
|
18
|
+
artist: source.artist,
|
|
19
|
+
artworkUri: source.artworkUri,
|
|
20
|
+
startPosition: source.startPosition
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* The single owner of the native playback engine on the JS side.
|
|
26
|
+
*
|
|
27
|
+
* React components never talk to the native module directly — they issue
|
|
28
|
+
* commands here and subscribe to `store` for state. The manager exists for
|
|
29
|
+
* the whole app lifetime; unmounting React trees never destroys it.
|
|
30
|
+
*/
|
|
31
|
+
export class VideoManager {
|
|
32
|
+
static instance = null;
|
|
33
|
+
static get shared() {
|
|
34
|
+
if (!VideoManager.instance) {
|
|
35
|
+
VideoManager.instance = new VideoManager();
|
|
36
|
+
}
|
|
37
|
+
return VideoManager.instance;
|
|
38
|
+
}
|
|
39
|
+
store = createVideoStore();
|
|
40
|
+
events = new Emitter();
|
|
41
|
+
nativeSubscriptions = [];
|
|
42
|
+
initialized = false;
|
|
43
|
+
config = {
|
|
44
|
+
fullscreenHost: true,
|
|
45
|
+
floatingHost: true,
|
|
46
|
+
pauseOnDetach: false
|
|
47
|
+
};
|
|
48
|
+
/** Last non-reserved surface, restored after fullscreen/floating exits. */
|
|
49
|
+
lastInlineSurfaceId = null;
|
|
50
|
+
constructor() {}
|
|
51
|
+
get providerConfig() {
|
|
52
|
+
return this.config;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Idempotent. Called by VideoProvider on mount ("mount silently"):
|
|
57
|
+
* creates the native player once and wires native events.
|
|
58
|
+
*/
|
|
59
|
+
init(config) {
|
|
60
|
+
this.config = {
|
|
61
|
+
...this.config,
|
|
62
|
+
...config
|
|
63
|
+
};
|
|
64
|
+
if (this.initialized) {
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
this.initialized = true;
|
|
68
|
+
NativeAuVideo.nativeInit();
|
|
69
|
+
this.subscribeNative();
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
// ---------------------------------------------------------------- events
|
|
73
|
+
|
|
74
|
+
addListener(event, listener) {
|
|
75
|
+
return this.events.addListener(event, listener);
|
|
76
|
+
}
|
|
77
|
+
subscribeNative() {
|
|
78
|
+
const subs = this.nativeSubscriptions;
|
|
79
|
+
subs.push(NativeAuVideo.onStatusChange(e => {
|
|
80
|
+
this.applyStatus(e.status);
|
|
81
|
+
}));
|
|
82
|
+
subs.push(NativeAuVideo.onLoad(e => {
|
|
83
|
+
this.set({
|
|
84
|
+
duration: e.duration,
|
|
85
|
+
videoWidth: e.width,
|
|
86
|
+
videoHeight: e.height,
|
|
87
|
+
loading: false
|
|
88
|
+
});
|
|
89
|
+
this.events.emit('onLoad', e);
|
|
90
|
+
this.events.emit('onReady', {
|
|
91
|
+
videoId: e.videoId
|
|
92
|
+
});
|
|
93
|
+
}));
|
|
94
|
+
subs.push(NativeAuVideo.onProgress(e => {
|
|
95
|
+
this.set({
|
|
96
|
+
position: e.position,
|
|
97
|
+
duration: e.duration,
|
|
98
|
+
buffered: e.buffered
|
|
99
|
+
});
|
|
100
|
+
this.events.emit('onProgress', e);
|
|
101
|
+
}));
|
|
102
|
+
subs.push(NativeAuVideo.onSeek(e => {
|
|
103
|
+
this.set({
|
|
104
|
+
position: e.position
|
|
105
|
+
});
|
|
106
|
+
this.events.emit('onSeek', e);
|
|
107
|
+
}));
|
|
108
|
+
subs.push(NativeAuVideo.onEnd(() => {
|
|
109
|
+
this.applyStatus('ended');
|
|
110
|
+
this.events.emit('onEnd', undefined);
|
|
111
|
+
}));
|
|
112
|
+
subs.push(NativeAuVideo.onError(e => {
|
|
113
|
+
this.set({
|
|
114
|
+
error: e,
|
|
115
|
+
status: 'error',
|
|
116
|
+
playing: false,
|
|
117
|
+
loading: false
|
|
118
|
+
});
|
|
119
|
+
this.events.emit('onError', e);
|
|
120
|
+
}));
|
|
121
|
+
subs.push(NativeAuVideo.onAttach(e => {
|
|
122
|
+
this.events.emit('onAttach', e);
|
|
123
|
+
}));
|
|
124
|
+
subs.push(NativeAuVideo.onDetach(e => {
|
|
125
|
+
this.events.emit('onDetach', e);
|
|
126
|
+
if (this.config.pauseOnDetach) {
|
|
127
|
+
this.pause();
|
|
128
|
+
}
|
|
129
|
+
}));
|
|
130
|
+
subs.push(NativeAuVideo.onPipChange(e => {
|
|
131
|
+
this.set({
|
|
132
|
+
pip: e.active
|
|
133
|
+
});
|
|
134
|
+
this.setMode(e.active ? 'pip' : this.deriveMode({
|
|
135
|
+
pip: false
|
|
136
|
+
}));
|
|
137
|
+
this.events.emit('onPipChanged', e);
|
|
138
|
+
}));
|
|
139
|
+
}
|
|
140
|
+
applyStatus(status) {
|
|
141
|
+
const prev = this.store.getState();
|
|
142
|
+
this.set({
|
|
143
|
+
status,
|
|
144
|
+
playing: status === 'playing',
|
|
145
|
+
paused: status === 'paused',
|
|
146
|
+
buffering: status === 'buffering',
|
|
147
|
+
loading: status === 'loading',
|
|
148
|
+
error: status === 'error' ? prev.error : null
|
|
149
|
+
});
|
|
150
|
+
if (status === 'playing' && prev.status !== 'playing') {
|
|
151
|
+
this.events.emit('onPlay', undefined);
|
|
152
|
+
}
|
|
153
|
+
if (status === 'paused' && prev.status !== 'paused') {
|
|
154
|
+
this.events.emit('onPause', undefined);
|
|
155
|
+
}
|
|
156
|
+
if (status === 'buffering' !== (prev.status === 'buffering')) {
|
|
157
|
+
this.events.emit('onBuffer', {
|
|
158
|
+
buffering: status === 'buffering'
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
// -------------------------------------------------------------- commands
|
|
164
|
+
|
|
165
|
+
/**
|
|
166
|
+
* Load a video. Same-video handoff: if `source.id` equals the current
|
|
167
|
+
* video's id the engine is untouched — position, buffer and play state
|
|
168
|
+
* survive. Pass `surfaceId` to attach in the same call.
|
|
169
|
+
*/
|
|
170
|
+
setSource(source, options) {
|
|
171
|
+
const autoplay = options?.autoplay ?? true;
|
|
172
|
+
const current = this.store.getState().currentVideo;
|
|
173
|
+
const sameVideo = current?.id === source.id;
|
|
174
|
+
if (!sameVideo) {
|
|
175
|
+
this.set({
|
|
176
|
+
currentVideo: source,
|
|
177
|
+
status: 'loading',
|
|
178
|
+
loading: true,
|
|
179
|
+
position: source.startPosition ?? 0,
|
|
180
|
+
duration: 0,
|
|
181
|
+
buffered: 0,
|
|
182
|
+
error: null
|
|
183
|
+
});
|
|
184
|
+
NativeAuVideo.setSource(toNativeSource(source), autoplay);
|
|
185
|
+
this.events.emit('onVideoChanged', {
|
|
186
|
+
video: source
|
|
187
|
+
});
|
|
188
|
+
} else if (autoplay && !this.store.getState().playing) {
|
|
189
|
+
this.play();
|
|
190
|
+
}
|
|
191
|
+
if (options?.surfaceId) {
|
|
192
|
+
this.attach(options.surfaceId);
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
/** Warm a source without rendering or touching current playback. */
|
|
197
|
+
preload(source) {
|
|
198
|
+
NativeAuVideo.preload(toNativeSource(source));
|
|
199
|
+
}
|
|
200
|
+
play() {
|
|
201
|
+
NativeAuVideo.play();
|
|
202
|
+
}
|
|
203
|
+
pause() {
|
|
204
|
+
NativeAuVideo.pause();
|
|
205
|
+
}
|
|
206
|
+
resume() {
|
|
207
|
+
NativeAuVideo.play();
|
|
208
|
+
}
|
|
209
|
+
toggle() {
|
|
210
|
+
if (this.store.getState().playing) {
|
|
211
|
+
this.pause();
|
|
212
|
+
} else {
|
|
213
|
+
this.play();
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
stop() {
|
|
217
|
+
NativeAuVideo.stop();
|
|
218
|
+
this.set({
|
|
219
|
+
position: 0,
|
|
220
|
+
playing: false,
|
|
221
|
+
status: 'idle'
|
|
222
|
+
});
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
/** @param position seconds */
|
|
226
|
+
seek(position) {
|
|
227
|
+
const duration = this.store.getState().duration;
|
|
228
|
+
const clamped = Math.max(0, duration > 0 ? Math.min(position, duration) : position);
|
|
229
|
+
this.set({
|
|
230
|
+
position: clamped
|
|
231
|
+
});
|
|
232
|
+
NativeAuVideo.seekTo(clamped);
|
|
233
|
+
}
|
|
234
|
+
seekBy(offset) {
|
|
235
|
+
this.seek(this.store.getState().position + offset);
|
|
236
|
+
}
|
|
237
|
+
setRate(rate) {
|
|
238
|
+
this.set({
|
|
239
|
+
rate
|
|
240
|
+
});
|
|
241
|
+
NativeAuVideo.setRate(rate);
|
|
242
|
+
}
|
|
243
|
+
setVolume(volume) {
|
|
244
|
+
const clamped = Math.max(0, Math.min(volume, 1));
|
|
245
|
+
this.set({
|
|
246
|
+
volume: clamped
|
|
247
|
+
});
|
|
248
|
+
NativeAuVideo.setVolume(clamped);
|
|
249
|
+
}
|
|
250
|
+
mute() {
|
|
251
|
+
this.set({
|
|
252
|
+
muted: true
|
|
253
|
+
});
|
|
254
|
+
NativeAuVideo.setMuted(true);
|
|
255
|
+
}
|
|
256
|
+
unmute() {
|
|
257
|
+
this.set({
|
|
258
|
+
muted: false
|
|
259
|
+
});
|
|
260
|
+
NativeAuVideo.setMuted(false);
|
|
261
|
+
}
|
|
262
|
+
setRepeat(repeat) {
|
|
263
|
+
this.set({
|
|
264
|
+
repeat
|
|
265
|
+
});
|
|
266
|
+
NativeAuVideo.setRepeat(repeat);
|
|
267
|
+
}
|
|
268
|
+
setResizeMode(mode) {
|
|
269
|
+
this.set({
|
|
270
|
+
resizeMode: mode
|
|
271
|
+
});
|
|
272
|
+
NativeAuVideo.setResizeMode(mode);
|
|
273
|
+
}
|
|
274
|
+
async getPosition() {
|
|
275
|
+
return NativeAuVideo.getPosition();
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
// -------------------------------------------------------------- surfaces
|
|
279
|
+
|
|
280
|
+
/** Re-parent the player into the surface registered under `surfaceId`. */
|
|
281
|
+
attach(surfaceId) {
|
|
282
|
+
if (!RESERVED_SURFACES.has(surfaceId)) {
|
|
283
|
+
this.lastInlineSurfaceId = surfaceId;
|
|
284
|
+
}
|
|
285
|
+
this.set({
|
|
286
|
+
surfaceId
|
|
287
|
+
});
|
|
288
|
+
this.setMode(this.deriveMode({}));
|
|
289
|
+
NativeAuVideo.attach(surfaceId);
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
/** Detach from any surface. Playback continues (audio) unless configured otherwise. */
|
|
293
|
+
detach() {
|
|
294
|
+
this.set({
|
|
295
|
+
surfaceId: null
|
|
296
|
+
});
|
|
297
|
+
this.setMode('hidden');
|
|
298
|
+
NativeAuVideo.detach();
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
/**
|
|
302
|
+
* Called by VideoSurface on unmount. Only clears JS state when the
|
|
303
|
+
* unmounting surface is the active one; the native registry has already
|
|
304
|
+
* dropped its weak reference.
|
|
305
|
+
*/
|
|
306
|
+
handleSurfaceUnmount(surfaceId) {
|
|
307
|
+
const state = this.store.getState();
|
|
308
|
+
if (state.surfaceId === surfaceId) {
|
|
309
|
+
this.set({
|
|
310
|
+
surfaceId: null
|
|
311
|
+
});
|
|
312
|
+
if (this.config.pauseOnDetach) {
|
|
313
|
+
this.pause();
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
if (this.lastInlineSurfaceId === surfaceId) {
|
|
317
|
+
this.lastInlineSurfaceId = null;
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
// ------------------------------------------------------------ modes
|
|
322
|
+
|
|
323
|
+
/**
|
|
324
|
+
* Show the built-in fullscreen host and unlock device rotation.
|
|
325
|
+
* The host mounts a surface and attaches automatically.
|
|
326
|
+
*/
|
|
327
|
+
enterFullscreen() {
|
|
328
|
+
if (this.store.getState().fullscreen) {
|
|
329
|
+
return;
|
|
330
|
+
}
|
|
331
|
+
this.set({
|
|
332
|
+
fullscreen: true,
|
|
333
|
+
floating: false
|
|
334
|
+
});
|
|
335
|
+
this.setMode('fullscreen');
|
|
336
|
+
NativeAuVideo.enterFullscreen();
|
|
337
|
+
this.events.emit('onEnterFullscreen', undefined);
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
/** Restore the previous orientation lock and re-attach the previous surface. */
|
|
341
|
+
exitFullscreen() {
|
|
342
|
+
if (!this.store.getState().fullscreen) {
|
|
343
|
+
return;
|
|
344
|
+
}
|
|
345
|
+
NativeAuVideo.exitFullscreen();
|
|
346
|
+
this.set({
|
|
347
|
+
fullscreen: false
|
|
348
|
+
});
|
|
349
|
+
this.events.emit('onExitFullscreen', undefined);
|
|
350
|
+
this.restoreInlineSurface();
|
|
351
|
+
}
|
|
352
|
+
toggleFullscreen() {
|
|
353
|
+
if (this.store.getState().fullscreen) {
|
|
354
|
+
this.exitFullscreen();
|
|
355
|
+
} else {
|
|
356
|
+
this.enterFullscreen();
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
showFloating() {
|
|
360
|
+
if (this.store.getState().floating) {
|
|
361
|
+
return;
|
|
362
|
+
}
|
|
363
|
+
this.set({
|
|
364
|
+
floating: true,
|
|
365
|
+
fullscreen: false
|
|
366
|
+
});
|
|
367
|
+
this.setMode('floating');
|
|
368
|
+
}
|
|
369
|
+
hideFloating() {
|
|
370
|
+
if (!this.store.getState().floating) {
|
|
371
|
+
return;
|
|
372
|
+
}
|
|
373
|
+
this.set({
|
|
374
|
+
floating: false
|
|
375
|
+
});
|
|
376
|
+
this.restoreInlineSurface();
|
|
377
|
+
}
|
|
378
|
+
async enterPiP() {
|
|
379
|
+
return NativeAuVideo.enterPip();
|
|
380
|
+
}
|
|
381
|
+
exitPiP() {
|
|
382
|
+
NativeAuVideo.exitPip();
|
|
383
|
+
}
|
|
384
|
+
restoreInlineSurface() {
|
|
385
|
+
if (this.lastInlineSurfaceId) {
|
|
386
|
+
this.attach(this.lastInlineSurfaceId);
|
|
387
|
+
} else {
|
|
388
|
+
this.set({
|
|
389
|
+
surfaceId: null
|
|
390
|
+
});
|
|
391
|
+
this.setMode('hidden');
|
|
392
|
+
}
|
|
393
|
+
}
|
|
394
|
+
deriveMode(override) {
|
|
395
|
+
const s = {
|
|
396
|
+
...this.store.getState(),
|
|
397
|
+
...override
|
|
398
|
+
};
|
|
399
|
+
if (s.pip) return 'pip';
|
|
400
|
+
if (s.fullscreen) return 'fullscreen';
|
|
401
|
+
if (s.floating) return 'floating';
|
|
402
|
+
if (s.surfaceId) return 'inline';
|
|
403
|
+
return 'hidden';
|
|
404
|
+
}
|
|
405
|
+
setMode(mode) {
|
|
406
|
+
if (this.store.getState().mode !== mode) {
|
|
407
|
+
this.set({
|
|
408
|
+
mode
|
|
409
|
+
});
|
|
410
|
+
this.events.emit('onModeChanged', {
|
|
411
|
+
mode
|
|
412
|
+
});
|
|
413
|
+
}
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
// ------------------------------------------------------------ lifecycle
|
|
417
|
+
|
|
418
|
+
/** Tear the native player down entirely. Rarely needed. */
|
|
419
|
+
destroy() {
|
|
420
|
+
for (const sub of this.nativeSubscriptions) {
|
|
421
|
+
sub.remove();
|
|
422
|
+
}
|
|
423
|
+
this.nativeSubscriptions = [];
|
|
424
|
+
this.events.removeAll();
|
|
425
|
+
this.initialized = false;
|
|
426
|
+
this.lastInlineSurfaceId = null;
|
|
427
|
+
NativeAuVideo.releasePlayer();
|
|
428
|
+
this.store.setState({
|
|
429
|
+
...initialVideoState
|
|
430
|
+
}, true);
|
|
431
|
+
}
|
|
432
|
+
set(partial) {
|
|
433
|
+
this.store.setState(partial);
|
|
434
|
+
}
|
|
435
|
+
}
|
|
436
|
+
//# sourceMappingURL=VideoManager.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["NativeAuVideo","createVideoStore","initialVideoState","Emitter","FULLSCREEN_SURFACE_ID","FLOATING_SURFACE_ID","RESERVED_SURFACES","Set","toNativeSource","source","id","uri","headers","title","artist","artworkUri","startPosition","VideoManager","instance","shared","store","events","nativeSubscriptions","initialized","config","fullscreenHost","floatingHost","pauseOnDetach","lastInlineSurfaceId","constructor","providerConfig","init","nativeInit","subscribeNative","addListener","event","listener","subs","push","onStatusChange","e","applyStatus","status","onLoad","set","duration","videoWidth","width","videoHeight","height","loading","emit","videoId","onProgress","position","buffered","onSeek","onEnd","undefined","onError","error","playing","onAttach","onDetach","pause","onPipChange","pip","active","setMode","deriveMode","prev","getState","paused","buffering","setSource","options","autoplay","current","currentVideo","sameVideo","video","play","surfaceId","attach","preload","resume","toggle","stop","seek","clamped","Math","max","min","seekTo","seekBy","offset","setRate","rate","setVolume","volume","mute","muted","setMuted","unmute","setRepeat","repeat","setResizeMode","mode","resizeMode","getPosition","has","detach","handleSurfaceUnmount","state","enterFullscreen","fullscreen","floating","exitFullscreen","restoreInlineSurface","toggleFullscreen","showFloating","hideFloating","enterPiP","enterPip","exitPiP","exitPip","override","s","destroy","sub","remove","removeAll","releasePlayer","setState","partial"],"sourceRoot":"../../../src","sources":["core/VideoManager.ts"],"mappings":";;AACA,OAAOA,aAAa,MAAkC,qBAAkB;AACxE,SACEC,gBAAgB,EAChBC,iBAAiB,QAEZ,8BAA2B;AAWlC,SAASC,OAAO,QAA0C,qBAAkB;;AAE5E;AACA,OAAO,MAAMC,qBAAqB,GAAG,mBAAmB;AACxD;AACA,OAAO,MAAMC,mBAAmB,GAAG,iBAAiB;AAEpD,MAAMC,iBAAiB,GAAG,IAAIC,GAAG,CAAC,CAACH,qBAAqB,EAAEC,mBAAmB,CAAC,CAAC;AAE/E,SAASG,cAAcA,CAACC,MAAmB,EAAqB;EAC9D,OAAO;IACLC,EAAE,EAAED,MAAM,CAACC,EAAE;IACbC,GAAG,EAAEF,MAAM,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I,CAAC;EACrD;EAEQ0C,GAAGA,CAAC0F,OAA4B,EAAQ;IAC9C,IAAI,CAAClH,KAAK,CAACiH,QAAQ,CAACC,OAAO,CAAC;EAC9B;AACF","ignoreList":[]}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { useCallback } from 'react';
|
|
4
|
+
import { useVideoManager } from "../provider/VideoContext.js";
|
|
5
|
+
import { usePlayback } from "./usePlayback.js";
|
|
6
|
+
export function useFullscreen() {
|
|
7
|
+
const manager = useVideoManager();
|
|
8
|
+
const isFullscreen = usePlayback(s => s.fullscreen);
|
|
9
|
+
const enter = useCallback(() => manager.enterFullscreen(), [manager]);
|
|
10
|
+
const exit = useCallback(() => manager.exitFullscreen(), [manager]);
|
|
11
|
+
const toggle = useCallback(() => manager.toggleFullscreen(), [manager]);
|
|
12
|
+
return {
|
|
13
|
+
isFullscreen,
|
|
14
|
+
enter,
|
|
15
|
+
exit,
|
|
16
|
+
toggle
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=useFullscreen.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["useCallback","useVideoManager","usePlayback","useFullscreen","manager","isFullscreen","s","fullscreen","enter","enterFullscreen","exit","exitFullscreen","toggle","toggleFullscreen"],"sourceRoot":"../../../src","sources":["hooks/useFullscreen.ts"],"mappings":";;AAAA,SAASA,WAAW,QAAQ,OAAO;AACnC,SAASC,eAAe,QAAQ,6BAA0B;AAC1D,SAASC,WAAW,QAAQ,kBAAe;AAE3C,OAAO,SAASC,aAAaA,CAAA,EAAG;EAC9B,MAAMC,OAAO,GAAGH,eAAe,CAAC,CAAC;EACjC,MAAMI,YAAY,GAAGH,WAAW,CAAEI,CAAC,IAAKA,CAAC,CAACC,UAAU,CAAC;EAErD,MAAMC,KAAK,GAAGR,WAAW,CAAC,MAAMI,OAAO,CAACK,eAAe,CAAC,CAAC,EAAE,CAACL,OAAO,CAAC,CAAC;EACrE,MAAMM,IAAI,GAAGV,WAAW,CAAC,MAAMI,OAAO,CAACO,cAAc,CAAC,CAAC,EAAE,CAACP,OAAO,CAAC,CAAC;EACnE,MAAMQ,MAAM,GAAGZ,WAAW,CAAC,MAAMI,OAAO,CAACS,gBAAgB,CAAC,CAAC,EAAE,CAACT,OAAO,CAAC,CAAC;EAEvE,OAAO;IAAEC,YAAY;IAAEG,KAAK;IAAEE,IAAI;IAAEE;EAAO,CAAC;AAC9C","ignoreList":[]}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { useCallback } from 'react';
|
|
4
|
+
import { useVideoManager } from "../provider/VideoContext.js";
|
|
5
|
+
import { usePlayback } from "./usePlayback.js";
|
|
6
|
+
export function usePiP() {
|
|
7
|
+
const manager = useVideoManager();
|
|
8
|
+
const isActive = usePlayback(s => s.pip);
|
|
9
|
+
const enter = useCallback(() => manager.enterPiP(), [manager]);
|
|
10
|
+
const exit = useCallback(() => manager.exitPiP(), [manager]);
|
|
11
|
+
return {
|
|
12
|
+
isActive,
|
|
13
|
+
enter,
|
|
14
|
+
exit
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=usePiP.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["useCallback","useVideoManager","usePlayback","usePiP","manager","isActive","s","pip","enter","enterPiP","exit","exitPiP"],"sourceRoot":"../../../src","sources":["hooks/usePiP.ts"],"mappings":";;AAAA,SAASA,WAAW,QAAQ,OAAO;AACnC,SAASC,eAAe,QAAQ,6BAA0B;AAC1D,SAASC,WAAW,QAAQ,kBAAe;AAE3C,OAAO,SAASC,MAAMA,CAAA,EAAG;EACvB,MAAMC,OAAO,GAAGH,eAAe,CAAC,CAAC;EACjC,MAAMI,QAAQ,GAAGH,WAAW,CAAEI,CAAC,IAAKA,CAAC,CAACC,GAAG,CAAC;EAE1C,MAAMC,KAAK,GAAGR,WAAW,CAAC,MAAMI,OAAO,CAACK,QAAQ,CAAC,CAAC,EAAE,CAACL,OAAO,CAAC,CAAC;EAC9D,MAAMM,IAAI,GAAGV,WAAW,CAAC,MAAMI,OAAO,CAACO,OAAO,CAAC,CAAC,EAAE,CAACP,OAAO,CAAC,CAAC;EAE5D,OAAO;IAAEC,QAAQ;IAAEG,KAAK;IAAEE;EAAK,CAAC;AAClC","ignoreList":[]}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { useStore } from 'zustand';
|
|
4
|
+
import { useVideoManager } from "../provider/VideoContext.js";
|
|
5
|
+
const identity = s => s;
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Subscribe to playback state. Pass a selector so your component only
|
|
9
|
+
* re-renders for the fields it displays:
|
|
10
|
+
*
|
|
11
|
+
* ```tsx
|
|
12
|
+
* const position = usePlayback((s) => s.position);
|
|
13
|
+
* const { playing, duration } = usePlayback((s) => ({ ... }));
|
|
14
|
+
* ```
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
export function usePlayback(selector) {
|
|
18
|
+
const manager = useVideoManager();
|
|
19
|
+
return useStore(manager.store, selector ?? identity);
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=usePlayback.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["useStore","useVideoManager","identity","s","usePlayback","selector","manager","store"],"sourceRoot":"../../../src","sources":["hooks/usePlayback.ts"],"mappings":";;AAAA,SAASA,QAAQ,QAAQ,SAAS;AAClC,SAASC,eAAe,QAAQ,6BAA0B;AAG1D,MAAMC,QAAQ,GAAIC,CAAa,IAAiBA,CAAC;;AAEjD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA,OAAO,SAASC,WAAWA,CACzBC,QAAmC,EACnB;EAChB,MAAMC,OAAO,GAAGL,eAAe,CAAC,CAAC;EACjC,OAAOD,QAAQ,CACbM,OAAO,CAACC,KAAK,EACZF,QAAQ,IAAIH,QACf,CAAC;AACH","ignoreList":[]}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { useVideoManager } from "../provider/VideoContext.js";
|
|
4
|
+
/**
|
|
5
|
+
* Command API for the singleton player:
|
|
6
|
+
* `play, pause, resume, toggle, stop, seek, seekBy, setSource, preload,
|
|
7
|
+
* attach, detach, enterFullscreen, exitFullscreen, showFloating,
|
|
8
|
+
* hideFloating, enterPiP, exitPiP, setRate, setVolume, mute, unmute,
|
|
9
|
+
* setRepeat, setResizeMode, addListener, destroy` — plus `store` for
|
|
10
|
+
* imperative reads (`useVideo().store.getState()`).
|
|
11
|
+
*
|
|
12
|
+
* Commands never cause re-renders; subscribe with `usePlayback()` for state.
|
|
13
|
+
*/
|
|
14
|
+
export function useVideo() {
|
|
15
|
+
return useVideoManager();
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=useVideo.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["useVideoManager","useVideo"],"sourceRoot":"../../../src","sources":["hooks/useVideo.ts"],"mappings":";;AAAA,SAASA,eAAe,QAAQ,6BAA0B;AAG1D;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,QAAQA,CAAA,EAAiB;EACvC,OAAOD,eAAe,CAAC,CAAC;AAC1B","ignoreList":[]}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { useEffect, useRef } from 'react';
|
|
4
|
+
import { useVideoManager } from "../provider/VideoContext.js";
|
|
5
|
+
/**
|
|
6
|
+
* Subscribe to player events for the lifetime of the component.
|
|
7
|
+
* Handlers are kept in a ref, so inline functions are fine.
|
|
8
|
+
*
|
|
9
|
+
* ```tsx
|
|
10
|
+
* useVideoEvents({ onEnd: () => next(), onError: (e) => report(e) });
|
|
11
|
+
* ```
|
|
12
|
+
*/
|
|
13
|
+
export function useVideoEvents(handlers) {
|
|
14
|
+
const manager = useVideoManager();
|
|
15
|
+
const ref = useRef(handlers);
|
|
16
|
+
ref.current = handlers;
|
|
17
|
+
useEffect(() => {
|
|
18
|
+
const names = Object.keys(ref.current);
|
|
19
|
+
const subs = names.map(name => manager.addListener(name, payload => {
|
|
20
|
+
const handler = ref.current[name];
|
|
21
|
+
handler?.(payload);
|
|
22
|
+
}));
|
|
23
|
+
return () => subs.forEach(s => s.remove());
|
|
24
|
+
}, [manager]);
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=useVideoEvents.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["useEffect","useRef","useVideoManager","useVideoEvents","handlers","manager","ref","current","names","Object","keys","subs","map","name","addListener","payload","handler","forEach","s","remove"],"sourceRoot":"../../../src","sources":["hooks/useVideoEvents.ts"],"mappings":";;AAAA,SAASA,SAAS,EAAEC,MAAM,QAAQ,OAAO;AACzC,SAASC,eAAe,QAAQ,6BAA0B;AAO1D;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,cAAcA,CAACC,QAA4B,EAAQ;EACjE,MAAMC,OAAO,GAAGH,eAAe,CAAC,CAAC;EACjC,MAAMI,GAAG,GAAGL,MAAM,CAACG,QAAQ,CAAC;EAC5BE,GAAG,CAACC,OAAO,GAAGH,QAAQ;EAEtBJ,SAAS,CAAC,MAAM;IACd,MAAMQ,KAAK,GAAGC,MAAM,CAACC,IAAI,CAACJ,GAAG,CAACC,OAAO,CAAqB;IAC1D,MAAMI,IAAI,GAAGH,KAAK,CAACI,GAAG,CAAEC,IAAI,IAC1BR,OAAO,CAACS,WAAW,CAACD,IAAI,EAAGE,OAAO,IAAK;MACrC,MAAMC,OAAO,GAAGV,GAAG,CAACC,OAAO,CAACM,IAAI,CACuB;MACvDG,OAAO,GAAGD,OAAO,CAAC;IACpB,CAAC,CACH,CAAC;IACD,OAAO,MAAMJ,IAAI,CAACM,OAAO,CAAEC,CAAC,IAAKA,CAAC,CAACC,MAAM,CAAC,CAAC,CAAC;EAC9C,CAAC,EAAE,CAACd,OAAO,CAAC,CAAC;AACf","ignoreList":[]}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
export { VideoProvider } from "./provider/VideoProvider.js";
|
|
4
|
+
export { useVideoManager } from "./provider/VideoContext.js";
|
|
5
|
+
export { VideoManager, FULLSCREEN_SURFACE_ID, FLOATING_SURFACE_ID } from "./core/VideoManager.js";
|
|
6
|
+
export { VideoSurface } from "./components/VideoSurface.js";
|
|
7
|
+
export { VideoPlayer } from "./components/VideoPlayer.js";
|
|
8
|
+
export { FullscreenPlayer } from "./components/FullscreenPlayer.js";
|
|
9
|
+
export { FloatingPlayer } from "./components/FloatingPlayer.js";
|
|
10
|
+
export { MiniPlayer } from "./components/MiniPlayer.js";
|
|
11
|
+
export { VideoControls } from "./components/VideoControls.js";
|
|
12
|
+
export { GestureOverlay } from "./components/GestureOverlay.js";
|
|
13
|
+
export { useVideo } from "./hooks/useVideo.js";
|
|
14
|
+
export { usePlayback } from "./hooks/usePlayback.js";
|
|
15
|
+
export { useFullscreen } from "./hooks/useFullscreen.js";
|
|
16
|
+
export { usePiP } from "./hooks/usePiP.js";
|
|
17
|
+
export { useVideoEvents } from "./hooks/useVideoEvents.js";
|
|
18
|
+
export { formatTime } from "./utils/formatTime.js";
|
|
19
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["VideoProvider","useVideoManager","VideoManager","FULLSCREEN_SURFACE_ID","FLOATING_SURFACE_ID","VideoSurface","VideoPlayer","FullscreenPlayer","FloatingPlayer","MiniPlayer","VideoControls","GestureOverlay","useVideo","usePlayback","useFullscreen","usePiP","useVideoEvents","formatTime"],"sourceRoot":"../../src","sources":["index.ts"],"mappings":";;AAAA,SACEA,aAAa,QAER,6BAA0B;AACjC,SAASC,eAAe,QAAQ,4BAAyB;AACzD,SACEC,YAAY,EACZC,qBAAqB,EACrBC,mBAAmB,QACd,wBAAqB;AAE5B,SACEC,YAAY,QAEP,8BAA2B;AAClC,SAASC,WAAW,QAA+B,6BAA0B;AAC7E,SAASC,gBAAgB,QAAQ,kCAA+B;AAChE,SACEC,cAAc,QAET,gCAA6B;AACpC,SAASC,UAAU,QAA8B,4BAAyB;AAC1E,SACEC,aAAa,QAER,+BAA4B;AACnC,SACEC,cAAc,QAET,gCAA6B;AAEpC,SAASC,QAAQ,QAAQ,qBAAkB;AAC3C,SAASC,WAAW,QAAQ,wBAAqB;AACjD,SAASC,aAAa,QAAQ,0BAAuB;AACrD,SAASC,MAAM,QAAQ,mBAAgB;AACvC,SACEC,cAAc,QAET,2BAAwB;AAE/B,SAASC,UAAU,QAAQ,uBAAoB","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"type":"module"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { createContext, useContext } from 'react';
|
|
4
|
+
import { VideoManager } from "../core/VideoManager.js";
|
|
5
|
+
export const VideoContext = /*#__PURE__*/createContext(null);
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Returns the app-wide VideoManager. Falls back to the shared singleton so
|
|
9
|
+
* the API also works outside the provider (e.g. headless/background code).
|
|
10
|
+
*/
|
|
11
|
+
export function useVideoManager() {
|
|
12
|
+
return useContext(VideoContext) ?? VideoManager.shared;
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=VideoContext.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["createContext","useContext","VideoManager","VideoContext","useVideoManager","shared"],"sourceRoot":"../../../src","sources":["provider/VideoContext.ts"],"mappings":";;AAAA,SAASA,aAAa,EAAEC,UAAU,QAAQ,OAAO;AACjD,SAASC,YAAY,QAAQ,yBAAsB;AAEnD,OAAO,MAAMC,YAAY,gBAAGH,aAAa,CAAsB,IAAI,CAAC;;AAEpE;AACA;AACA;AACA;AACA,OAAO,SAASI,eAAeA,CAAA,EAAiB;EAC9C,OAAOH,UAAU,CAACE,YAAY,CAAC,IAAID,YAAY,CAACG,MAAM;AACxD","ignoreList":[]}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { useEffect, useMemo } from 'react';
|
|
4
|
+
import { VideoManager } from "../core/VideoManager.js";
|
|
5
|
+
import { VideoContext } from "./VideoContext.js";
|
|
6
|
+
import { FullscreenPlayer } from "../components/FullscreenPlayer.js";
|
|
7
|
+
import { FloatingPlayer } from "../components/FloatingPlayer.js";
|
|
8
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
9
|
+
/**
|
|
10
|
+
* Wrap the app once. Creates the singleton native player silently and
|
|
11
|
+
* mounts the fullscreen/floating hosts above the app so `enterFullscreen()`
|
|
12
|
+
* and `showFloating()` work from any screen.
|
|
13
|
+
*
|
|
14
|
+
* ```tsx
|
|
15
|
+
* <VideoProvider>
|
|
16
|
+
* <Navigation />
|
|
17
|
+
* </VideoProvider>
|
|
18
|
+
* ```
|
|
19
|
+
*/
|
|
20
|
+
export function VideoProvider({
|
|
21
|
+
children,
|
|
22
|
+
config
|
|
23
|
+
}) {
|
|
24
|
+
const manager = useMemo(() => VideoManager.shared, []);
|
|
25
|
+
useEffect(() => {
|
|
26
|
+
manager.init(config);
|
|
27
|
+
// Intentionally no destroy on unmount: the engine outlives React trees
|
|
28
|
+
// (and survives Fast Refresh). Call manager.destroy() explicitly to tear down.
|
|
29
|
+
}, [manager, config]);
|
|
30
|
+
const cfg = manager.providerConfig;
|
|
31
|
+
return /*#__PURE__*/_jsxs(VideoContext.Provider, {
|
|
32
|
+
value: manager,
|
|
33
|
+
children: [children, cfg.floatingHost !== false ? /*#__PURE__*/_jsx(FloatingPlayer, {}) : null, cfg.fullscreenHost !== false ? /*#__PURE__*/_jsx(FullscreenPlayer, {}) : null]
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=VideoProvider.js.map
|