react-native-theoplayer 3.7.0 → 3.8.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 (82) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/android/build.gradle +1 -1
  3. package/android/local/com/theoplayer/theoplayer-sdk-android/ads-wrapper/6.10.0/ads-wrapper-6.10.0.aar +0 -0
  4. package/android/local/com/theoplayer/theoplayer-sdk-android/ads-wrapper/{4.8.0/ads-wrapper-4.8.0.pom → 6.10.0/ads-wrapper-6.10.0.pom} +1 -1
  5. package/android/local/com/theoplayer/theoplayer-sdk-android/ads-wrapper/maven-metadata-local.xml +4 -4
  6. package/android/src/main/java/com/theoplayer/PlayerConfigAdapter.kt +4 -0
  7. package/android/src/main/java/com/theoplayer/ads/AdEventAdapter.kt +9 -4
  8. package/android/src/main/java/com/theoplayer/ads/AdsModule.kt +1 -1
  9. package/android/src/main/java/com/theoplayer/broadcast/EventBroadcastModule.kt +1 -1
  10. package/android/src/main/java/com/theoplayer/cache/CacheModule.kt +1 -1
  11. package/android/src/main/java/com/theoplayer/cast/CastModule.kt +1 -1
  12. package/android/src/main/java/com/theoplayer/drm/ContentProtectionModule.kt +1 -1
  13. package/android/src/main/java/com/theoplayer/player/PlayerModule.kt +1 -1
  14. package/ios/THEOplayerRCTBridge.m +6 -6
  15. package/ios/THEOplayerRCTPlayerAPI.swift +25 -25
  16. package/ios/ads/THEOplayerRCTAdsAPI.swift +17 -17
  17. package/ios/cache/THEOplayerRCTCacheAPI.swift +29 -29
  18. package/ios/casting/THEOplayerRCTCastAPI.swift +9 -9
  19. package/ios/contentprotection/THEOplayerRCTContentProtectionAPI.swift +22 -22
  20. package/ios/eventBroadcasting/THEOplayerRCTEventBroadcastAPI.swift +5 -5
  21. package/lib/commonjs/api/config/PlayerConfiguration.js.map +1 -1
  22. package/lib/commonjs/internal/adapter/THEOplayerAdapter.js +18 -17
  23. package/lib/commonjs/internal/adapter/THEOplayerAdapter.js.map +1 -1
  24. package/lib/commonjs/internal/adapter/abr/AbrAdapter.js +2 -1
  25. package/lib/commonjs/internal/adapter/abr/AbrAdapter.js.map +1 -1
  26. package/lib/commonjs/internal/adapter/ads/THEOplayerNativeAdsAdapter.js +7 -6
  27. package/lib/commonjs/internal/adapter/ads/THEOplayerNativeAdsAdapter.js.map +1 -1
  28. package/lib/commonjs/internal/adapter/ads/THEOplayerNativeGoogleDAI.js +5 -4
  29. package/lib/commonjs/internal/adapter/ads/THEOplayerNativeGoogleDAI.js.map +1 -1
  30. package/lib/commonjs/internal/adapter/broadcast/EventBroadcastAdapter.js +2 -1
  31. package/lib/commonjs/internal/adapter/broadcast/EventBroadcastAdapter.js.map +1 -1
  32. package/lib/commonjs/internal/adapter/cast/THEOplayerNativeAirplay.js +5 -4
  33. package/lib/commonjs/internal/adapter/cast/THEOplayerNativeAirplay.js.map +1 -1
  34. package/lib/commonjs/internal/adapter/cast/THEOplayerNativeChromecast.js +7 -6
  35. package/lib/commonjs/internal/adapter/cast/THEOplayerNativeChromecast.js.map +1 -1
  36. package/lib/commonjs/internal/adapter/track/TextTrackStyleAdapter.js +11 -10
  37. package/lib/commonjs/internal/adapter/track/TextTrackStyleAdapter.js.map +1 -1
  38. package/lib/commonjs/internal/cache/MediaCache.js +4 -3
  39. package/lib/commonjs/internal/cache/MediaCache.js.map +1 -1
  40. package/lib/commonjs/internal/cache/NativeCachingTaskAdapter.js +5 -4
  41. package/lib/commonjs/internal/cache/NativeCachingTaskAdapter.js.map +1 -1
  42. package/lib/commonjs/internal/drm/ContentProtectionRegistry.js +23 -22
  43. package/lib/commonjs/internal/drm/ContentProtectionRegistry.js.map +1 -1
  44. package/lib/module/api/config/PlayerConfiguration.js.map +1 -1
  45. package/lib/module/internal/adapter/THEOplayerAdapter.js +18 -17
  46. package/lib/module/internal/adapter/THEOplayerAdapter.js.map +1 -1
  47. package/lib/module/internal/adapter/abr/AbrAdapter.js +2 -1
  48. package/lib/module/internal/adapter/abr/AbrAdapter.js.map +1 -1
  49. package/lib/module/internal/adapter/ads/THEOplayerNativeAdsAdapter.js +7 -6
  50. package/lib/module/internal/adapter/ads/THEOplayerNativeAdsAdapter.js.map +1 -1
  51. package/lib/module/internal/adapter/ads/THEOplayerNativeGoogleDAI.js +5 -4
  52. package/lib/module/internal/adapter/ads/THEOplayerNativeGoogleDAI.js.map +1 -1
  53. package/lib/module/internal/adapter/broadcast/EventBroadcastAdapter.js +2 -1
  54. package/lib/module/internal/adapter/broadcast/EventBroadcastAdapter.js.map +1 -1
  55. package/lib/module/internal/adapter/cast/THEOplayerNativeAirplay.js +5 -4
  56. package/lib/module/internal/adapter/cast/THEOplayerNativeAirplay.js.map +1 -1
  57. package/lib/module/internal/adapter/cast/THEOplayerNativeChromecast.js +7 -6
  58. package/lib/module/internal/adapter/cast/THEOplayerNativeChromecast.js.map +1 -1
  59. package/lib/module/internal/adapter/track/TextTrackStyleAdapter.js +11 -10
  60. package/lib/module/internal/adapter/track/TextTrackStyleAdapter.js.map +1 -1
  61. package/lib/module/internal/cache/MediaCache.js +4 -3
  62. package/lib/module/internal/cache/MediaCache.js.map +1 -1
  63. package/lib/module/internal/cache/NativeCachingTaskAdapter.js +5 -4
  64. package/lib/module/internal/cache/NativeCachingTaskAdapter.js.map +1 -1
  65. package/lib/module/internal/drm/ContentProtectionRegistry.js +23 -22
  66. package/lib/module/internal/drm/ContentProtectionRegistry.js.map +1 -1
  67. package/lib/typescript/api/config/PlayerConfiguration.d.ts +10 -0
  68. package/package.json +1 -1
  69. package/react-native-theoplayer.podspec +15 -8
  70. package/src/api/config/PlayerConfiguration.ts +11 -0
  71. package/src/internal/adapter/THEOplayerAdapter.ts +19 -17
  72. package/src/internal/adapter/abr/AbrAdapter.ts +3 -1
  73. package/src/internal/adapter/ads/THEOplayerNativeAdsAdapter.ts +8 -6
  74. package/src/internal/adapter/ads/THEOplayerNativeGoogleDAI.ts +6 -4
  75. package/src/internal/adapter/broadcast/EventBroadcastAdapter.ts +3 -1
  76. package/src/internal/adapter/cast/THEOplayerNativeAirplay.ts +6 -4
  77. package/src/internal/adapter/cast/THEOplayerNativeChromecast.ts +8 -6
  78. package/src/internal/adapter/track/TextTrackStyleAdapter.ts +11 -10
  79. package/src/internal/cache/MediaCache.ts +5 -3
  80. package/src/internal/cache/NativeCachingTaskAdapter.ts +6 -4
  81. package/src/internal/drm/ContentProtectionRegistry.ts +24 -22
  82. package/android/local/com/theoplayer/theoplayer-sdk-android/ads-wrapper/4.8.0/ads-wrapper-4.8.0.aar +0 -0
