react-native-theoplayer 11.8.0 → 11.10.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 (90) hide show
  1. package/CHANGELOG.md +32 -1
  2. package/README.md +0 -67
  3. package/android/build.gradle +2 -0
  4. package/android/src/main/java/com/theoplayer/ReactTHEOplayerContext.kt +1 -0
  5. package/android/src/main/java/com/theoplayer/ads/AdAdapter.kt +33 -7
  6. package/android/src/main/java/com/theoplayer/ads/AdEventAdapter.kt +8 -1
  7. package/android/src/main/java/com/theoplayer/drm/ContentProtectionAdapter.kt +7 -0
  8. package/android/src/main/java/com/theoplayer/drm/KeySystemAdapter.kt +5 -5
  9. package/android/src/main/java/com/theoplayer/integration/PlayerFacadeAds.kt +3 -6
  10. package/android/src/main/java/com/theoplayer/source/SourceAdapter.kt +23 -0
  11. package/android/src/main/java/com/theoplayer/util/BridgeUtils.kt +4 -4
  12. package/android/src/test/java/com/theoplayer/ads/AdAdapterCustomDataTest.kt +144 -0
  13. package/android/src/test/java/com/theoplayer/drm/KeySystemAdapterTest.kt +30 -0
  14. package/android/src/test/java/com/theoplayer/integration/PlayerFacadeTest.kt +18 -0
  15. package/android/src/test/java/com/theoplayer/integration/PlayerFacadeTestHost.kt +1 -1
  16. package/ios/THEOplayerRCTBridge.m +7 -0
  17. package/ios/THEOplayerRCTMainEventHandler.swift +27 -1
  18. package/ios/THEOplayerRCTPlayerAPI.swift +20 -0
  19. package/ios/ads/THEOplayerRCTAdAdapter.swift +14 -3
  20. package/ios/ads/THEOplayerRCTAdsNative.swift +4 -0
  21. package/lib/commonjs/api/source/abr/SourceAbrConfiguration.js +2 -0
  22. package/lib/commonjs/api/source/abr/SourceAbrConfiguration.js.map +1 -0
  23. package/lib/commonjs/api/source/abr/barrel.js +17 -0
  24. package/lib/commonjs/api/source/abr/barrel.js.map +1 -0
  25. package/lib/commonjs/api/source/barrel.js +18 -7
  26. package/lib/commonjs/api/source/barrel.js.map +1 -1
  27. package/lib/commonjs/internal/adapter/DefaultNativePlayerState.js +1 -0
  28. package/lib/commonjs/internal/adapter/DefaultNativePlayerState.js.map +1 -1
  29. package/lib/commonjs/internal/adapter/THEOplayerAdapter.js +9 -0
  30. package/lib/commonjs/internal/adapter/THEOplayerAdapter.js.map +1 -1
  31. package/lib/commonjs/internal/adapter/THEOplayerWebAdapter.js +13 -1
  32. package/lib/commonjs/internal/adapter/THEOplayerWebAdapter.js.map +1 -1
  33. package/lib/commonjs/internal/adapter/event/native/NativeTheoLiveEvent.js +2 -2
  34. package/lib/commonjs/internal/adapter/event/native/NativeTheoLiveEvent.js.map +1 -1
  35. package/lib/commonjs/manifest.json +1 -1
  36. package/lib/module/api/source/abr/SourceAbrConfiguration.js +2 -0
  37. package/lib/module/api/source/abr/SourceAbrConfiguration.js.map +1 -0
  38. package/lib/module/api/source/abr/barrel.js +4 -0
  39. package/lib/module/api/source/abr/barrel.js.map +1 -0
  40. package/lib/module/api/source/barrel.js +1 -0
  41. package/lib/module/api/source/barrel.js.map +1 -1
  42. package/lib/module/internal/adapter/DefaultNativePlayerState.js +1 -0
  43. package/lib/module/internal/adapter/DefaultNativePlayerState.js.map +1 -1
  44. package/lib/module/internal/adapter/THEOplayerAdapter.js +9 -0
  45. package/lib/module/internal/adapter/THEOplayerAdapter.js.map +1 -1
  46. package/lib/module/internal/adapter/THEOplayerWebAdapter.js +13 -1
  47. package/lib/module/internal/adapter/THEOplayerWebAdapter.js.map +1 -1
  48. package/lib/module/internal/adapter/event/native/NativeTheoLiveEvent.js +2 -2
  49. package/lib/module/internal/adapter/event/native/NativeTheoLiveEvent.js.map +1 -1
  50. package/lib/module/manifest.json +1 -1
  51. package/lib/typescript/__tests__/NativeTheoLiveEvent.test.d.ts +2 -0
  52. package/lib/typescript/__tests__/NativeTheoLiveEvent.test.d.ts.map +1 -0
  53. package/lib/typescript/api/ads/Ad.d.ts +9 -0
  54. package/lib/typescript/api/ads/Ad.d.ts.map +1 -1
  55. package/lib/typescript/api/ads/AdBreak.d.ts +9 -0
  56. package/lib/typescript/api/ads/AdBreak.d.ts.map +1 -1
  57. package/lib/typescript/api/player/THEOplayer.d.ts +11 -0
  58. package/lib/typescript/api/player/THEOplayer.d.ts.map +1 -1
  59. package/lib/typescript/api/source/SourceDescription.d.ts +7 -0
  60. package/lib/typescript/api/source/SourceDescription.d.ts.map +1 -1
  61. package/lib/typescript/api/source/abr/SourceAbrConfiguration.d.ts +27 -0
  62. package/lib/typescript/api/source/abr/SourceAbrConfiguration.d.ts.map +1 -0
  63. package/lib/typescript/api/source/abr/barrel.d.ts +2 -0
  64. package/lib/typescript/api/source/abr/barrel.d.ts.map +1 -0
  65. package/lib/typescript/api/source/barrel.d.ts +1 -0
  66. package/lib/typescript/api/source/barrel.d.ts.map +1 -1
  67. package/lib/typescript/internal/adapter/DefaultNativePlayerState.d.ts +1 -0
  68. package/lib/typescript/internal/adapter/DefaultNativePlayerState.d.ts.map +1 -1
  69. package/lib/typescript/internal/adapter/NativePlayerState.d.ts +1 -0
  70. package/lib/typescript/internal/adapter/NativePlayerState.d.ts.map +1 -1
  71. package/lib/typescript/internal/adapter/THEOplayerAdapter.d.ts +2 -0
  72. package/lib/typescript/internal/adapter/THEOplayerAdapter.d.ts.map +1 -1
  73. package/lib/typescript/internal/adapter/THEOplayerWebAdapter.d.ts +2 -0
  74. package/lib/typescript/internal/adapter/THEOplayerWebAdapter.d.ts.map +1 -1
  75. package/package.json +1 -1
  76. package/src/__tests__/NativeTheoLiveEvent.test.ts +82 -0
  77. package/src/__tests__/PlayerFacadeWebAdapter.test.ts +13 -0
  78. package/src/api/ads/Ad.ts +10 -0
  79. package/src/api/ads/AdBreak.ts +10 -0
  80. package/src/api/player/THEOplayer.ts +12 -0
  81. package/src/api/source/SourceDescription.ts +8 -0
  82. package/src/api/source/abr/SourceAbrConfiguration.ts +27 -0
  83. package/src/api/source/abr/barrel.ts +1 -0
  84. package/src/api/source/barrel.ts +1 -0
  85. package/src/internal/adapter/DefaultNativePlayerState.ts +1 -0
  86. package/src/internal/adapter/NativePlayerState.ts +1 -0
  87. package/src/internal/adapter/THEOplayerAdapter.ts +11 -0
  88. package/src/internal/adapter/THEOplayerWebAdapter.ts +15 -1
  89. package/src/internal/adapter/event/native/NativeTheoLiveEvent.ts +2 -2
  90. package/src/manifest.json +1 -1
