react-native-video-provider 0.2.0 → 0.2.2

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.
Files changed (48) hide show
  1. package/README.md +18 -7
  2. package/android/src/main/java/com/auvideo/AuVideoModule.kt +15 -10
  3. package/ios/AuVideo.mm +4 -4
  4. package/ios/AuVideoOrientation.swift +31 -14
  5. package/lib/module/NativeAuVideo.js.map +1 -1
  6. package/lib/module/components/FloatingPlayer.js +8 -11
  7. package/lib/module/components/FloatingPlayer.js.map +1 -1
  8. package/lib/module/components/MiniPlayer.js +10 -10
  9. package/lib/module/components/MiniPlayer.js.map +1 -1
  10. package/lib/module/components/SvgIcons.js +163 -0
  11. package/lib/module/components/SvgIcons.js.map +1 -0
  12. package/lib/module/components/VideoControls.js +36 -15
  13. package/lib/module/components/VideoControls.js.map +1 -1
  14. package/lib/module/components/VideoPlayer.js +8 -0
  15. package/lib/module/components/VideoPlayer.js.map +1 -1
  16. package/lib/module/components/icons.js +164 -0
  17. package/lib/module/components/icons.js.map +1 -0
  18. package/lib/module/core/VideoManager.js +40 -18
  19. package/lib/module/core/VideoManager.js.map +1 -1
  20. package/lib/module/hooks/useFullscreen.js +2 -2
  21. package/lib/module/hooks/useFullscreen.js.map +1 -1
  22. package/lib/typescript/src/NativeAuVideo.d.ts +8 -4
  23. package/lib/typescript/src/NativeAuVideo.d.ts.map +1 -1
  24. package/lib/typescript/src/components/MiniPlayer.d.ts.map +1 -1
  25. package/lib/typescript/src/components/SvgIcons.d.ts +8 -0
  26. package/lib/typescript/src/components/SvgIcons.d.ts.map +1 -0
  27. package/lib/typescript/src/components/VideoControls.d.ts.map +1 -1
  28. package/lib/typescript/src/components/VideoPlayer.d.ts +8 -1
  29. package/lib/typescript/src/components/VideoPlayer.d.ts.map +1 -1
  30. package/lib/typescript/src/components/icons.d.ts +13 -0
  31. package/lib/typescript/src/components/icons.d.ts.map +1 -0
  32. package/lib/typescript/src/core/VideoManager.d.ts +20 -5
  33. package/lib/typescript/src/core/VideoManager.d.ts.map +1 -1
  34. package/lib/typescript/src/hooks/useFullscreen.d.ts +2 -2
  35. package/lib/typescript/src/hooks/useFullscreen.d.ts.map +1 -1
  36. package/lib/typescript/src/types/video.d.ts +0 -6
  37. package/lib/typescript/src/types/video.d.ts.map +1 -1
  38. package/package.json +4 -2
  39. package/src/NativeAuVideo.ts +8 -4
  40. package/src/components/FloatingPlayer.tsx +3 -7
  41. package/src/components/MiniPlayer.tsx +7 -6
  42. package/src/components/SvgIcons.tsx +169 -0
  43. package/src/components/VideoControls.tsx +30 -10
  44. package/src/components/VideoPlayer.tsx +16 -0
  45. package/src/components/icons.tsx +117 -0
  46. package/src/core/VideoManager.ts +51 -17
  47. package/src/hooks/useFullscreen.ts +8 -2
  48. package/src/types/video.ts +0 -6
@@ -25,6 +25,14 @@ export const FLOATING_SURFACE_ID = '__au_floating__';
25
25
 
26
26
  const RESERVED_SURFACES = new Set([FULLSCREEN_SURFACE_ID, FLOATING_SURFACE_ID]);
27
27
 