@@ -51,6 +51,8 @@ import { TextTrackStyleAdapter } from './track/TextTrackStyleAdapter';
51
51
  import type { NativePlayerState } from './NativePlayerState';
52
52
  import { EventBroadcastAdapter } from './broadcast/EventBroadcastAdapter';
53
53
 
54
+ const NativePlayerModule = NativeModules.THEORCTPlayerModule;
55
+
54
56
  const defaultPlayerState: NativePlayerState = {
55
57
  source: undefined,
56
58
  autoplay: false,
@@ -281,7 +283,7 @@ export class THEOplayerAdapter extends DefaultEventDispatcher<PlayerEventMap> im
281
283
 
282
284
  set preload(type: PreloadType) {
283
285
  this._state.preload = type;
284
- NativeModules.PlayerModule.setPreload(this._view.nativeHandle, type);
286
+ NativePlayerModule.setPreload(this._view.nativeHandle, type);
285
287
  }
286
288
 
287
289
  get preload(): PreloadType {
@@ -325,7 +327,7 @@ export class THEOplayerAdapter extends DefaultEventDispatcher<PlayerEventMap> im
325
327
  }
326
328
 
327
329
  this._state.currentTime = seekTime;
328
- NativeModules.PlayerModule.setCurrentTime(this._view.nativeHandle, seekTime);
330
+ NativePlayerModule.setCurrentTime(this._view.nativeHandle, seekTime);
329
331
  }
330
332
 
