react-native-theoplayer 7.5.1 → 7.7.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.
Files changed (45) hide show
  1. package/CHANGELOG.md +24 -0
  2. package/android/src/main/java/com/theoplayer/cache/CacheModule.kt +27 -25
  3. package/android/src/main/java/com/theoplayer/player/PlayerModule.kt +11 -0
  4. package/ios/THEOplayerRCTBridge.m +3 -1
  5. package/ios/THEOplayerRCTMainEventHandler.swift +2 -2
  6. package/ios/THEOplayerRCTMediaTrackEventHandler.swift +129 -2
  7. package/ios/THEOplayerRCTSourceDescriptionAggregator.swift +15 -2
  8. package/ios/THEOplayerRCTSourceDescriptionBuilder.swift +12 -0
  9. package/ios/THEOplayerRCTTrackEventTypes.swift +4 -0
  10. package/ios/ads/THEOplayerRCTAdAdapter.swift +19 -15
  11. package/ios/ads/THEOplayerRCTAdsNative.swift +25 -8
  12. package/ios/cache/THEOplayerRCTCacheAPI.swift +7 -3
  13. package/ios/cache/THEOplayerRCTCacheAggregator.swift +1 -1
  14. package/lib/commonjs/api/player/THEOplayer.js +16 -2
  15. package/lib/commonjs/api/player/THEOplayer.js.map +1 -1
  16. package/lib/commonjs/internal/adapter/DefaultNativePlayerState.js +1 -0
  17. package/lib/commonjs/internal/adapter/DefaultNativePlayerState.js.map +1 -1
  18. package/lib/commonjs/internal/adapter/THEOplayerAdapter.js +10 -1
  19. package/lib/commonjs/internal/adapter/THEOplayerAdapter.js.map +1 -1
  20. package/lib/commonjs/internal/adapter/web/WebPresentationModeManager.js +6 -4
  21. package/lib/commonjs/internal/adapter/web/WebPresentationModeManager.js.map +1 -1
  22. package/lib/module/api/player/THEOplayer.js +16 -1
  23. package/lib/module/api/player/THEOplayer.js.map +1 -1
  24. package/lib/module/internal/adapter/DefaultNativePlayerState.js +2 -1
  25. package/lib/module/internal/adapter/DefaultNativePlayerState.js.map +1 -1
  26. package/lib/module/internal/adapter/THEOplayerAdapter.js +10 -1
  27. package/lib/module/internal/adapter/THEOplayerAdapter.js.map +1 -1
  28. package/lib/module/internal/adapter/web/WebPresentationModeManager.js +6 -4
  29. package/lib/module/internal/adapter/web/WebPresentationModeManager.js.map +1 -1
  30. package/lib/typescript/api/player/THEOplayer.d.ts +22 -1
  31. package/lib/typescript/api/player/THEOplayer.d.ts.map +1 -1
  32. package/lib/typescript/internal/adapter/DefaultNativePlayerState.d.ts +2 -1
  33. package/lib/typescript/internal/adapter/DefaultNativePlayerState.d.ts.map +1 -1
  34. package/lib/typescript/internal/adapter/NativePlayerState.d.ts +2 -1
  35. package/lib/typescript/internal/adapter/NativePlayerState.d.ts.map +1 -1
  36. package/lib/typescript/internal/adapter/THEOplayerAdapter.d.ts +3 -1
  37. package/lib/typescript/internal/adapter/THEOplayerAdapter.d.ts.map +1 -1
  38. package/lib/typescript/internal/adapter/web/WebPresentationModeManager.d.ts.map +1 -1
  39. package/package.json +3 -3
  40. package/react-native-theoplayer.podspec +5 -5
  41. package/src/api/player/THEOplayer.ts +24 -1
  42. package/src/internal/adapter/DefaultNativePlayerState.ts +4 -1
  43. package/src/internal/adapter/NativePlayerState.ts +2 -1
  44. package/src/internal/adapter/THEOplayerAdapter.ts +14 -2
  45. package/src/internal/adapter/web/WebPresentationModeManager.ts +6 -4
@@ -32,23 +32,23 @@ Pod::Spec.new do |s|
32
32
  s.dependency "React-Core"
33
33
 
34
34
  # THEOplayer core Dependency