@@ -0,0 +1,82 @@
1
+ import type { NativeSyntheticEvent } from 'react-native';
2
+ import type { NativeTheoLiveEvent } from '../internal/adapter/event/native/NativeTheoLiveEvent';
3
+
4
+ import assert from 'node:assert/strict';
5
+ import { test } from 'node:test';
6
+ import { readFileSync } from 'node:fs';
7
+ import path from 'node:path';
8
+ import ts from 'typescript';
9
+
10
+ const modules = new Map<string, object>();
11
+
12
+ function loadSource(file: string): object {
13
+ const cached = modules.get(file);
14
+ if (cached) return cached;
15
+ const compiled = ts.transpileModule(readFileSync(file, 'utf8'), {
16
+ compilerOptions: { target: ts.ScriptTarget.ES2020, module: ts.ModuleKind.CommonJS },
17
+ });
18
+ const exports = {};
19
+ modules.set(file, exports);
20
+ new Function('exports', 'require', compiled.outputText)(exports, (specifier: string) => {
21
+ if (specifier === 'react-native-theoplayer') {
22
+ return {
23
+ ...loadSource(path.resolve('src/api/player/PlayerEventMap.ts')),
24
+ ...loadSource(path.resolve('src/api/event/TheoLiveEvent.ts')),
25
+ };
26
+ }
27
+ assert.ok(specifier.startsWith('.'), 'Event adapter runtime imports must remain local');
28
+ return loadSource(path.resolve(path.dirname(file), `${specifier}.ts`));
29
+ });
30
+ return exports;
31
+ }
32
+
33
+ const { fromNativeTheoLiveEvent } = loadSource(
34
+ path.resolve('src/internal/adapter/event/native/NativeTheoLiveEvent.ts'),
35
+ ) as typeof import('../internal/adapter/event/native/NativeTheoLiveEvent');
36
+ const { DefaultTheoLiveEndpointLoadedEvent, DefaultTheoLiveDistributionEvent, DefaultTheoLiveIntentToFallbackEvent, DefaultTheoLiveEvent } =
37
+ loadSource(path.resolve('src/internal/adapter/event/PlayerEvents.ts')) as typeof import('../internal/adapter/event/PlayerEvents');
38
+ const { TheoLiveEventType } = loadSource(path.resolve('src/api/event/TheoLiveEvent.ts')) as typeof import('../api/event/TheoLiveEvent');
39
+
40
+ function nativeEvent(payload: Partial<NativeTheoLiveEvent> & Pick<NativeTheoLiveEvent, 'type'>) {
41
+ return fromNativeTheoLiveEvent({
42
+ type: 'nativetheoliveevent',
43
+ nativeEvent: payload,
44
+ } as NativeSyntheticEvent<NativeTheoLiveEvent>);
45
+ }
46
+
47
+ test('New Architecture endpointloaded preserves the endpoint', () => {
48
+ const endpoint = { provider: 'mediakind', hlsSrc: 'https://cdn.example.com/live.m3u8', weight: 1, priority: 1 };
49
+ const event = nativeEvent({ type: TheoLiveEventType.ENDPOINT_LOADED, endpoint });
50
+ assert.ok(event instanceof DefaultTheoLiveEndpointLoadedEvent);
51
+ assert.equal(event.type, 'theolive');
52
+ assert.equal(event.subType, TheoLiveEventType.ENDPOINT_LOADED);
53
+ assert.equal(event.endpoint, endpoint);
54
+ });
55
+
56
+ test('New Architecture distributionloadstart preserves the distribution identifier', () => {
57
+ const event = nativeEvent({ type: TheoLiveEventType.DISTRIBUTION_LOAD_START, distributionId: 'distribution-1' });
58
+ assert.ok(event instanceof DefaultTheoLiveDistributionEvent);
59
+ assert.equal(event.subType, TheoLiveEventType.DISTRIBUTION_LOAD_START);
60
+ assert.equal(event.distributionId, 'distribution-1');
61
+ });
62
+
63
+ test('New Architecture distributionloadstart defaults a missing distribution identifier', () => {
64
+ const event = nativeEvent({ type: TheoLiveEventType.DISTRIBUTION_LOAD_START });
65
+ assert.ok(event instanceof DefaultTheoLiveDistributionEvent);
66
+ assert.equal(event.subType, TheoLiveEventType.DISTRIBUTION_LOAD_START);
67
+ assert.equal(event.distributionId, '');
68
+ });
69
+
70
+ test('New Architecture intenttofallback preserves the error reason', () => {
71
+ const reason = { errorCode: 'NETWORK_ERROR', errorMessage: 'Endpoint unavailable' };
72
+ const event = nativeEvent({ type: TheoLiveEventType.INTENT_TO_FALLBACK, reason });
73
+ assert.ok(event instanceof DefaultTheoLiveIntentToFallbackEvent);
74
+ assert.equal(event.subType, TheoLiveEventType.INTENT_TO_FALLBACK);
75
+ assert.equal(event.reason, reason);
76
+ });
77
+
78
+ test('New Architecture generic events preserve the native subtype', () => {
79
+ const event = nativeEvent({ type: 'futureevent' as NativeTheoLiveEvent['type'] });
80
+ assert.ok(event instanceof DefaultTheoLiveEvent);
81
+ assert.equal(event.subType, 'futureevent');
82
+ });
@@ -109,6 +109,19 @@ function setup(enabled = true) {
109
109
  return { adapter, facade, content, session, actions };
110
110
  }