331
333
  get duration(): number {
@@ -338,7 +340,7 @@ export class THEOplayerAdapter extends DefaultEventDispatcher<PlayerEventMap> im
338
340
 
339
341
  set pipConfiguration(pipConfiguration: PiPConfiguration) {
340
342
  this._state.pipConfig = pipConfiguration;
341
- NativeModules.PlayerModule.setPipConfig(this._view.nativeHandle, pipConfiguration);
343
+ NativePlayerModule.setPipConfig(this._view.nativeHandle, pipConfiguration);
342
344
  }
343
345
 
344
346
  get backgroundAudioConfiguration(): BackgroundAudioConfiguration {
@@ -347,7 +349,7 @@ export class THEOplayerAdapter extends DefaultEventDispatcher<PlayerEventMap> im
347
349
 
348
350
  set backgroundAudioConfiguration(backgroundAudioConfiguration: BackgroundAudioConfiguration) {
349
351
  this._state.backgroundAudioConfig = backgroundAudioConfiguration;
350
- NativeModules.PlayerModule.setBackgroundAudioConfig(this._view.nativeHandle, backgroundAudioConfiguration);
352
+ NativePlayerModule.setBackgroundAudioConfig(this._view.nativeHandle, backgroundAudioConfiguration);
351
353
  }
352
354
 
353
355
  get presentationMode(): PresentationMode {
@@ -356,7 +358,7 @@ export class THEOplayerAdapter extends DefaultEventDispatcher<PlayerEventMap> im
356
358
 
357
359
  set presentationMode(presentationMode: PresentationMode) {
358
360
  this._state.presentationMode = presentationMode;
359
- NativeModules.PlayerModule.setPresentationMode(this._view.nativeHandle, presentationMode);
361
+ NativePlayerModule.setPresentationMode(this._view.nativeHandle, presentationMode);
360
362
  }
361
363
 
362
364
  get muted(): boolean {
@@ -365,7 +367,7 @@ export class THEOplayerAdapter extends DefaultEventDispatcher<PlayerEventMap> im
365
367
 
366
368
  set muted(muted: boolean) {
367
369
  this._state.muted = muted;
368
- NativeModules.PlayerModule.setMuted(this._view.nativeHandle, muted);
370
+ NativePlayerModule.setMuted(this._view.nativeHandle, muted);
369
371
  }
370
372
 
371
373
  get seeking(): boolean {
@@ -382,7 +384,7 @@ export class THEOplayerAdapter extends DefaultEventDispatcher<PlayerEventMap> im
382
384
 
383
385
  set playbackRate(playbackRate: number) {
384
386
  this._state.playbackRate = playbackRate;
385
- NativeModules.PlayerModule.setPlaybackRate(this._view.nativeHandle, playbackRate);
387
+ NativePlayerModule.setPlaybackRate(this._view.nativeHandle, playbackRate);
386
388
  }
387
389
 
388
390
  get audioTracks(): MediaTrack[] {
@@ -398,7 +400,7 @@ export class THEOplayerAdapter extends DefaultEventDispatcher<PlayerEventMap> im
398
400
  return;
399
401
  }
400
402
  this._state.selectedAudioTrack = trackUid;
401
- NativeModules.PlayerModule.setSelectedAudioTrack(this._view.nativeHandle, trackUid !== undefined ? trackUid : -1);
403
+ NativePlayerModule.setSelectedAudioTrack(this._view.nativeHandle, trackUid !== undefined ? trackUid : -1);
402
404
  }
403
405
 
404
406
  get videoTracks(): MediaTrack[] {
@@ -415,7 +417,7 @@ export class THEOplayerAdapter extends DefaultEventDispatcher<PlayerEventMap> im
415
417
  }
416
418
  this._state.selectedVideoTrack = trackUid;
417
419
  this._state.targetVideoQuality = undefined;
418
- NativeModules.PlayerModule.setSelectedVideoTrack(this._view.nativeHandle, trackUid !== undefined ? trackUid : -1);
420
+ NativePlayerModule.setSelectedVideoTrack(this._view.nativeHandle, trackUid !== undefined ? trackUid : -1);
419
421
  }
420
422
 
421
423
  get textTracks(): TextTrack[] {
@@ -438,7 +440,7 @@ export class THEOplayerAdapter extends DefaultEventDispatcher<PlayerEventMap> im
438
440
  track.mode = TextTrackMode.disabled;
439
441
  }
440
442
  });
441
- NativeModules.PlayerModule.setSelectedTextTrack(this._view.nativeHandle, trackUid !== undefined ? trackUid : -1);
443
+ NativePlayerModule.setSelectedTextTrack(this._view.nativeHandle, trackUid !== undefined ? trackUid : -1);
442
444
  }
443
445
 