35
- s.dependency "THEOplayerSDK-core", "~> 7.4"
35
+ s.dependency "THEOplayerSDK-core", "~> 7.8"
36
36
 
37
37
  if theofeatures.include?("GOOGLE_IMA")
38
38
  puts "Adding THEOplayer-Integration-GoogleIMA"
39
- s.dependency "THEOplayer-Integration-GoogleIMA/Base", "~> 7.4"
40
- s.dependency "THEOplayer-Integration-GoogleIMA/Dependencies", "~> 7.4"
39
+ s.dependency "THEOplayer-Integration-GoogleIMA/Base", "~> 7.8"
40
+ s.dependency "THEOplayer-Integration-GoogleIMA/Dependencies", "~> 7.8"
41
41
  end
42
42
 
43
43
  if theofeatures.include?("CHROMECAST")
44
44
  puts "Adding THEOplayer-Integration-GoogleCast"
45
- s.ios.dependency "THEOplayer-Integration-GoogleCast/Base", "~> 7.4"
45
+ s.ios.dependency "THEOplayer-Integration-GoogleCast/Base", "~> 7.8"
46
46
  s.ios.dependency "google-cast-sdk-dynamic-xcframework", "~> 4.8"
47
47
  end
48
48
 
49
49
  if theofeatures.include?("SIDELOADED_TEXTTRACKS")
50
50
  puts "Adding THEOplayer-Connector-SideloadedSubtitle"
51
- s.dependency "THEOplayer-Connector-SideloadedSubtitle", "~> 7.4"
51
+ s.dependency "THEOplayer-Connector-SideloadedSubtitle", "~> 7.8"
52
52
  end
53
53
 
54
54
  end
@@ -19,7 +19,7 @@ export type PreloadType = 'none' | 'metadata' | 'auto' | '';
19
19
  /**
20
20
  * Specifies an aspect ratio for the player.
21
21
  *
22
- * <br/> - `FIT` (default): Scales the player so that all content fits inside its bounding box, keeping the original aspect ratio of the content..
22
+ * <br/> - `FIT` (default): Scales the player so that all content fits inside its bounding box, keeping the original aspect ratio of the content.
23
23
  * <br/> - `FILL`: Scales the player so that all content fits inside the bounding box, which will be stretched to fill it entirely.
24
24
  * <br/> - `ASPECT_FILL`: Scales the player so that the content fills up the entire bounding box, keeping the original aspect ratio of the content.
25
25
  *
@@ -32,6 +32,20 @@ export enum AspectRatio {
32
32
  ASPECT_FILL = 'aspectFill',
33
33
  }
34
34
 
35
+ /**
36
+ * Specifies the rendering target for the player.
37
+ *
38
+ * <br/> - `SURFACE_VIEW` (default): Render video to a {@link https://developer.android.com/reference/android/view/SurfaceView | SurfaceView}.
39
+ * <br/> - `TEXTURE_VIEW`: Render video to a {@link https://developer.android.com/reference/android/view/TextureView | TextureView}.
40
+ *
41
+ * @public
42
+ * @defaultValue `'SURFACE_VIEW'`
43
+ */
44
+ export enum RenderingTarget {
45
+ SURFACE_VIEW = 'surfaceView',
46
+ TEXTURE_VIEW = 'textureView',
47
+ }
48
+
35
49
  export type NativeHandleType = unknown;
36
50
 
37
51
  /**
@@ -176,6 +190,15 @@ export interface THEOplayer extends EventDispatcher<PlayerEventMap> {
176
190
  */
177
191
  aspectRatio: AspectRatio;
178
192
 