28
+ const ORIENTATION_LOCKS: readonly OrientationLock[] = [
29
+ 'auto',
30
+ 'portrait',
31
+ 'inverted-portrait',
32
+ 'landscape',
33
+ 'inverted-landscape',
34
+ ];
35
+
28
36
  function toNativeSource(source: VideoSource): NativeVideoSource {
29
37
  return {
30
38
  id: source.id,
@@ -63,11 +71,13 @@ export class VideoManager {
63
71
  fullscreenHost: true,
64
72
  floatingHost: true,
65
73
  pauseOnDetach: false,
66
- fullscreenOrientation: 'auto',
67
74
  };
68
75
  /** Last non-reserved surface, restored after fullscreen/floating exits. */
69
76
  private lastInlineSurfaceId: string | null = null;
70
77
 
78
+ /** Per-player default for `enterFullscreen()` (VideoPlayer's prop). */
79
+ private fullscreenOrientationDefault: OrientationLock | null = null;
80
+
71
81
  private constructor() {}
72
82
 
73
83
  get providerConfig(): Required<VideoProviderConfig> {
@@ -306,6 +316,17 @@ export class VideoManager {
306
316
  NativeAuVideo.setOrientation(lock);
307
317
  }
308
318
 
319
+ /**
320
+ * Register the orientation `enterFullscreen()` uses when called without an
321
+ * argument (the built-in controls call it that way). Scoped: applied when
322
+ * fullscreen opens, restored when it closes — the rest of the app is
323
+ * unaffected. Pass null to unregister. Set by VideoPlayer's
324
+ * `fullscreenOrientation` prop.
325
+ */
326
+ setFullscreenOrientation(lock: OrientationLock | null): void {
327
+ this.fullscreenOrientationDefault = lock;
328
+ }
329
+
309
330
  async getPosition(): Promise<number> {
310
331
  return NativeAuVideo.getPosition();
311
332
  }
@@ -350,43 +371,55 @@ export class VideoManager {
350
371
  // ------------------------------------------------------------ modes
351
372
 
352
373
  /**
353
- * Show the built-in fullscreen host and unlock device rotation.
354
- * The host mounts a surface and attaches automatically.
374
+ * Show the built-in fullscreen host. Rotation unlocks by default; pass an
375
+ * orientation (or set VideoPlayer's `fullscreenOrientation` prop) to force
376
+ * one for the fullscreen session only. That scoped orientation is the
377
+ * highest priority — it's applied in the SAME native call as entering
378
+ * fullscreen (never as a separate follow-up call), so there is no
379
+ * unlocked frame where the sensor could win before the lock takes effect.
380
+ * Restored on exit; the rest of the app never sees the lock.
355
381
  */
356
- enterFullscreen(): void {
382
+ enterFullscreen(orientation?: OrientationLock): void {
357
383
  if (this.store.getState().fullscreen) {
358
384
  return;
359
385
  }
360
386
  this.set({ fullscreen: true, floating: false });
361
387
  this.setMode('fullscreen');
362
- NativeAuVideo.enterFullscreen();
363
- const forced = this.config.fullscreenOrientation;
364
- if (forced !== 'auto') {
365
- NativeAuVideo.setOrientation(forced);
366
- }
388
+ // `enter` is often passed straight to onPress, so the argument may be a
389
+ // press event — only honor real orientation values.
390
+ const requested = ORIENTATION_LOCKS.includes(orientation as OrientationLock)
391
+ ? (orientation as OrientationLock)
392
+ : this.fullscreenOrientationDefault;
393
+ // A scoped override wins outright; otherwise carry any standing
394
+ // setOrientation() lock through fullscreen unchanged (still higher
395
+ // priority than the sensor unlock — 'auto' just means neither applies).
396
+ const lock =
397
+ requested && requested !== 'auto'
398
+ ? requested
399
+ : this.store.getState().orientationLock;
400
+ NativeAuVideo.enterFullscreen(lock);
367
401
  this.events.emit('onEnterFullscreen', undefined);
368
402
  }
369
403
 
370
- /** Restore the previous orientation lock and re-attach the previous surface. */
404
+ /** Restore the standing orientation lock (if any) and re-attach the previous surface. */
371
405
  exitFullscreen(): void {
372
406
  if (!this.store.getState().fullscreen) {
373
407
  return;
374
408
  }
375
- if (this.config.fullscreenOrientation !== 'auto') {
376
- // Drop the fullscreen-only lock, restoring any explicit setOrientation.
377
- NativeAuVideo.setOrientation(this.store.getState().orientationLock);
378
- }
379
- NativeAuVideo.exitFullscreen();
409
+ // Always restore the standing lock (or 'auto' if none) — a
410
+ // fullscreen-scoped override was never written to state, so this
411
+ // naturally drops it without needing to track whether one was applied.
412
+ NativeAuVideo.exitFullscreen(this.store.getState().orientationLock);
380
413
  this.set({ fullscreen: false });
381
414
  this.events.emit('onExitFullscreen', undefined);
382
415
  this.restoreInlineSurface();
383
416
  }
384
417
 
385
- toggleFullscreen(): void {
418
+ toggleFullscreen(orientation?: OrientationLock): void {
386
419
  if (this.store.getState().fullscreen) {
387
420
  this.exitFullscreen();
388
421
  } else {
389
- this.enterFullscreen();
422
+ this.enterFullscreen(orientation);
390
423
  }
391
424
  }
392
425
 
@@ -450,6 +483,7 @@ export class VideoManager {
450
483
  this.events.removeAll();
451
484
  this.initialized = false;
452
485
  this.lastInlineSurfaceId = null;
486
+ this.fullscreenOrientationDefault = null;
453
487
  NativeAuVideo.setOrientation('auto');
454
488
  NativeAuVideo.releasePlayer();
455
489
  this.store.setState({ ...initialVideoState }, true);
@@ -8,9 +8,15 @@ export function useFullscreen() {
8
8
  const isFullscreen = usePlayback((s) => s.fullscreen);
9
9
  const orientationLock = usePlayback((s) => s.orientationLock);
10
10
 
11
- const enter = useCallback(() => manager.enterFullscreen(), [manager]);
11
+ const enter = useCallback(
12
+ (orientation?: OrientationLock) => manager.enterFullscreen(orientation),
13
+ [manager]
14
+ );
12
15
  const exit = useCallback(() => manager.exitFullscreen(), [manager]);
13
- const toggle = useCallback(() => manager.toggleFullscreen(), [manager]);
16
+ const toggle = useCallback(
17
+ (orientation?: OrientationLock) => manager.toggleFullscreen(orientation),
18
+ [manager]
19
+ );
14
20
  const setOrientation = useCallback(
15
21
  (lock: OrientationLock) => manager.setOrientation(lock),
16
22
  [manager]
@@ -100,10 +100,4 @@ export interface VideoProviderConfig {
100
100
  floatingHost?: boolean;
101
101
  /** Pause playback when the active surface unmounts. Default false. */
102
102
  pauseOnDetach?: boolean;
103
- /**
104
- * Orientation to force while fullscreen is active, e.g. `'landscape'`.
105
- * Restored to the previous lock (or `'auto'`) on exit.
106
- * Default `'auto'` — fullscreen just unlocks the sensor.
107
- */
108
- fullscreenOrientation?: OrientationLock;
109
103
  }