111
111
 
112
+ for (const enabled of [false, true]) {
113
+ test(`external playback assignments are ignored on Web (facade=${enabled})`, () => {
114
+ const { adapter, content } = setup(enabled);
115
+ assert.equal(adapter.allowsExternalPlayback, true);
116
+ adapter.allowsExternalPlayback = false;
117
+ assert.equal(adapter.allowsExternalPlayback, true);
118
+ adapter.allowsExternalPlayback = true;
119
+ assert.equal(adapter.allowsExternalPlayback, true);
120
+ assert.equal('allowsExternalPlayback' in content, false);
121
+ adapter.destroy();
122
+ });
123
+ }
124
+
112
125
  test('media session uses facade clocks, commands, synthetic updates, and advertising state', () => {
113
126
  const { adapter, facade, content, session, actions } = setup();
114
127
  const commands: Array<string | number> = [];
package/src/api/ads/Ad.ts CHANGED
@@ -129,6 +129,16 @@ export interface Ad {
129
129
  * <br/> - Only supported for `'theo'` and `'google-ima'`.
130
130
  */
131
131
  universalAdIds: UniversalAdId[];
132
+
133
+ /**
134
+ * Additional integration-specific data associated with this ad.
135
+ *
136
+ * @remarks
137
+ * <br/> - The value depends on the ad integration. It may be `undefined` if the integration does not provide any custom data.
138
+ * <br/> - On native platforms, values must be JSON-serializable. Custom data is preserved both in events forwarded to JavaScript
139
+ * and in events broadcast to native listeners.
140
+ */
141
+ customData?: Record<string, unknown>;
132
142
  }
133
143
 
134
144
  /**
@@ -56,4 +56,14 @@ export interface AdBreak {
56
56
  * <br/> - This feature is not available in the Google IMA integration and will default to -1.
57
57
  */
58
58
  maxRemainingDuration: number | undefined;
59
+
60
+ /**
61
+ * Additional integration-specific data associated with this ad break.
62
+ *
63
+ * @remarks
64
+ * <br/> - The value depends on the ad integration. It may be `undefined` if the integration does not provide any custom data.
65
+ * <br/> - On native platforms, values must be JSON-serializable. Custom data is preserved both in events forwarded to JavaScript
66
+ * and in events broadcast to native listeners.
67
+ */
68
+ customData?: Record<string, unknown>;
59
69
  }
@@ -215,6 +215,18 @@ export interface THEOplayer extends EventDispatcher<PlayerEventMap> {
215
215
  */
216
216
  manageContentMatching: boolean;
217
217
 
218
+ /**
219
+ * Whether the player allows external playback through AirPlay.
220
+ *
221
+ * @defaultValue `true`
222
+ * @platform ios
223
+ *
224
+ * @remarks
225
+ * <br/> - Not supported for THEOlive sources.
226
+ * <br/> - On Android and Web, assignments are ignored and the getter returns `true`; this does not indicate AirPlay support.
227
+ */
228
+ allowsExternalPlayback: boolean;
229
+
218
230
  /**
219
231
  * Specifies where the player is displaying the video.
220
232
  *
@@ -16,6 +16,7 @@ import type { ServerSideAdInsertionConfiguration } from './ads/ssai/ServerSideAd
16
16
  import type { AnalyticsDescription } from './analytics/AnalyticsDescription';
17
17
  import { CmcdSourceConfiguration } from '../cmcd/CmcdConfiguration';
18
18
  import { SourceLatencyConfiguration } from './latency/SourceLatencyConfiguration';
19
+ import type { SourceAbrConfiguration } from './abr/SourceAbrConfiguration';
19
20
 
20
21
  /**
21
22
  * A type alias for a {@link TypedSource} media resource.
@@ -344,6 +345,13 @@ export interface BaseSource {
344
345
  * <br/> - Ignored for non-HLS streams.
345
346
  */
346
347
  hls?: HlsPlaybackConfiguration;
348
+
349
+ /**
350
+ * The source's ABR configuration.
351
+ *
352
+ * @platform web,android
353
+ */
354
+ abr?: SourceAbrConfiguration;
347
355
  }
348
356
 
349
357
  /**
@@ -0,0 +1,27 @@
1
+ /**
2
+ * Describes the ABR configuration for a specific source.
3
+ *
4
+ * @category Source
5
+ * @public
6
+ */
7
+ export interface SourceAbrConfiguration {
8
+ /**
9
+ * A list of preferred audio codecs which will be used by the ABR algorithm for track selection, if the codec is supported.
10
+ *
11
+ * @platform web,android
12
+ *
13
+ * @remarks
14
+ * <br/> - Codecs are specified by their RFC 6381 name, e.g. `"ec-3"` or `"mp4a.40.2"`.
15
+ */
16
+ preferredAudioCodecs?: string[];
17
+
18
+ /**
19
+ * A list of preferred video codecs which will be used by the ABR algorithm for track selection, if the codec is supported.
20
+ *
21
+ * @platform web,android
22
+ *
23
+ * @remarks
24
+ * <br/> - Codecs are specified by their RFC 6381 name, e.g. `"hvc1"`, `"dvh1"` or `"avc1"`.
25
+ */
26
+ preferredVideoCodecs?: string[];
27
+ }
@@ -0,0 +1 @@
1
+ export * from './SourceAbrConfiguration';
@@ -1,3 +1,4 @@
1
+ export * from './abr/barrel';
1
2
  export * from './ads/barrel';
2
3
  export * from './analytics/barrel';
3
4
  export * from './drm/barrel';
@@ -31,6 +31,7 @@ export class DefaultNativePlayerState extends DefaultTextTrackState implements N
31
31
  preload: PreloadType = 'none';
32
32
  aspectRatio: AspectRatio = AspectRatio.FIT;
33
33
  manageContentMatching = false;
34
+ allowsExternalPlayback = true;
34
35
  renderingTarget: RenderingTarget = RenderingTarget.SURFACE_VIEW;
35
36
  keepScreenOn = true;
36
37
  audioTracks: MediaTrack[] = [];
@@ -25,6 +25,7 @@ export interface PlaybackState {
25
25
  presentationMode: PresentationMode;
26
26
  aspectRatio: AspectRatio;
27
27
  manageContentMatching: boolean;
28
+ allowsExternalPlayback: boolean;
28
29
  renderingTarget: RenderingTarget;
29
30
  }
30
31
 
@@ -503,6 +503,17 @@ export class THEOplayerAdapter extends DefaultEventDispatcher<PlayerEventMap> im
503
503
  }