193
+ /**
194
+ * Specifies where the player is displaying the video.
195
+ *
196
+ * @defaultValue `SURFACE_VIEW`
197
+ * @remarks
198
+ * Only available for Android.
199
+ */
200
+ renderingTarget?: RenderingTarget;
201
+
179
202
  /**
180
203
  * Toggle the wake-lock on the player view. The screen will time out if disabled.
181
204
  *
@@ -7,7 +7,9 @@ import {
7
7
  PiPConfiguration,
8
8
  PreloadType,
9
9
  PresentationMode,
10
- SourceDescription, TimeRange,
10
+ RenderingTarget,
11
+ SourceDescription,
12
+ TimeRange,
11
13
  } from 'react-native-theoplayer';
12
14
 
13
15
  export class DefaultNativePlayerState extends DefaultTextTrackState implements NativePlayerState {
@@ -27,6 +29,7 @@ export class DefaultNativePlayerState extends DefaultTextTrackState implements N
27
29
  playbackRate = 1;
28
30
  preload: PreloadType = 'none';
29
31
  aspectRatio: AspectRatio = AspectRatio.FIT;
32
+ renderingTarget: RenderingTarget = RenderingTarget.SURFACE_VIEW;
30
33
  keepScreenOn = true;
31
34
  audioTracks: MediaTrack[] = [];
32
35
  videoTracks: MediaTrack[] = [];
@@ -1,4 +1,4 @@
1
- import { MediaTrack, PreloadType, PresentationMode, SourceDescription, TextTrack, TimeRange } from 'react-native-theoplayer';
1
+ import { MediaTrack, PreloadType, PresentationMode, RenderingTarget, SourceDescription, TextTrack, TimeRange } from 'react-native-theoplayer';
2
2
  import type { PiPConfiguration, AspectRatio, BackgroundAudioConfiguration } from 'react-native-theoplayer';
3
3
 
4
4
  export interface PlayerConfigState {
@@ -24,6 +24,7 @@ export interface PlaybackState {
24
24
  buffered: TimeRange[];
25
25
  presentationMode: PresentationMode;
26
26
  aspectRatio: AspectRatio;
27
+ renderingTarget: RenderingTarget;
27
28
  }
28
29
 
29
30
  export interface MediaTrackState {
@@ -1,5 +1,5 @@
1
1
  import { DefaultEventDispatcher } from './event/DefaultEventDispatcher';
2
- import type {
2
+ import {
3
3
  ABRConfiguration,
4
4
  AdsAPI,
5
5
  CastAPI,
@@ -15,6 +15,7 @@ import type {
15
15
  PresentationModeChangeEvent,
16
16
  ProgressEvent,
17
17
  RateChangeEvent,
18
+ RenderingTarget,
18
19
  ResizeEvent,
19
20
  SourceDescription,
20
21
  TextTrack,
@@ -446,13 +447,24 @@ export class THEOplayerAdapter extends DefaultEventDispatcher<PlayerEventMap> im
446
447
  NativePlayerModule.setAspectRatio(this._view.nativeHandle, ratio);
447
448
  }
448
449
 
450
+ get renderingTarget(): RenderingTarget {
451
+ return this._state.renderingTarget;
452
+ }
453
+
454
+ set renderingTarget(target: RenderingTarget) {
455
+ if (Platform.OS === 'android') {
456
+ this._state.renderingTarget = target;
457
+ NativePlayerModule.setRenderingTarget(this._view.nativeHandle, target);
458
+ }
459
+ }
460
+
449
461
  get keepScreenOn(): boolean {
450
462
  return this._state.keepScreenOn;
451
463
  }
452
464
 
453
465
  set keepScreenOn(value: boolean) {
454
- this._state.keepScreenOn = value;
455
466
  if (Platform.OS === 'android') {
467
+ this._state.keepScreenOn = value;
456
468
  NativePlayerModule.setKeepScreenOn(this._view.nativeHandle, value);
457
469
  }
458
470
  }
@@ -31,10 +31,12 @@ export class WebPresentationModeManager {
31
31
  if (fullscreenAPI !== undefined) {
32
32
  // All other browsers
33
33
  if (presentationMode === PresentationMode.fullscreen) {
34
- const appElement = document.getElementById('app')!;
35
- const promise = appElement[fullscreenAPI.requestFullscreen_]();
36
- if (promise && promise.then) {
37
- promise.then(noOp, noOp);
34
+ const appElement = document.getElementById('app') ?? document.getElementById('root');
35
+ if (appElement !== null) {
36
+ const promise = appElement[fullscreenAPI.requestFullscreen_]();
37
+ if (promise && promise.then) {
38
+ promise.then(noOp, noOp);
39
+ }
38
40
  }
39
41
  } else if (presentationMode === PresentationMode.pip) {
40
42
  void this._element?.requestPictureInPicture?.();