444
446
  get textTrackStyle(): TextTrackStyle {
@@ -453,7 +455,7 @@ export class THEOplayerAdapter extends DefaultEventDispatcher<PlayerEventMap> im
453
455
  // This is to correctly reset autoplay during a source change.
454
456
  this.pause();
455
457
  this._state.source = source;
456
- NativeModules.PlayerModule.setSource(this._view.nativeHandle, source);
458
+ NativePlayerModule.setSource(this._view.nativeHandle, source);
457
459
  // Reset state for play-out of new source
458
460
  Object.assign(this._state, {
459
461
  playbackRate: 1,
@@ -486,7 +488,7 @@ export class THEOplayerAdapter extends DefaultEventDispatcher<PlayerEventMap> im
486
488
  if (track) {
487
489
  Object.assign(track, { ...track, targetQuality: this._state.targetVideoQuality });
488
490
  }
489
- NativeModules.PlayerModule.setTargetVideoQuality(this._view.nativeHandle, this._state.targetVideoQuality);
491
+ NativePlayerModule.setTargetVideoQuality(this._view.nativeHandle, this._state.targetVideoQuality);
490
492
  }
491
493
 
492
494
  get volume(): number {
@@ -495,7 +497,7 @@ export class THEOplayerAdapter extends DefaultEventDispatcher<PlayerEventMap> im
495
497
 
496
498
  set volume(volume: number) {
497
499
  this._state.volume = volume;
498
- NativeModules.PlayerModule.setVolume(this._view.nativeHandle, volume);
500
+ NativePlayerModule.setVolume(this._view.nativeHandle, volume);
499
501
  }
500
502
 
501
503
  get aspectRatio(): AspectRatio {
@@ -504,7 +506,7 @@ export class THEOplayerAdapter extends DefaultEventDispatcher<PlayerEventMap> im
504
506
 
505
507
  set aspectRatio(ratio: AspectRatio) {
506
508
  this._state.aspectRatio = ratio;
507
- NativeModules.PlayerModule.setAspectRatio(this._view.nativeHandle, ratio);
509
+ NativePlayerModule.setAspectRatio(this._view.nativeHandle, ratio);
508
510
  }
509
511
 
510
512
  get keepScreenOn(): boolean {
@@ -514,21 +516,21 @@ export class THEOplayerAdapter extends DefaultEventDispatcher<PlayerEventMap> im
514
516
  set keepScreenOn(value: boolean) {
515
517
  this._state.keepScreenOn = value;
516
518
  if (Platform.OS === 'android') {
517
- NativeModules.PlayerModule.setKeepScreenOn(this._view.nativeHandle, value);
519
+ NativePlayerModule.setKeepScreenOn(this._view.nativeHandle, value);
518
520
  }
519
521
  }
520
522
 
521
523
  pause(): void {
522
524
  if (this.hasValidSource()) {
523
525
  this._state.paused = true;
524
- NativeModules.PlayerModule.setPaused(this._view.nativeHandle, true);
526
+ NativePlayerModule.setPaused(this._view.nativeHandle, true);
525
527
  }
526
528
  }
527
529
 
528
530
  play(): void {
529
531
  if (this.hasValidSource()) {
530
532
  this._state.paused = false;
531
- NativeModules.PlayerModule.setPaused(this._view.nativeHandle, false);
533
+ NativePlayerModule.setPaused(this._view.nativeHandle, false);
532
534
  }
533
535
  }
534
536
 
@@ -1,6 +1,8 @@
1
1
  import type { ABRConfiguration, ABRStrategy, THEOplayerView } from 'react-native-theoplayer';
2
2
  import { NativeModules } from 'react-native';
3
3
 
4
+ const NativePlayerModule = NativeModules.THEORCTPlayerModule;
5
+
4
6
  export class AbrAdapter implements ABRConfiguration {
5
7
  private readonly _view: THEOplayerView;
6
8
  private _strategy: ABRStrategy | undefined;
@@ -29,7 +31,7 @@ export class AbrAdapter implements ABRConfiguration {
29
31
  }
30
32
 
31
33
  private updateConfig() {
32
- NativeModules.PlayerModule.setABRConfig(this._view.nativeHandle, {
34
+ NativePlayerModule.setABRConfig(this._view.nativeHandle, {
33
35
  targetBuffer: this._targetBuffer,
34
36
  strategy: this._strategy,
35
37
  });
@@ -2,6 +2,8 @@ import type { Ad, AdBreak, AdDescription, AdsAPI, GoogleDAI, THEOplayerView } fr
2
2
  import { NativeModules } from 'react-native';
3
3
  import { THEOplayerNativeGoogleDAI } from './THEOplayerNativeGoogleDAI';
4
4
 
5
+ const NativeAdsModule = NativeModules.THEORCTAdsModule;
6
+
5
7
  export class THEOplayerNativeAdsAdapter implements AdsAPI {
6
8
  private readonly _dai: GoogleDAI;
7
9
 
@@ -10,27 +12,27 @@ export class THEOplayerNativeAdsAdapter implements AdsAPI {
10
12
  }
11
13
 
12
14
  playing(): Promise<boolean> {
13
- return NativeModules.AdsModule.playing(this._player.nativeHandle);
15
+ return NativeAdsModule.playing(this._player.nativeHandle);
14
16
  }
15
17
 
16
18
  skip(): void {
17
- NativeModules.AdsModule.skip(this._player.nativeHandle);
19
+ NativeAdsModule.skip(this._player.nativeHandle);
18
20
  }
19
21
 
20
22
  currentAdBreak(): Promise<AdBreak> {
21
- return NativeModules.AdsModule.currentAdBreak(this._player.nativeHandle);
23
+ return NativeAdsModule.currentAdBreak(this._player.nativeHandle);
22
24
  }
23
25
 
24
26
  currentAds(): Promise<Ad[]> {
25
- return NativeModules.AdsModule.currentAds(this._player.nativeHandle);
27
+ return NativeAdsModule.currentAds(this._player.nativeHandle);
26
28
  }
27
29
 
28
30
  scheduledAdBreaks(): Promise<AdBreak[]> {
29
- return NativeModules.AdsModule.scheduledAdBreaks(this._player.nativeHandle);
31
+ return NativeAdsModule.scheduledAdBreaks(this._player.nativeHandle);
30
32
  }
31
33
 
32
34
  schedule(ad: AdDescription): void {
33
- NativeModules.AdsModule.schedule(this._player.nativeHandle, ad);
35
+ NativeAdsModule.schedule(this._player.nativeHandle, ad);
34
36
  }
35
37
 
36
38
  get dai(): GoogleDAI | undefined {
@@ -1,22 +1,24 @@
1
1
  import type { GoogleDAI, THEOplayerView } from 'react-native-theoplayer';
2
2
  import { NativeModules } from 'react-native';
3
3
 
4
+ const NativeAdsModule = NativeModules.THEORCTAdsModule;
5
+
4
6
  export class THEOplayerNativeGoogleDAI implements GoogleDAI {
5
7
  public constructor(private readonly _player: THEOplayerView) {}
6
8
 
7
9
  get snapback(): Promise<boolean> {
8
- return NativeModules.AdsModule.daiSnapback(this._player.nativeHandle);
10
+ return NativeAdsModule.daiSnapback(this._player.nativeHandle);
9
11
  }
10
12
 
11
13
  setSnapback(enabled: boolean): void {
12
- NativeModules.AdsModule.daiSetSnapback(this._player.nativeHandle, enabled);
14
+ NativeAdsModule.daiSetSnapback(this._player.nativeHandle, enabled);
13
15
  }
14
16
 
15
17
  contentTimeForStreamTime(time: number): Promise<number> {
16
- return NativeModules.AdsModule.daiContentTimeForStreamTime(this._player.nativeHandle, time);
18
+ return NativeAdsModule.daiContentTimeForStreamTime(this._player.nativeHandle, time);
17
19
  }
18
20
 
19
21
  streamTimeForContentTime(time: number): Promise<number> {
20
- return NativeModules.AdsModule.daiStreamTimeForContentTime(this._player.nativeHandle, time);
22
+ return NativeAdsModule.daiStreamTimeForContentTime(this._player.nativeHandle, time);
21
23
  }
22
24
  }
@@ -3,6 +3,8 @@ import { NativeModules } from 'react-native';
3
3
  import type { THEOplayerAdapter } from '../THEOplayerAdapter';
4
4
  import type { StringKeyOf } from '../../../api/event/EventDispatcher';
5
5
 
6
+ const NativeEventBroadcastModule = NativeModules.THEORCTEventBroadcastModule;
7
+
6
8
  export class EventBroadcastAdapter implements EventBroadcastAPI {
7
9
  constructor(private _player: THEOplayer) {}
8
10
 
@@ -12,7 +14,7 @@ export class EventBroadcastAdapter implements EventBroadcastAPI {
12
14
 
13
15
  try {
14
16
  // Broadcast native event.
15
- NativeModules.EventBroadcastModule.broadcastEvent(this._player.nativeHandle, Object.freeze(event));
17
+ NativeEventBroadcastModule.broadcastEvent(this._player.nativeHandle, Object.freeze(event));
16
18
  } catch (e) {
17
19
  console.warn(`EventBroadcastModule not available: ${e}`);
18
20
  }
@@ -2,6 +2,8 @@ import type { Airplay } from 'react-native-theoplayer';
2
2
  import { CastEvent, CastEventType, CastState, PlayerEventType, THEOplayer } from 'react-native-theoplayer';
3
3
  import { NativeModules } from 'react-native';
4
4
 
5
+ const NativeCastModule = NativeModules.THEORCTCastModule;
6
+
5
7
  export class THEOplayerNativeAirplay implements Airplay {
6
8
  private readonly _player: THEOplayer;
7
9
 
@@ -14,8 +16,8 @@ export class THEOplayerNativeAirplay implements Airplay {
14
16
  }
15
17
 
16
18
  async init_(): Promise<void> {
17
- this._casting = await NativeModules.CastModule.airplayCasting(this._player.nativeHandle);
18
- this._state = await NativeModules.CastModule.airplayState(this._player.nativeHandle);
19
+ this._casting = await NativeCastModule.airplayCasting(this._player.nativeHandle);
20
+ this._state = await NativeCastModule.airplayState(this._player.nativeHandle);
19
21
  }
20
22
 
21
23
  private readonly _onCastStateChange = (event: CastEvent) => {
@@ -34,11 +36,11 @@ export class THEOplayerNativeAirplay implements Airplay {
34
36
  }
35
37
 
36
38
  start(): void {
37
- NativeModules.CastModule.airplayStart(this._player.nativeHandle);
39
+ NativeCastModule.airplayStart(this._player.nativeHandle);
38
40
  }
39
41
 
40
42
  stop(): void {
41
- NativeModules.CastModule.airplayStop(this._player.nativeHandle);
43
+ NativeCastModule.airplayStop(this._player.nativeHandle);
42
44
  }
43
45
 
44
46
  unload_(): void {
@@ -2,6 +2,8 @@ import type { CastEvent, Chromecast, THEOplayerView } from 'react-native-theopla
2
2
  import { CastEventType, CastState, PlayerEventType, THEOplayer } from 'react-native-theoplayer';
3
3
  import { NativeModules } from 'react-native';
4
4
 
5
+ const NativeCastModule = NativeModules.THEORCTCastModule;
6
+
5
7
  export class THEOplayerNativeChromecast implements Chromecast {
6
8
  private readonly _player: THEOplayer;
7
9
  private readonly _view: THEOplayerView;
@@ -16,8 +18,8 @@ export class THEOplayerNativeChromecast implements Chromecast {
16
18
  }
17
19
 
18
20
  async init_(): Promise<void> {
19
- this._casting = await NativeModules.CastModule.chromecastCasting(this._view.nativeHandle);
20
- this._state = await NativeModules.CastModule.chromecastState(this._view.nativeHandle);
21
+ this._casting = await NativeCastModule.chromecastCasting(this._view.nativeHandle);
22
+ this._state = await NativeCastModule.chromecastState(this._view.nativeHandle);
21
23
  }
22
24
 
23
25
  private readonly _onCastStateChange = (event: CastEvent) => {
@@ -36,19 +38,19 @@ export class THEOplayerNativeChromecast implements Chromecast {
36
38
  }
37
39
 
38
40
  start(): void {
39
- NativeModules.CastModule.chromecastStart(this._view.nativeHandle);
41
+ NativeCastModule.chromecastStart(this._view.nativeHandle);
40
42
  }
41
43
 
42
44
  stop(): void {
43
- NativeModules.CastModule.chromecastStop(this._view.nativeHandle);
45
+ NativeCastModule.chromecastStop(this._view.nativeHandle);
44
46
  }
45
47
 
46
48
  join(): void {
47
- NativeModules.CastModule.chromecastJoin(this._view.nativeHandle);
49
+ NativeCastModule.chromecastJoin(this._view.nativeHandle);
48
50
  }
49
51
 
50
52
  leave(): void {
51
- NativeModules.CastModule.chromecastLeave(this._view.nativeHandle);
53
+ NativeCastModule.chromecastLeave(this._view.nativeHandle);
52
54
  }
53
55
 
54
56
  unload_(): void {
@@ -3,6 +3,7 @@ import { NativeModules } from 'react-native';
3
3
  import NamedColors from './NamedColors.json';
4
4
 
5
5
  const namedColorsMap = NamedColors as { [name: string]: string };
6
+ const NativePlayerModule = NativeModules.THEORCTPlayerModule;
6
7
 
7
8
  export class TextTrackStyleAdapter implements TextTrackStyle {
8
9
  private _backgroundColor: string | undefined = undefined;
@@ -24,7 +25,7 @@ export class TextTrackStyleAdapter implements TextTrackStyle {
24
25
 
25
26
  set backgroundColor(color: string | undefined) {
26
27
  this._backgroundColor = color;
27
- NativeModules.PlayerModule.setTextTrackStyle(this._view.nativeHandle, {
28
+ NativePlayerModule.setTextTrackStyle(this._view.nativeHandle, {
28
29
  backgroundColor: convertColorToRGBA(color),
29
30
  });
30
31
  }
@@ -35,7 +36,7 @@ export class TextTrackStyleAdapter implements TextTrackStyle {
35
36
 
36
37
  set edgeStyle(style: EdgeStyle | undefined) {
37
38
  this._edgeStyle = style;
38
- NativeModules.PlayerModule.setTextTrackStyle(this._view.nativeHandle, {
39
+ NativePlayerModule.setTextTrackStyle(this._view.nativeHandle, {
39
40
  edgeStyle: style,
40
41
  });
41
42
  }
@@ -46,7 +47,7 @@ export class TextTrackStyleAdapter implements TextTrackStyle {
46
47
 
47
48
  set fontColor(color: string | undefined) {
48
49
  this._fontColor = color;
49
- NativeModules.PlayerModule.setTextTrackStyle(this._view.nativeHandle, {
50
+ NativePlayerModule.setTextTrackStyle(this._view.nativeHandle, {
50
51
  fontColor: convertColorToRGBA(color),
51
52
  });
52
53
  }
@@ -57,7 +58,7 @@ export class TextTrackStyleAdapter implements TextTrackStyle {
57
58
 
58
59
  set fontFamily(family: string | undefined) {
59
60
  this._fontFamily = family;
60
- NativeModules.PlayerModule.setTextTrackStyle(this._view.nativeHandle, {
61
+ NativePlayerModule.setTextTrackStyle(this._view.nativeHandle, {
61
62
  fontFamily: family,
62
63
  });
63
64
  }
@@ -68,7 +69,7 @@ export class TextTrackStyleAdapter implements TextTrackStyle {
68
69
 
69
70
  set fontSize(size: string | undefined) {
70
71
  this._fontSize = size;
71
- NativeModules.PlayerModule.setTextTrackStyle(this._view.nativeHandle, {
72
+ NativePlayerModule.setTextTrackStyle(this._view.nativeHandle, {
72
73
  fontSize: fromPercentage(size),
73
74
  });
74
75
  }
@@ -79,7 +80,7 @@ export class TextTrackStyleAdapter implements TextTrackStyle {
79
80
 
80
81
  set windowColor(color: string | undefined) {
81
82
  this._windowColor = color;
82
- NativeModules.PlayerModule.setTextTrackStyle(this._view.nativeHandle, {
83
+ NativePlayerModule.setTextTrackStyle(this._view.nativeHandle, {
83
84
  windowColor: convertColorToRGBA(color),
84
85
  });
85
86
  }
@@ -90,7 +91,7 @@ export class TextTrackStyleAdapter implements TextTrackStyle {
90
91
 
91
92
  set marginBottom(margin: number | undefined) {
92
93
  this._marginBottom = margin;
93
- NativeModules.PlayerModule.setTextTrackStyle(this._view.nativeHandle, {
94
+ NativePlayerModule.setTextTrackStyle(this._view.nativeHandle, {
94
95
  marginBottom: margin,
95
96
  });
96
97
  }
@@ -101,7 +102,7 @@ export class TextTrackStyleAdapter implements TextTrackStyle {
101
102
 
102
103
  set marginLeft(margin: number | undefined) {
103
104
  this._marginLeft = margin;
104
- NativeModules.PlayerModule.setTextTrackStyle(this._view.nativeHandle, {
105
+ NativePlayerModule.setTextTrackStyle(this._view.nativeHandle, {
105
106
  marginLeft: margin,
106
107
  });
107
108
  }
@@ -112,7 +113,7 @@ export class TextTrackStyleAdapter implements TextTrackStyle {
112
113
 
113
114
  set marginRight(margin: number | undefined) {
114
115
  this._marginRight = margin;
115
- NativeModules.PlayerModule.setTextTrackStyle(this._view.nativeHandle, {
116
+ NativePlayerModule.setTextTrackStyle(this._view.nativeHandle, {
116
117
  marginRight: margin,
117
118
  });
118
119
  }
@@ -123,7 +124,7 @@ export class TextTrackStyleAdapter implements TextTrackStyle {
123
124
 
124
125
  set marginTop(margin: number | undefined) {
125
126
  this._marginTop = margin;
126
- NativeModules.PlayerModule.setTextTrackStyle(this._view.nativeHandle, {
127
+ NativePlayerModule.setTextTrackStyle(this._view.nativeHandle, {
127
128
  marginTop: margin,
128
129
  });
129
130
  }
@@ -13,6 +13,8 @@ import { toNativeCachingTaskParameters } from "./NativeCachingTaskParametersAdap
13
13
 
14
14
  const TAG = "NativeMediaCache";
15
15
 
16
+ const NativeCacheModule = NativeModules.THEORCTCacheModule;
17
+
16
18
  interface NativeCachingStatusChangeEvent {
17
19
  readonly id: string;
18
20
  readonly status: CacheTaskStatus;
@@ -43,7 +45,7 @@ interface NativeCachingTaskProgressEvent {
43
45
  }
44
46
 
45
47
  export class NativeMediaCache extends DefaultEventDispatcher<CacheEventMap> implements MediaCacheAPI {
46
- private _emitter: NativeEventEmitter = new NativeEventEmitter(NativeModules.CacheModule);
48
+ private _emitter: NativeEventEmitter = new NativeEventEmitter(NativeCacheModule);
47
49
  private _status: CacheStatus = CacheStatus.uninitialised;
48
50
  private _tasks: NativeCachingTaskAdapter[] = [];
49
51
 
@@ -58,7 +60,7 @@ export class NativeMediaCache extends DefaultEventDispatcher<CacheEventMap> impl
58
60
  }
59
61
 
60
62
  async createTask(source: SourceDescription, parameters: CachingTaskParameters): Promise<CachingTask> {
61
- return NativeModules.CacheModule.createTask(source, toNativeCachingTaskParameters(parameters));
63
+ return NativeCacheModule.createTask(source, toNativeCachingTaskParameters(parameters));
62
64
  }
63
65
 
64
66
  get status(): CacheStatus {
@@ -81,7 +83,7 @@ export class NativeMediaCache extends DefaultEventDispatcher<CacheEventMap> impl
81
83
  }
82
84
 
83
85
  private async getInitialState(): Promise<void> {
84
- const initialState = await NativeModules.CacheModule.getInitialState();
86
+ const initialState = await NativeCacheModule.getInitialState();
85
87
  this._status = initialState.status;
86
88
  this._tasks = initialState.tasks.map((task: NativeCachingTask) => new NativeCachingTaskAdapter(task));
87
89
  }
@@ -12,6 +12,8 @@ import { NativeModules } from 'react-native';
12
12
  import type { DRMConfiguration } from 'react-native-theoplayer';
13
13
  import { fromNativeCachingTaskParameters, NativeCachingTaskParameters } from "./NativeCachingTaskParametersAdapter";
14
14
 
15
+ const NativeCacheModule = NativeModules.THEORCTCacheModule;
16
+
15
17
  export interface NativeCachingTask {
16
18
  readonly id: string;
17
19
 
@@ -56,7 +58,7 @@ export class NativeCachingTaskAdapter extends DefaultEventDispatcher<CachingTask
56
58
  this.bytesCached = task.bytesCached;
57
59
  this.license = {
58
60
  renew(drmConfiguration?: DRMConfiguration) {
59
- NativeModules.CacheModule.renewLicense(task.id, drmConfiguration);
61
+ NativeCacheModule.renewLicense(task.id, drmConfiguration);
60
62
  },
61
63
  };
62
64
  this.parameters = fromNativeCachingTaskParameters(task.parameters);
@@ -68,14 +70,14 @@ export class NativeCachingTaskAdapter extends DefaultEventDispatcher<CachingTask
68
70
  }
69
71
 
70
72
  pause(): void {
71
- NativeModules.CacheModule.pauseCachingTask(this.id);
73
+ NativeCacheModule.pauseCachingTask(this.id);
72
74
  }
73
75
 
74
76
  remove(): void {
75
- NativeModules.CacheModule.removeCachingTask(this.id);
77
+ NativeCacheModule.removeCachingTask(this.id);
76
78
  }
77
79
 
78
80
  start(): void {
79
- NativeModules.CacheModule.startCachingTask(this.id);
81
+ NativeCacheModule.startCachingTask(this.id);
80
82
  }
81
83
  }
@@ -10,6 +10,8 @@ import { fromNativeCertificateRequest, NativeCertificateRequest, toNativeCertifi
10
10
  import { fromNativeCertificateResponse, NativeCertificateResponse, toNativeCertificateResponseResult } from './NativeCertificateResponse';
11
11
  import { isBufferSource } from '../utils/TypeUtils';
12
12
 
13
+ const NativeContentProtectionModule = NativeModules.THEORCTContentProtectionModule;
14
+
13
15
  interface WrappedContentProtectionIntegrationFactory {
14
16
  integrationId: string;
15
17
  keySystemId: string;
@@ -36,7 +38,7 @@ export class NativeContentProtectionRegistry implements ContentProtectionAPI {
36
38
  private currentIntegration: WrappedContentProtectionIntegration | undefined = undefined;
37
39
 
38
40
  constructor() {
39
- this.emitter = new NativeEventEmitter(NativeModules.ContentProtectionModule);
41
+ this.emitter = new NativeEventEmitter(NativeContentProtectionModule);
40
42
  this.emitter.addListener('onBuildIntegration', this.onBuildIntegrationRequest);
41
43
  this.emitter.addListener('onCertificateRequest', this.onCertificateRequest);
42
44
  this.emitter.addListener('onCertificateResponse', this.onCertificateResponse);
@@ -51,7 +53,7 @@ export class NativeContentProtectionRegistry implements ContentProtectionAPI {
51
53
  keySystemId,
52
54
  integrationFactory,
53
55
  });
54
- NativeModules.ContentProtectionModule.registerContentProtectionIntegration(integrationId, keySystemId);
56
+ NativeContentProtectionModule.registerContentProtectionIntegration(integrationId, keySystemId);
55
57
  }
56
58
 
57
59
  private getFactory(integrationId: string, keySystemId: string): ContentProtectionIntegrationFactory | undefined {
@@ -66,7 +68,7 @@ export class NativeContentProtectionRegistry implements ContentProtectionAPI {
66
68
 
67
69
  private onBuildIntegrationRequest = (event: BuildEvent) => {
68
70
  const { requestId, integrationId, keySystemId, drmConfig } = event;
69
- console.log('ContentProtectionModule', `onBuildIntegrationRequest ${integrationId} ${keySystemId}`);
71
+ console.log('NativeContentProtectionModule', `onBuildIntegrationRequest ${integrationId} ${keySystemId}`);
70
72
  const factory = this.getFactory(integrationId, keySystemId);
71
73
  if (factory) {
72
74
  this.currentIntegration = {
@@ -74,9 +76,9 @@ export class NativeContentProtectionRegistry implements ContentProtectionAPI {
74
76
  keySystemId,
75
77
  integration: factory.build(drmConfig),
76
78
  };
77
- NativeModules.ContentProtectionModule.onBuildProcessed({ requestId, resultString: 'success' });
79
+ NativeContentProtectionModule.onBuildProcessed({ requestId, resultString: 'success' });
78
80
  } else {
79
- NativeModules.ContentProtectionModule.onBuildProcessed({
81
+ NativeContentProtectionModule.onBuildProcessed({
80
82
  requestId,
81
83
  resultString: 'failed',
82
84
  });
@@ -85,40 +87,40 @@ export class NativeContentProtectionRegistry implements ContentProtectionAPI {
85
87
 
86
88
  private onCertificateRequest = async (request: NativeCertificateRequest) => {
87
89
  const { requestId, integrationId, keySystemId } = request;
88
- console.log('ContentProtectionModule', `onCertificateRequest ${integrationId} ${keySystemId}`);
90
+ console.log('NativeContentProtectionModule', `onCertificateRequest ${integrationId} ${keySystemId}`);
89
91
  const integration = this.getIntegration(integrationId, keySystemId);
90
92
  if (integration?.onCertificateRequest) {
91
93
  const result = await integration.onCertificateRequest(fromNativeCertificateRequest(request));
92
94
  // TODO: we also want to support ArrayBufferView results
93
95
  if (isBufferSource(result)) {
94
96
  const nativeResponse = toNativeCertificateResponseResult(requestId, integrationId, keySystemId, result as ArrayBuffer);
95
- NativeModules.ContentProtectionModule.onCertificateRequestProcessedAsCertificate(nativeResponse);
97
+ NativeContentProtectionModule.onCertificateRequestProcessedAsCertificate(nativeResponse);
96
98
  } else if (result as CertificateRequest) {
97
99
  const modifiedNativeRequest = toNativeCertificateRequest(requestId, integrationId, keySystemId, result as CertificateRequest);
98
- NativeModules.ContentProtectionModule.onCertificateRequestProcessedAsRequest(modifiedNativeRequest);
100
+ NativeContentProtectionModule.onCertificateRequestProcessedAsRequest(modifiedNativeRequest);
99
101
  }
100
102
  } else {
101
- NativeModules.ContentProtectionModule.onCertificateRequestProcessedAsRequest(request);
103
+ NativeContentProtectionModule.onCertificateRequestProcessedAsRequest(request);
102
104
  }
103
105
  };
104
106
 
105
107
  private onCertificateResponse = async (response: NativeCertificateResponse) => {
106
108
  const { requestId, integrationId, keySystemId } = response;
107
- console.log('ContentProtectionModule', `onCertificateResponse ${integrationId} ${keySystemId}`);
109
+ console.log('NativeContentProtectionModule', `onCertificateResponse ${integrationId} ${keySystemId}`);
108
110
  const integration = this.getIntegration(integrationId, keySystemId);
109
111
  if (integration?.onCertificateResponse) {
110
112
  const responseResult = await integration.onCertificateResponse(fromNativeCertificateResponse(response));
111
113
  // TODO: we also want to support ArrayBufferView results
112
114
  const modifiedNativeResponse = toNativeCertificateResponseResult(requestId, integrationId, keySystemId, responseResult as ArrayBuffer);
113
- NativeModules.ContentProtectionModule.onCertificateResponseProcessed(modifiedNativeResponse);
115
+ NativeContentProtectionModule.onCertificateResponseProcessed(modifiedNativeResponse);
114
116
  } else {
115
- NativeModules.ContentProtectionModule.onCertificateResponseProcessed(response);
117
+ NativeContentProtectionModule.onCertificateResponseProcessed(response);
116
118
  }
117
119
  };
118
120
 
119
121
  private onLicenseRequest = async (request: NativeLicenseRequest) => {
120
122
  const { requestId, integrationId, keySystemId } = request;
121
- console.log('ContentProtectionModule', `onLicenseRequest ${integrationId} ${keySystemId}`);
123
+ console.log('NativeContentProtectionModule', `onLicenseRequest ${integrationId} ${keySystemId}`);
122
124
  const integration = this.getIntegration(integrationId, keySystemId);
123
125
  // Optionally let the custom integration modify the request.
124
126
  if (integration?.onLicenseRequest) {
@@ -126,43 +128,43 @@ export class NativeContentProtectionRegistry implements ContentProtectionAPI {
126
128
  // TODO: we also want to support ArrayBufferView results
127
129
  if (isBufferSource(result)) {
128
130
  const nativeResponse = toNativeLicenseResponseResult(requestId, integrationId, keySystemId, result as ArrayBuffer);
129
- NativeModules.ContentProtectionModule.onLicenseRequestProcessedAsLicense(nativeResponse);
131
+ NativeContentProtectionModule.onLicenseRequestProcessedAsLicense(nativeResponse);
130
132
  } else if (result as LicenseRequest) {
131
133
  const modifiedNativeRequest = toNativeLicenseRequest(requestId, integrationId, keySystemId, result as LicenseRequest);
132
- NativeModules.ContentProtectionModule.onLicenseRequestProcessedAsRequest(modifiedNativeRequest);
134
+ NativeContentProtectionModule.onLicenseRequestProcessedAsRequest(modifiedNativeRequest);
133
135
  }
134
136
  } else {
135
- NativeModules.ContentProtectionModule.onLicenseRequestProcessedAsRequest(request);
137
+ NativeContentProtectionModule.onLicenseRequestProcessedAsRequest(request);
136
138
  }
137
139
  };
138
140
 
139
141
  private onLicenseResponse = async (response: NativeLicenseResponse) => {
140
142
  const { requestId, integrationId, keySystemId } = response;
141
- console.log('ContentProtectionModule', `onLicenseResponse ${integrationId} ${keySystemId}`);
143
+ console.log('NativeContentProtectionModule', `onLicenseResponse ${integrationId} ${keySystemId}`);
142
144
  const integration = this.getIntegration(integrationId, keySystemId);
143
145
  if (integration?.onLicenseResponse) {
144
146
  const responseResult = await integration.onLicenseResponse(fromNativeLicenseResponse(response));
145
147
  // TODO: we also want to support ArrayBufferView results
146
148
  const modifiedNativeResponse = toNativeLicenseResponseResult(requestId, integrationId, keySystemId, responseResult as ArrayBuffer);
147
- NativeModules.ContentProtectionModule.onLicenseResponseProcessed(modifiedNativeResponse);
149
+ NativeContentProtectionModule.onLicenseResponseProcessed(modifiedNativeResponse);
148
150
  } else {
149
- NativeModules.ContentProtectionModule.onLicenseResponseProcessed(response);
151
+ NativeContentProtectionModule.onLicenseResponseProcessed(response);
150
152
  }
151
153
  };
152
154
 
153
155
  private onExtractFairplayContentId = async (event: ExtractFaiplayContentIdEvent) => {
154
156
  const { integrationId, keySystemId, fairplaySkdUrl, requestId } = event;
155
- console.log('ContentProtectionModule', `onExtractFairplayContentId ${integrationId} ${keySystemId}`);
157
+ console.log('NativeContentProtectionModule', `onExtractFairplayContentId ${integrationId} ${keySystemId}`);
156
158
  const integration = this.getIntegration(integrationId, keySystemId);
157
159
  if (integration?.extractFairplayContentId) {
158
160
  const contentId = await integration.extractFairplayContentId(fairplaySkdUrl);
159
- NativeModules.ContentProtectionModule.onExtractFairplayContentIdProcessed({
161
+ NativeContentProtectionModule.onExtractFairplayContentIdProcessed({
160
162
  requestId,
161
163
  contentId,
162
164
  });
163
165
  } else {
164
166
  const contentId = fairplaySkdUrl;
165
- NativeModules.ContentProtectionModule.onExtractFairplayContentIdProcessed({
167
+ NativeContentProtectionModule.onExtractFairplayContentIdProcessed({
166
168
  requestId,
167
169
  contentId,
168
170
  });