504
504
  }
505
505
 
506
+ get allowsExternalPlayback(): boolean {
507
+ return this._state.allowsExternalPlayback;
508
+ }
509
+
510
+ set allowsExternalPlayback(enable: boolean) {
511
+ if (Platform.OS === 'ios') {
512
+ this._state.allowsExternalPlayback = enable;
513
+ NativePlayerModule.setAllowsExternalPlayback(this._view.nativeHandle, enable);
514
+ }
515
+ }
516
+
506
517
  get renderingTarget(): RenderingTarget {
507
518
  return this._state.renderingTarget;
508
519
  }
@@ -374,6 +374,14 @@ export class THEOplayerWebAdapter extends DefaultEventDispatcher<PlayerEventMap>
374
374
  // unused
375
375
  }
376
376
 
377
+ get allowsExternalPlayback(): boolean {
378
+ return true;
379
+ }
380
+
381
+ set allowsExternalPlayback(_enable: boolean) {
382
+ // unused
383
+ }
384
+
377
385
  get keepScreenOn(): boolean {
378
386
  return false;
379
387
  }
@@ -419,9 +427,15 @@ export class THEOplayerWebAdapter extends DefaultEventDispatcher<PlayerEventMap>
419
427
  this._cmcdConnector = undefined;
420
428
  this._player?.removeEventListener('dimensionchange', this.onPlayerDimensionChange);
421
429
  try {
430
+ // The native player dispatches 'destroy' asynchronously, after destroy() returns, and the facade
431
+ // closes itself once it has forwarded that event (see PlayerFacade). Closing it here would detach
432
+ // every facade listener (e.g. the Bitmovin collector) before the event arrives.
422
433
  this._player?.destroy();
423
- } finally {
434
+ } catch (error) {
435
+ // The native destroy failed, so no 'destroy' event will come to close the facade.
424
436
  this._playerFacade?.close();
437
+ throw error;
438
+ } finally {
425
439
  this._player = undefined;
426
440
  }
427
441
  }
@@ -38,7 +38,7 @@ export interface NativeTheoLiveEvent {
38
38
 
39
39
  export function fromNativeTheoLiveEvent(event: NativeSyntheticEvent<NativeTheoLiveEvent>): TheoLiveEvent {
40
40
  const { nativeEvent } = event;
41
- switch (event.type) {
41
+ switch (nativeEvent.type) {
42
42
  case TheoLiveEventType.DISTRIBUTION_LOAD_START:
43
43
  return new DefaultTheoLiveDistributionEvent(TheoLiveEventType.DISTRIBUTION_LOAD_START, nativeEvent.distributionId ?? '');
44
44
  case TheoLiveEventType.DISTRIBUTION_LOADED:
@@ -50,6 +50,6 @@ export function fromNativeTheoLiveEvent(event: NativeSyntheticEvent<NativeTheoLi
50
50
  case TheoLiveEventType.INTENT_TO_FALLBACK:
51
51
  return new DefaultTheoLiveIntentToFallbackEvent(TheoLiveEventType.INTENT_TO_FALLBACK, nativeEvent.reason);
52
52
  default:
53
- return new DefaultTheoLiveEvent(event.type as TheoLiveEventType);
53
+ return new DefaultTheoLiveEvent(nativeEvent.type);
54
54
  }
55
55
  }
package/src/manifest.json CHANGED
@@ -1 +1 @@
1
- {"version":"11.8.0","buildDate":"2026-10-21T13:28:57.701Z"}
1
+ {"version":"11.10.0","buildDate":"2026-11-19T18:01:17.961Z"}