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
@@ -4,6 +4,7 @@ function _toPrimitive(input, hint) { if (typeof input !== "object" || input ===
4
4
  import { NativeModules } from 'react-native';
5
5
  import NamedColors from './NamedColors.json';
6
6
  const namedColorsMap = NamedColors;
7
+ const NativePlayerModule = NativeModules.THEORCTPlayerModule;
7
8
  export class TextTrackStyleAdapter {
8
9
  constructor(_view) {
9
10
  this._view = _view;
@@ -23,7 +24,7 @@ export class TextTrackStyleAdapter {
23
24
  }
24
25
  set backgroundColor(color) {
25
26
  this._backgroundColor = color;
26
- NativeModules.PlayerModule.setTextTrackStyle(this._view.nativeHandle, {
27
+ NativePlayerModule.setTextTrackStyle(this._view.nativeHandle, {
27
28
  backgroundColor: convertColorToRGBA(color)
28
29
  });
29
30
  }
@@ -32,7 +33,7 @@ export class TextTrackStyleAdapter {
32
33
  }
33
34
  set edgeStyle(style) {
34
35
  this._edgeStyle = style;
35
- NativeModules.PlayerModule.setTextTrackStyle(this._view.nativeHandle, {
36
+ NativePlayerModule.setTextTrackStyle(this._view.nativeHandle, {
36
37
  edgeStyle: style
37
38
  });
38
39
  }
@@ -41,7 +42,7 @@ export class TextTrackStyleAdapter {
41
42
  }
42
43
  set fontColor(color) {
43
44
  this._fontColor = color;
44
- NativeModules.PlayerModule.setTextTrackStyle(this._view.nativeHandle, {
45
+ NativePlayerModule.setTextTrackStyle(this._view.nativeHandle, {
45
46
  fontColor: convertColorToRGBA(color)
46
47
  });
47
48
  }
@@ -50,7 +51,7 @@ export class TextTrackStyleAdapter {
50
51
  }
51
52
  set fontFamily(family) {
52
53
  this._fontFamily = family;
53
- NativeModules.PlayerModule.setTextTrackStyle(this._view.nativeHandle, {
54
+ NativePlayerModule.setTextTrackStyle(this._view.nativeHandle, {
54
55
  fontFamily: family
55
56
  });
56
57
  }
@@ -59,7 +60,7 @@ export class TextTrackStyleAdapter {
59
60
  }
60
61
  set fontSize(size) {
61
62
  this._fontSize = size;
62
- NativeModules.PlayerModule.setTextTrackStyle(this._view.nativeHandle, {
63
+ NativePlayerModule.setTextTrackStyle(this._view.nativeHandle, {
63
64
  fontSize: fromPercentage(size)
64
65
  });
65
66
  }
@@ -68,7 +69,7 @@ export class TextTrackStyleAdapter {
68
69
  }
69
70
  set windowColor(color) {
70
71
  this._windowColor = color;
71
- NativeModules.PlayerModule.setTextTrackStyle(this._view.nativeHandle, {
72
+ NativePlayerModule.setTextTrackStyle(this._view.nativeHandle, {
72
73
  windowColor: convertColorToRGBA(color)
73
74
  });
74
75
  }
@@ -77,7 +78,7 @@ export class TextTrackStyleAdapter {
77
78
  }
78
79
  set marginBottom(margin) {
79
80
  this._marginBottom = margin;
80
- NativeModules.PlayerModule.setTextTrackStyle(this._view.nativeHandle, {
81
+ NativePlayerModule.setTextTrackStyle(this._view.nativeHandle, {
81
82
  marginBottom: margin
82
83
  });
83
84
  }
@@ -86,7 +87,7 @@ export class TextTrackStyleAdapter {
86
87
  }
87
88
  set marginLeft(margin) {
88
89
  this._marginLeft = margin;
89
- NativeModules.PlayerModule.setTextTrackStyle(this._view.nativeHandle, {
90
+ NativePlayerModule.setTextTrackStyle(this._view.nativeHandle, {
90
91
  marginLeft: margin
91
92
  });
92
93
  }
@@ -95,7 +96,7 @@ export class TextTrackStyleAdapter {
95
96
  }
96
97
  set marginRight(margin) {
97
98
  this._marginRight = margin;
98
- NativeModules.PlayerModule.setTextTrackStyle(this._view.nativeHandle, {
99
+ NativePlayerModule.setTextTrackStyle(this._view.nativeHandle, {
99
100
  marginRight: margin
100
101
  });
101
102
  }
@@ -104,7 +105,7 @@ export class TextTrackStyleAdapter {
104
105
  }
105
106
  set marginTop(margin) {
106
107
  this._marginTop = margin;
107
- NativeModules.PlayerModule.setTextTrackStyle(this._view.nativeHandle, {
108
+ NativePlayerModule.setTextTrackStyle(this._view.nativeHandle, {
108
109
  marginTop: margin
109
110
  });
110
111
  }
@@ -1 +1 @@
1
- {"version":3,"names":["NativeModules","NamedColors","namedColorsMap","TextTrackStyleAdapter","constructor","_view","_defineProperty","undefined","backgroundColor","_backgroundColor","color","PlayerModule","setTextTrackStyle","nativeHandle","convertColorToRGBA","edgeStyle","_edgeStyle","style","fontColor","_fontColor","fontFamily","_fontFamily","family","fontSize","_fontSize","size","fromPercentage","windowColor","_windowColor","marginBottom","_marginBottom","margin","marginLeft","_marginLeft","marginRight","_marginRight","marginTop","_marginTop","replace","toLowerCase","colorPattern","match","r","parseInt","g","b","a","pct","parseFloat"],"sources":["TextTrackStyleAdapter.ts"],"sourcesContent":["import type { EdgeStyle, TextTrackStyle, THEOplayerView } from 'react-native-theoplayer';\nimport { NativeModules } from 'react-native';\nimport NamedColors from './NamedColors.json';\n\nconst namedColorsMap = NamedColors as { [name: string]: string };\n\nexport class TextTrackStyleAdapter implements TextTrackStyle {\n private _backgroundColor: string | undefined = undefined;\n private _edgeStyle: EdgeStyle | undefined = undefined;\n private _fontColor: string | undefined = undefined;\n private _fontFamily: string | undefined = undefined;\n private _fontSize: string | undefined = undefined;\n private _windowColor: string | undefined = undefined;\n private _marginBottom: number | undefined = undefined;\n private _marginTop: number | undefined = undefined;\n private _marginLeft: number | undefined = undefined;\n private _marginRight: number | undefined = undefined;\n\n constructor(private readonly _view: THEOplayerView) {}\n\n get backgroundColor(): string | undefined {\n return this._backgroundColor;\n }\n\n set backgroundColor(color: string | undefined) {\n this._backgroundColor = color;\n NativeModules.PlayerModule.setTextTrackStyle(this._view.nativeHandle, {\n backgroundColor: convertColorToRGBA(color),\n });\n }\n\n get edgeStyle(): EdgeStyle | undefined {\n return this._edgeStyle;\n }\n\n set edgeStyle(style: EdgeStyle | undefined) {\n this._edgeStyle = style;\n NativeModules.PlayerModule.setTextTrackStyle(this._view.nativeHandle, {\n edgeStyle: style,\n });\n }\n\n get fontColor(): string | undefined {\n return this._fontColor;\n }\n\n set fontColor(color: string | undefined) {\n this._fontColor = color;\n NativeModules.PlayerModule.setTextTrackStyle(this._view.nativeHandle, {\n fontColor: convertColorToRGBA(color),\n });\n }\n\n get fontFamily(): string | undefined {\n return this._fontFamily;\n }\n\n set fontFamily(family: string | undefined) {\n this._fontFamily = family;\n NativeModules.PlayerModule.setTextTrackStyle(this._view.nativeHandle, {\n fontFamily: family,\n });\n }\n\n get fontSize(): string | undefined {\n return this._fontSize;\n }\n\n set fontSize(size: string | undefined) {\n this._fontSize = size;\n NativeModules.PlayerModule.setTextTrackStyle(this._view.nativeHandle, {\n fontSize: fromPercentage(size),\n });\n }\n\n get windowColor(): string | undefined {\n return this._windowColor;\n }\n\n set windowColor(color: string | undefined) {\n this._windowColor = color;\n NativeModules.PlayerModule.setTextTrackStyle(this._view.nativeHandle, {\n windowColor: convertColorToRGBA(color),\n });\n }\n\n get marginBottom(): number | undefined {\n return this._marginBottom;\n }\n\n set marginBottom(margin: number | undefined) {\n this._marginBottom = margin;\n NativeModules.PlayerModule.setTextTrackStyle(this._view.nativeHandle, {\n marginBottom: margin,\n });\n }\n\n get marginLeft(): number | undefined {\n return this._marginLeft;\n }\n\n set marginLeft(margin: number | undefined) {\n this._marginLeft = margin;\n NativeModules.PlayerModule.setTextTrackStyle(this._view.nativeHandle, {\n marginLeft: margin,\n });\n }\n\n get marginRight(): number | undefined {\n return this._marginRight;\n }\n\n set marginRight(margin: number | undefined) {\n this._marginRight = margin;\n NativeModules.PlayerModule.setTextTrackStyle(this._view.nativeHandle, {\n marginRight: margin,\n });\n }\n\n get marginTop(): number | undefined {\n return this._marginTop;\n }\n\n set marginTop(margin: number | undefined) {\n this._marginTop = margin;\n NativeModules.PlayerModule.setTextTrackStyle(this._view.nativeHandle, {\n marginTop: margin,\n });\n }\n}\n\ninterface BridgeColor {\n r: number;\n g: number;\n b: number;\n a: number;\n}\n\nfunction convertColorToRGBA(color: string | undefined): BridgeColor | null {\n if (!color) {\n return null;\n }\n\n color = color.replace('#', '');\n\n if (namedColorsMap[color.toLowerCase()]) {\n color = namedColorsMap[color.toLowerCase()];\n }\n\n const colorPattern = /^(?:#|0x)?([a-f\\d]{2})([a-f\\d]{2})([a-f\\d]{2})([a-f\\d]{2})?$/i;\n const match = color.match(colorPattern);\n\n if (!match) {\n return null;\n }\n\n const r = parseInt(match[1], 16);\n const g = parseInt(match[2], 16);\n const b = parseInt(match[3], 16);\n const a = match[4] ? parseInt(match[4], 16) : 255;\n return { r, g, b, a };\n}\n\nfunction fromPercentage(pct: string | undefined): number {\n return pct ? parseFloat(pct) : 100;\n}\n"],"mappings":";;;AACA,SAASA,aAAa,QAAQ,cAAc;AAC5C,OAAOC,WAAW,MAAM,oBAAoB;AAE5C,MAAMC,cAAc,GAAGD,WAAyC;AAEhE,OAAO,MAAME,qBAAqB,CAA2B;EAY3DC,WAAWA,CAAkBC,KAAqB,EAAE;IAAA,KAAvBA,KAAqB,GAArBA,KAAqB;IAAAC,eAAA,2BAXHC,SAAS;IAAAD,eAAA,qBACZC,SAAS;IAAAD,eAAA,qBACZC,SAAS;IAAAD,eAAA,sBACRC,SAAS;IAAAD,eAAA,oBACXC,SAAS;IAAAD,eAAA,uBACNC,SAAS;IAAAD,eAAA,wBACRC,SAAS;IAAAD,eAAA,qBACZC,SAAS;IAAAD,eAAA,sBACRC,SAAS;IAAAD,eAAA,uBACRC,SAAS;EAEC;EAErD,IAAIC,eAAeA,CAAA,EAAuB;IACxC,OAAO,IAAI,CAACC,gBAAgB;EAC9B;EAEA,IAAID,eAAeA,CAACE,KAAyB,EAAE;IAC7C,IAAI,CAACD,gBAAgB,GAAGC,KAAK;IAC7BV,aAAa,CAACW,YAAY,CA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1
+ {"version":3,"names":["NativeModules","NamedColors","namedColorsMap","NativePlayerModule","THEORCTPlayerModule","TextTrackStyleAdapter","constructor","_view","_defineProperty","undefined","backgroundColor","_backgroundColor","color","setTextTrackStyle","nativeHandle","convertColorToRGBA","edgeStyle","_edgeStyle","style","fontColor","_fontColor","fontFamily","_fontFamily","family","fontSize","_fontSize","size","fromPercentage","windowColor","_windowColor","marginBottom","_marginBottom","margin","marginLeft","_marginLeft","marginRight","_marginRight","marginTop","_marginTop","replace","toLowerCase","colorPattern","match","r","parseInt","g","b","a","pct","parseFloat"],"sources":["TextTrackStyleAdapter.ts"],"sourcesContent":["import type { EdgeStyle, TextTrackStyle, THEOplayerView } from 'react-native-theoplayer';\nimport { NativeModules } from 'react-native';\nimport NamedColors from './NamedColors.json';\n\nconst namedColorsMap = NamedColors as { [name: string]: string };\nconst NativePlayerModule = NativeModules.THEORCTPlayerModule;\n\nexport class TextTrackStyleAdapter implements TextTrackStyle {\n private _backgroundColor: string | undefined = undefined;\n private _edgeStyle: EdgeStyle | undefined = undefined;\n private _fontColor: string | undefined = undefined;\n private _fontFamily: string | undefined = undefined;\n private _fontSize: string | undefined = undefined;\n private _windowColor: string | undefined = undefined;\n private _marginBottom: number | undefined = undefined;\n private _marginTop: number | undefined = undefined;\n private _marginLeft: number | undefined = undefined;\n private _marginRight: number | undefined = undefined;\n\n constructor(private readonly _view: THEOplayerView) {}\n\n get backgroundColor(): string | undefined {\n return this._backgroundColor;\n }\n\n set backgroundColor(color: string | undefined) {\n this._backgroundColor = color;\n NativePlayerModule.setTextTrackStyle(this._view.nativeHandle, {\n backgroundColor: convertColorToRGBA(color),\n });\n }\n\n get edgeStyle(): EdgeStyle | undefined {\n return this._edgeStyle;\n }\n\n set edgeStyle(style: EdgeStyle | undefined) {\n this._edgeStyle = style;\n NativePlayerModule.setTextTrackStyle(this._view.nativeHandle, {\n edgeStyle: style,\n });\n }\n\n get fontColor(): string | undefined {\n return this._fontColor;\n }\n\n set fontColor(color: string | undefined) {\n this._fontColor = color;\n NativePlayerModule.setTextTrackStyle(this._view.nativeHandle, {\n fontColor: convertColorToRGBA(color),\n });\n }\n\n get fontFamily(): string | undefined {\n return this._fontFamily;\n }\n\n set fontFamily(family: string | undefined) {\n this._fontFamily = family;\n NativePlayerModule.setTextTrackStyle(this._view.nativeHandle, {\n fontFamily: family,\n });\n }\n\n get fontSize(): string | undefined {\n return this._fontSize;\n }\n\n set fontSize(size: string | undefined) {\n this._fontSize = size;\n NativePlayerModule.setTextTrackStyle(this._view.nativeHandle, {\n fontSize: fromPercentage(size),\n });\n }\n\n get windowColor(): string | undefined {\n return this._windowColor;\n }\n\n set windowColor(color: string | undefined) {\n this._windowColor = color;\n NativePlayerModule.setTextTrackStyle(this._view.nativeHandle, {\n windowColor: convertColorToRGBA(color),\n });\n }\n\n get marginBottom(): number | undefined {\n return this._marginBottom;\n }\n\n set marginBottom(margin: number | undefined) {\n this._marginBottom = margin;\n NativePlayerModule.setTextTrackStyle(this._view.nativeHandle, {\n marginBottom: margin,\n });\n }\n\n get marginLeft(): number | undefined {\n return this._marginLeft;\n }\n\n set marginLeft(margin: number | undefined) {\n this._marginLeft = margin;\n NativePlayerModule.setTextTrackStyle(this._view.nativeHandle, {\n marginLeft: margin,\n });\n }\n\n get marginRight(): number | undefined {\n return this._marginRight;\n }\n\n set marginRight(margin: number | undefined) {\n this._marginRight = margin;\n NativePlayerModule.setTextTrackStyle(this._view.nativeHandle, {\n marginRight: margin,\n });\n }\n\n get marginTop(): number | undefined {\n return this._marginTop;\n }\n\n set marginTop(margin: number | undefined) {\n this._marginTop = margin;\n NativePlayerModule.setTextTrackStyle(this._view.nativeHandle, {\n marginTop: margin,\n });\n }\n}\n\ninterface BridgeColor {\n r: number;\n g: number;\n b: number;\n a: number;\n}\n\nfunction convertColorToRGBA(color: string | undefined): BridgeColor | null {\n if (!color) {\n return null;\n }\n\n color = color.replace('#', '');\n\n if (namedColorsMap[color.toLowerCase()]) {\n color = namedColorsMap[color.toLowerCase()];\n }\n\n const colorPattern = /^(?:#|0x)?([a-f\\d]{2})([a-f\\d]{2})([a-f\\d]{2})([a-f\\d]{2})?$/i;\n const match = color.match(colorPattern);\n\n if (!match) {\n return null;\n }\n\n const r = parseInt(match[1], 16);\n const g = parseInt(match[2], 16);\n const b = parseInt(match[3], 16);\n const a = match[4] ? parseInt(match[4], 16) : 255;\n return { r, g, b, a };\n}\n\nfunction fromPercentage(pct: string | undefined): number {\n return pct ? parseFloat(pct) : 100;\n}\n"],"mappings":";;;AACA,SAASA,aAAa,QAAQ,cAAc;AAC5C,OAAOC,WAAW,MAAM,oBAAoB;AAE5C,MAAMC,cAAc,GAAGD,WAAyC;AAChE,MAAME,kBAAkB,GAAGH,aAAa,CAACI,mBAAmB;AAE5D,OAAO,MAAMC,qBAAqB,CAA2B;EAY3DC,WAAWA,CAAkBC,KAAqB,EAAE;IAAA,KAAvBA,KAAqB,GAArBA,KAAqB;IAAAC,eAAA,2BAXHC,SAAS;IAAAD,eAAA,qBACZC,SAAS;IAAAD,eAAA,qBACZC,SAAS;IAAAD,eAAA,sBACRC,SAAS;IAAAD,eAAA,oBACXC,SAAS;IAAAD,eAAA,uBACNC,SAAS;IAAAD,eAAA,wBACRC,SAAS;IAAAD,eAAA,qBACZC,SAAS;IAAAD,eAAA,sBACRC,SAAS;IAAAD,eAAA,uBACRC,SAAS;EAEC;EAErD,IAAIC,eAAeA,CAAA,EAAuB;IACxC,OAAO,IAAI,CAACC,gBAAgB;EAC9B;EAEA,IAAID,eAAeA,CAACE,KAAyB,EAAE;IAC7C,IAAI,CAACD,gBAAgB,GAAGC,KAAK;IAC7BT,kBAAkB,CAACU,iBAAiB,CAAC,IAAI,CAACN,KAAK,CAACO,YAAY,EAAE;MAC5DJ,eAAe,EAAEK,kBAAkB,CAACH,KAAK;IAC3C,CAAC,CAAC;EACJ;EAEA,IAAII,SAASA,CAAA,EAA0B;IACrC,OAAO,IAAI,CAACC,UAAU;EACxB;EAEA,IAAID,SAAS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EAEAA,KAAK,GAAGA,KAAK,CAAC2B,OAAO,CAAC,GAAG,EAAE,EAAE,CAAC;EAE9B,IAAIrC,cAAc,CAACU,KAAK,CAAC4B,WAAW,CAAC,CAAC,CAAC,EAAE;IACvC5B,KAAK,GAAGV,cAAc,CAACU,KAAK,CAAC4B,WAAW,CAAC,CAAC,CAAC;EAC7C;EAEA,MAAMC,YAAY,GAAG,+DAA+D;EACpF,MAAMC,KAAK,GAAG9B,KAAK,CAAC8B,KAAK,CAACD,YAAY,CAAC;EAEvC,IAAI,CAACC,KAAK,EAAE;IACV,OAAO,IAAI;EACb;EAEA,MAAMC,CAAC,GAAGC,QAAQ,CAACF,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC;EAChC,MAAMG,CAAC,GAAGD,QAAQ,CAACF,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC;EAChC,MAAMI,CAAC,GAAGF,QAAQ,CAACF,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC;EAChC,MAAMK,CAAC,GAAGL,KAAK,CAAC,CAAC,CAAC,GAAGE,QAAQ,CAACF,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,GAAG,GAAG;EACjD,OAAO;IAAEC,CAAC;IAAEE,CAAC;IAAEC,CAAC;IAAEC;EAAE,CAAC;AACvB;AAEA,SAASpB,cAAcA,CAACqB,GAAuB,EAAU;EACvD,OAAOA,GAAG,GAAGC,UAAU,CAACD,GAAG,CAAC,GAAG,GAAG;AACpC"}
@@ -9,10 +9,11 @@ import { NativeEventEmitter, NativeModules } from 'react-native';
9
9
  import { NativeCachingTaskAdapter } from './NativeCachingTaskAdapter';
10
10
  import { toNativeCachingTaskParameters } from "./NativeCachingTaskParametersAdapter";
11
11
  const TAG = "NativeMediaCache";
12
+ const NativeCacheModule = NativeModules.THEORCTCacheModule;
12
13
  export class NativeMediaCache extends DefaultEventDispatcher {
13
14
  constructor() {
14
15
  super();
15
- _defineProperty(this, "_emitter", new NativeEventEmitter(NativeModules.CacheModule));
16
+ _defineProperty(this, "_emitter", new NativeEventEmitter(NativeCacheModule));
16
17
  _defineProperty(this, "_status", CacheStatus.uninitialised);
17
18
  _defineProperty(this, "_tasks", []);
18
19
  _defineProperty(this, "onCacheStatusChange", async event => {
@@ -79,7 +80,7 @@ export class NativeMediaCache extends DefaultEventDispatcher {
79
80
  void this.initialize();
80
81
  }
81
82
  async createTask(source, parameters) {
82
- return NativeModules.CacheModule.createTask(source, toNativeCachingTaskParameters(parameters));
83
+ return NativeCacheModule.createTask(source, toNativeCachingTaskParameters(parameters));
83
84
  }
84
85
  get status() {
85
86
  return this._status;
@@ -98,7 +99,7 @@ export class NativeMediaCache extends DefaultEventDispatcher {
98
99
  }
99
100
  }
100
101
  async getInitialState() {
101
- const initialState = await NativeModules.CacheModule.getInitialState();
102
+ const initialState = await NativeCacheModule.getInitialState();
102
103
  this._status = initialState.status;
103
104
  this._tasks = initialState.tasks.map(task => new NativeCachingTaskAdapter(task));
104
105
  }
@@ -1 +1 @@
1
- {"version":3,"names":["CacheStatus","DefaultEventDispatcher","CacheEventType","CachingTaskEventType","NativeEventEmitter","NativeModules","NativeCachingTaskAdapter","toNativeCachingTaskParameters","TAG","NativeMediaCache","constructor","_defineProperty","CacheModule","uninitialised","event","_status","getInitialState","status","dispatchEvent","type","statechange","date","Date","task","_tasks","push","addtask","taskById","id","filter","removetask","console","warn","Object","assign","progress","_emitter","addListener","onCacheStatusChange","onAddCachingTaskEvent","onRemoveCachingTaskEvent","onCachingTaskProgressEvent","onCachingTaskStatusChangeEvent","initialize","createTask","source","parameters","tasks","initialised","initialState","map","find","MediaCache"],"sources":["MediaCache.ts"],"sourcesContent":["import { CacheStatus, MediaCacheAPI } from '../../api/cache/MediaCacheAPI';\nimport type { CachingTaskList } from '../../api/cache/CachingTaskList';\nimport { DefaultEventDispatcher } from '../adapter/event/DefaultEventDispatcher';\nimport type { CacheEventMap } from '../../api/cache/events/CacheEvent';\nimport { CacheEventType } from '../../api/cache/events/CacheEvent';\nimport type { CachingTaskProgressEvent, CachingTaskStatusChangeEvent, SourceDescription } from 'react-native-theoplayer';\nimport { CacheTaskStatus, CachingTaskEventType, TimeRange } from 'react-native-theoplayer';\nimport type { CachingTaskParameters } from '../../api/cache/CachingTaskParameters';\nimport type { CachingTask } from '../../api/cache/CachingTask';\nimport { NativeEventEmitter, NativeModules } from 'react-native';\nimport { NativeCachingTask, NativeCachingTaskAdapter } from './NativeCachingTaskAdapter';\nimport { toNativeCachingTaskParameters } from \"./NativeCachingTaskParametersAdapter\";\n\nconst TAG = \"NativeMediaCache\";\n\ninterface NativeCachingStatusChangeEvent {\n readonly id: string;\n readonly status: CacheTaskStatus;\n}\n\ninterface NativeCacheStatusChangeEvent {\n readonly status: CacheStatus;\n}\n\ninterface NativeAddCachingTaskEvent {\n readonly task: NativeCachingTask;\n}\n\ninterface NativeRemoveCachingTaskEvent {\n readonly task: NativeCachingTask;\n}\n\ninterface NativeCachingTaskProgressEvent {\n id: string;\n progress: {\n readonly duration: number;\n readonly cached: TimeRange[];\n readonly secondsCached: number;\n readonly percentageCached: number;\n readonly bytes: number;\n readonly bytesCached: number;\n };\n}\n\nexport class NativeMediaCache extends DefaultEventDispatcher<CacheEventMap> implements MediaCacheAPI {\n private _emitter: NativeEventEmitter = new NativeEventEmitter(NativeModules.CacheModule);\n private _status: CacheStatus = CacheStatus.uninitialised;\n private _tasks: NativeCachingTaskAdapter[] = [];\n\n constructor() {\n super();\n this._emitter.addListener('onCacheStatusChange', this.onCacheStatusChange);\n this._emitter.addListener('onAddCachingTaskEvent', this.onAddCachingTaskEvent);\n this._emitter.addListener('onRemoveCachingTaskEvent', this.onRemoveCachingTaskEvent);\n this._emitter.addListener('onCachingTaskProgressEvent', this.onCachingTaskProgressEvent);\n this._emitter.addListener('onCachingTaskStatusChangeEvent', this.onCachingTaskStatusChangeEvent);\n void this.initialize();\n }\n\n async createTask(source: SourceDescription, parameters: CachingTaskParameters): Promise<CachingTask> {\n return NativeModules.CacheModule.createTask(source, toNativeCachingTaskParameters(parameters));\n }\n\n get status(): CacheStatus {\n return this._status;\n }\n\n get tasks(): CachingTaskList {\n return this._tasks;\n }\n\n private async initialize(): Promise<void> {\n await this.getInitialState();\n\n // Dispatch status change event here\n if (this._status === CacheStatus.initialised) {\n await this.onCacheStatusChange({\n status: this._status,\n });\n }\n }\n\n private async getInitialState(): Promise<void> {\n const initialState = await NativeModules.CacheModule.getInitialState();\n this._status = initialState.status;\n this._tasks = initialState.tasks.map((task: NativeCachingTask) => new NativeCachingTaskAdapter(task));\n }\n\n private onCacheStatusChange = async (event: NativeCacheStatusChangeEvent) => {\n if (this._status === CacheStatus.uninitialised) {\n await this.getInitialState();\n }\n this._status = event.status;\n this.dispatchEvent({\n type: CacheEventType.statechange,\n date: new Date()\n });\n };\n\n private onAddCachingTaskEvent = (event: NativeAddCachingTaskEvent) => {\n const task= new NativeCachingTaskAdapter(event.task);\n this._tasks.push(task);\n this.dispatchEvent({\n type: CacheEventType.addtask,\n task,\n date: new Date(),\n });\n };\n\n private onRemoveCachingTaskEvent = (event: NativeRemoveCachingTaskEvent) => {\n const task = this.taskById(event.task.id);\n if (task) {\n this._tasks = this._tasks.filter((task) => task.id !== event.task.id);\n this.dispatchEvent({\n type: CacheEventType.removetask,\n task,\n date: new Date(),\n });\n } else {\n console.warn(TAG, `onRemoveCachingTaskEvent: CachingTask with id ${event.task.id} not found.`)\n }\n };\n\n private onCachingTaskProgressEvent = (event: NativeCachingTaskProgressEvent) => {\n const task = this.taskById(event.id);\n if (task) {\n Object.assign(task, { ...event.progress });\n task.dispatchEvent({\n type: CachingTaskEventType.progress,\n date: new Date(),\n } as CachingTaskProgressEvent);\n }\n };\n\n private onCachingTaskStatusChangeEvent = (event: NativeCachingStatusChangeEvent) => {\n const task = this.taskById(event.id);\n if (task) {\n Object.assign(task, { ...event });\n task.dispatchEvent({\n type: CachingTaskEventType.statechange,\n date: new Date(),\n } as CachingTaskStatusChangeEvent);\n }\n };\n\n private taskById(id: string): NativeCachingTaskAdapter | undefined {\n return this._tasks.find((task) => task.id === id);\n }\n}\n\nexport const MediaCache = new NativeMediaCache();\n"],"mappings":";;;AAAA,SAASA,WAAW,QAAuB,+BAA+B;AAE1E,SAASC,sBAAsB,QAAQ,yCAAyC;AAEhF,SAASC,cAAc,QAAQ,mCAAmC;AAElE,SAA0BC,oBAAoB,QAAmB,yBAAyB;AAG1F,SAASC,kBAAkB,EAAEC,aAAa,QAAQ,cAAc;AAChE,SAA4BC,wBAAwB,QAAQ,4BAA4B;AACxF,SAASC,6BAA6B,QAAQ,sCAAsC;AAEpF,MAAMC,GAAG,GAAG,kBAAkB;AA+B9B,OAAO,MAAMC,gBAAgB,SAASR,sBAAsB,CAAyC;EAKnGS,WAAWA,CAAA,EAAG;IACZ,KAAK,CAAC,CAAC;IAACC,eAAA,mBAL6B,IAAIP,kBAAkB,CAACC,aAAa,CAACO,WAAW,CAAC;IAAAD,eAAA,kBACzDX,WAAW,CAACa,aAAa;IAAAF,eAAA,iBACX,EAAE;IAAAA,eAAA,8BAyCjB,MAAOG,KAAmC,IAAK;MAC3E,IAAI,IAAI,CAACC,OAAO,KAAKf,WAAW,CAACa,aAAa,EAAE;QAC9C,MAAM,IAAI,CAACG,eAAe,CAAC,CAAC;MAC9B;MACA,IAAI,CAACD,OAAO,GAAGD,KAAK,CAACG,MAAM;MAC3B,IAAI,CAACC,aAAa,CAAC;QACjBC,IAAI,EAAEjB,cAAc,CAACkB,WAAW;QAChCC,IAAI,EAAE,IAAIC,IAAI,CAAC;MACjB,CAAC,CAAC;IACJ,CAAC;IAAAX,eAAA,gCAEgCG,KAAgC,IAAK;MACpE,MAAMS,IAAI,GAAE,IAAIjB,wBAAwB,CAACQ,KAAK,CAACS,IAAI,CAAC;MACpD,IAAI,CAACC,MAAM,CAACC,IAAI,CAACF,IAAI,CAAC;MACtB,IAAI,CAACL,aAAa,CAAC;QACjBC,IAAI,EAAEjB,cAAc,CAACwB,OAAO;QAC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AG,MAAM5C,aAAa,CAACO,WAAW,CAACI,eAAe,CAAC,CAAC;IACtE,IAAI,CAACD,OAAO,GAAGkC,YAAY,CAAChC,MAAM;IAClC,IAAI,CAACO,MAAM,GAAGyB,YAAY,CAACF,KAAK,CAACG,GAAG,CAAE3B,IAAuB,IAAK,IAAIjB,wBAAwB,CAACiB,IAAI,CAAC,CAAC;EACvG;EA2DQI,QAAQA,CAACC,EAAU,EAAwC;IACjE,OAAO,IAAI,CAACJ,MAAM,CAAC2B,IAAI,CAAE5B,IAAI,IAAKA,IAAI,CAACK,EAAE,KAAKA,EAAE,CAAC;EACnD;AACF;AAEA,OAAO,MAAMwB,UAAU,GAAG,IAAI3C,gBAAgB,CAAC,CAAC"}
1
+ {"version":3,"names":["CacheStatus","DefaultEventDispatcher","CacheEventType","CachingTaskEventType","NativeEventEmitter","NativeModules","NativeCachingTaskAdapter","toNativeCachingTaskParameters","TAG","NativeCacheModule","THEORCTCacheModule","NativeMediaCache","constructor","_defineProperty","uninitialised","event","_status","getInitialState","status","dispatchEvent","type","statechange","date","Date","task","_tasks","push","addtask","taskById","id","filter","removetask","console","warn","Object","assign","progress","_emitter","addListener","onCacheStatusChange","onAddCachingTaskEvent","onRemoveCachingTaskEvent","onCachingTaskProgressEvent","onCachingTaskStatusChangeEvent","initialize","createTask","source","parameters","tasks","initialised","initialState","map","find","MediaCache"],"sources":["MediaCache.ts"],"sourcesContent":["import { CacheStatus, MediaCacheAPI } from '../../api/cache/MediaCacheAPI';\nimport type { CachingTaskList } from '../../api/cache/CachingTaskList';\nimport { DefaultEventDispatcher } from '../adapter/event/DefaultEventDispatcher';\nimport type { CacheEventMap } from '../../api/cache/events/CacheEvent';\nimport { CacheEventType } from '../../api/cache/events/CacheEvent';\nimport type { CachingTaskProgressEvent, CachingTaskStatusChangeEvent, SourceDescription } from 'react-native-theoplayer';\nimport { CacheTaskStatus, CachingTaskEventType, TimeRange } from 'react-native-theoplayer';\nimport type { CachingTaskParameters } from '../../api/cache/CachingTaskParameters';\nimport type { CachingTask } from '../../api/cache/CachingTask';\nimport { NativeEventEmitter, NativeModules } from 'react-native';\nimport { NativeCachingTask, NativeCachingTaskAdapter } from './NativeCachingTaskAdapter';\nimport { toNativeCachingTaskParameters } from \"./NativeCachingTaskParametersAdapter\";\n\nconst TAG = \"NativeMediaCache\";\n\nconst NativeCacheModule = NativeModules.THEORCTCacheModule;\n\ninterface NativeCachingStatusChangeEvent {\n readonly id: string;\n readonly status: CacheTaskStatus;\n}\n\ninterface NativeCacheStatusChangeEvent {\n readonly status: CacheStatus;\n}\n\ninterface NativeAddCachingTaskEvent {\n readonly task: NativeCachingTask;\n}\n\ninterface NativeRemoveCachingTaskEvent {\n readonly task: NativeCachingTask;\n}\n\ninterface NativeCachingTaskProgressEvent {\n id: string;\n progress: {\n readonly duration: number;\n readonly cached: TimeRange[];\n readonly secondsCached: number;\n readonly percentageCached: number;\n readonly bytes: number;\n readonly bytesCached: number;\n };\n}\n\nexport class NativeMediaCache extends DefaultEventDispatcher<CacheEventMap> implements MediaCacheAPI {\n private _emitter: NativeEventEmitter = new NativeEventEmitter(NativeCacheModule);\n private _status: CacheStatus = CacheStatus.uninitialised;\n private _tasks: NativeCachingTaskAdapter[] = [];\n\n constructor() {\n super();\n this._emitter.addListener('onCacheStatusChange', this.onCacheStatusChange);\n this._emitter.addListener('onAddCachingTaskEvent', this.onAddCachingTaskEvent);\n this._emitter.addListener('onRemoveCachingTaskEvent', this.onRemoveCachingTaskEvent);\n this._emitter.addListener('onCachingTaskProgressEvent', this.onCachingTaskProgressEvent);\n this._emitter.addListener('onCachingTaskStatusChangeEvent', this.onCachingTaskStatusChangeEvent);\n void this.initialize();\n }\n\n async createTask(source: SourceDescription, parameters: CachingTaskParameters): Promise<CachingTask> {\n return NativeCacheModule.createTask(source, toNativeCachingTaskParameters(parameters));\n }\n\n get status(): CacheStatus {\n return this._status;\n }\n\n get tasks(): CachingTaskList {\n return this._tasks;\n }\n\n private async initialize(): Promise<void> {\n await this.getInitialState();\n\n // Dispatch status change event here\n if (this._status === CacheStatus.initialised) {\n await this.onCacheStatusChange({\n status: this._status,\n });\n }\n }\n\n private async getInitialState(): Promise<void> {\n const initialState = await NativeCacheModule.getInitialState();\n this._status = initialState.status;\n this._tasks = initialState.tasks.map((task: NativeCachingTask) => new NativeCachingTaskAdapter(task));\n }\n\n private onCacheStatusChange = async (event: NativeCacheStatusChangeEvent) => {\n if (this._status === CacheStatus.uninitialised) {\n await this.getInitialState();\n }\n this._status = event.status;\n this.dispatchEvent({\n type: CacheEventType.statechange,\n date: new Date()\n });\n };\n\n private onAddCachingTaskEvent = (event: NativeAddCachingTaskEvent) => {\n const task= new NativeCachingTaskAdapter(event.task);\n this._tasks.push(task);\n this.dispatchEvent({\n type: CacheEventType.addtask,\n task,\n date: new Date(),\n });\n };\n\n private onRemoveCachingTaskEvent = (event: NativeRemoveCachingTaskEvent) => {\n const task = this.taskById(event.task.id);\n if (task) {\n this._tasks = this._tasks.filter((task) => task.id !== event.task.id);\n this.dispatchEvent({\n type: CacheEventType.removetask,\n task,\n date: new Date(),\n });\n } else {\n console.warn(TAG, `onRemoveCachingTaskEvent: CachingTask with id ${event.task.id} not found.`)\n }\n };\n\n private onCachingTaskProgressEvent = (event: NativeCachingTaskProgressEvent) => {\n const task = this.taskById(event.id);\n if (task) {\n Object.assign(task, { ...event.progress });\n task.dispatchEvent({\n type: CachingTaskEventType.progress,\n date: new Date(),\n } as CachingTaskProgressEvent);\n }\n };\n\n private onCachingTaskStatusChangeEvent = (event: NativeCachingStatusChangeEvent) => {\n const task = this.taskById(event.id);\n if (task) {\n Object.assign(task, { ...event });\n task.dispatchEvent({\n type: CachingTaskEventType.statechange,\n date: new Date(),\n } as CachingTaskStatusChangeEvent);\n }\n };\n\n private taskById(id: string): NativeCachingTaskAdapter | undefined {\n return this._tasks.find((task) => task.id === id);\n }\n}\n\nexport const MediaCache = new NativeMediaCache();\n"],"mappings":";;;AAAA,SAASA,WAAW,QAAuB,+B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,CAACO,MAAM,GAAGyB,YAAY,CAACF,KAAK,CAACG,GAAG,CAAE3B,IAAuB,IAAK,IAAIlB,wBAAwB,CAACkB,IAAI,CAAC,CAAC;EACvG;EA2DQI,QAAQA,CAACC,EAAU,EAAwC;IACjE,OAAO,IAAI,CAACJ,MAAM,CAAC2B,IAAI,CAAE5B,IAAI,IAAKA,IAAI,CAACK,EAAE,KAAKA,EAAE,CAAC;EACnD;AACF;AAEA,OAAO,MAAMwB,UAAU,GAAG,IAAI1C,gBAAgB,CAAC,CAAC"}
@@ -4,6 +4,7 @@ function _toPrimitive(input, hint) { if (typeof input !== "object" || input ===
4
4
  import { DefaultEventDispatcher } from '../adapter/event/DefaultEventDispatcher';
5
5
  import { NativeModules } from 'react-native';
6
6
  import { fromNativeCachingTaskParameters } from "./NativeCachingTaskParametersAdapter";
7
+ const NativeCacheModule = NativeModules.THEORCTCacheModule;
7
8
  export class NativeCachingTaskAdapter extends DefaultEventDispatcher {
8
9
  constructor(task) {
9
10
  super();
@@ -27,7 +28,7 @@ export class NativeCachingTaskAdapter extends DefaultEventDispatcher {
27
28
  this.bytesCached = task.bytesCached;
28
29
  this.license = {
29
30
  renew(drmConfiguration) {
30
- NativeModules.CacheModule.renewLicense(task.id, drmConfiguration);
31
+ NativeCacheModule.renewLicense(task.id, drmConfiguration);
31
32
  }
32
33
  };
33
34
  this.parameters = fromNativeCachingTaskParameters(task.parameters);
@@ -40,13 +41,13 @@ export class NativeCachingTaskAdapter extends DefaultEventDispatcher {
40
41
  this.status = task.status;
41
42
  }
42
43
  pause() {
43
- NativeModules.CacheModule.pauseCachingTask(this.id);
44
+ NativeCacheModule.pauseCachingTask(this.id);
44
45
  }
45
46
  remove() {
46
- NativeModules.CacheModule.removeCachingTask(this.id);
47
+ NativeCacheModule.removeCachingTask(this.id);
47
48
  }
48
49
  start() {
49
- NativeModules.CacheModule.startCachingTask(this.id);
50
+ NativeCacheModule.startCachingTask(this.id);
50
51
  }
51
52
  }
52
53
  //# sourceMappingURL=NativeCachingTaskAdapter.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["DefaultEventDispatcher","NativeModules","fromNativeCachingTaskParameters","NativeCachingTaskAdapter","constructor","task","_defineProperty","bytes","cached","duration","id","bytesCached","license","renew","drmConfiguration","CacheModule","renewLicense","parameters","percentageCached","secondsCached","source","status","pause","pauseCachingTask","remove","removeCachingTask","start","startCachingTask"],"sources":["NativeCachingTaskAdapter.ts"],"sourcesContent":["import { DefaultEventDispatcher } from '../adapter/event/DefaultEventDispatcher';\nimport type {\n CachingTask,\n CachingTaskEventMap,\n CachingTaskLicense,\n CachingTaskParameters,\n SourceDescription,\n TimeRange,\n} from 'react-native-theoplayer';\nimport type { CacheTaskStatus } from 'react-native-theoplayer';\nimport { NativeModules } from 'react-native';\nimport type { DRMConfiguration } from 'react-native-theoplayer';\nimport { fromNativeCachingTaskParameters, NativeCachingTaskParameters } from \"./NativeCachingTaskParametersAdapter\";\n\nexport interface NativeCachingTask {\n readonly id: string;\n\n readonly status: CacheTaskStatus;\n\n readonly source: SourceDescription;\n\n readonly parameters: NativeCachingTaskParameters;\n\n readonly duration: number;\n\n readonly cached: TimeRange[];\n\n readonly secondsCached: number;\n\n readonly percentageCached: number;\n\n readonly bytes: number;\n\n readonly bytesCached: number;\n}\n\nexport class NativeCachingTaskAdapter extends DefaultEventDispatcher<CachingTaskEventMap> implements CachingTask {\n readonly bytes: number;\n readonly bytesCached: number;\n readonly cached: TimeRange[];\n readonly duration: number;\n readonly id: string;\n readonly license: CachingTaskLicense;\n readonly parameters: CachingTaskParameters;\n readonly percentageCached: number;\n readonly secondsCached: number;\n readonly source: SourceDescription;\n readonly status: CacheTaskStatus;\n\n constructor(task: NativeCachingTask) {\n super();\n this.bytes = task.bytes;\n this.cached = { ...task.cached };\n this.duration = task.duration;\n this.id = task.id;\n this.bytesCached = task.bytesCached;\n this.license = {\n renew(drmConfiguration?: DRMConfiguration) {\n NativeModules.CacheModule.renewLicense(task.id, drmConfiguration);\n },\n };\n this.parameters = fromNativeCachingTaskParameters(task.parameters);\n this.percentageCached = task.percentageCached;\n this.secondsCached = task.secondsCached;\n // TODO!\n this.source = { ...task.source };\n this.status = task.status;\n }\n\n pause(): void {\n NativeModules.CacheModule.pauseCachingTask(this.id);\n }\n\n remove(): void {\n NativeModules.CacheModule.removeCachingTask(this.id);\n }\n\n start(): void {\n NativeModules.CacheModule.startCachingTask(this.id);\n }\n}\n"],"mappings":";;;AAAA,SAASA,sBAAsB,QAAQ,yCAAyC;AAUhF,SAASC,aAAa,QAAQ,cAAc;AAE5C,SAASC,+BAA+B,QAAqC,sCAAsC;AAwBnH,OAAO,MAAMC,wBAAwB,SAASH,sBAAsB,CAA6C;EAa/GI,WAAWA,CAACC,IAAuB,EAAE;IACnC,KAAK,CAAC,CAAC;IAACC,eAAA;IAAAA,eAAA;IAAAA,eAAA;IAAAA,eAAA;IAAAA,eAAA;IAAAA,eAAA;IAAAA,eAAA;IAAAA,eAAA;IAAAA,eAAA;IAAAA,eAAA;IAAAA,eAAA;IACR,IAAI,CAACC,KAAK,GAAGF,IAAI,CAACE,KAAK;IACvB,IAAI,CAACC,MAAM,GAAG;MAAE,GAAGH,IAAI,CAACG;IAAO,CAAC;IAChC,IAAI,CAACC,QAAQ,GAAGJ,IAAI,CAACI,QAAQ;IAC7B,IAAI,CAACC,EAAE,GAAGL,IAAI,CAACK,EAAE;IACjB,IAAI,CAACC,WAAW,GAAGN,IAAI,CAACM,WAAW;IACnC,IAAI,CAACC,OAAO,GAAG;MACbC,KAAKA,CAACC,gBAAmC,EAAE;QACzCb,aAAa,CAACc,WAAW,CAACC,YAAY,CAACX,IAAI,CAACK,EAAE,EAAEI,gBAAgB,CAAC;MACnE;IACF,CAAC;IACD,IAAI,CAACG,UAAU,GAAGf,+BAA+B,CAACG,IAAI,CAACY,UAAU,CAAC;IAClE,IAAI,CAACC,gBAAgB,GAAGb,IAAI,CAACa,gBAAgB;IAC7C,IAAI,CAACC,aAAa,GAAGd,IAAI,CAACc,aAAa;IACvC;IACA,IAAI,CAACC,MAAM,GAAG;MAAE,GAAGf,IAAI,CAACe;IAAO,CAAC;IAChC,IAAI,CAACC,MAAM,GAAGhB,IAAI,CAACgB,MAAM;EAC3B;EAEAC,KAAKA,CAAA,EAAS;IACZrB,aAAa,CAACc,WAAW,CAACQ,gBAAgB,CAAC,IAAI,CAACb,EAAE,CAAC;EACrD;EAEAc,MAAMA,CAAA,EAAS;IACbvB,aAAa,CAACc,WAAW,CAACU,iBAAiB,CAAC,IAAI,CAACf,EAAE,CAAC;EACtD;EAEAgB,KAAKA,CAAA,EAAS;IACZzB,aAAa,CAACc,WAAW,CAACY,gBAAgB,CAAC,IAAI,CAACjB,EAAE,CAAC;EACrD;AACF"}
1
+ {"version":3,"names":["DefaultEventDispatcher","NativeModules","fromNativeCachingTaskParameters","NativeCacheModule","THEORCTCacheModule","NativeCachingTaskAdapter","constructor","task","_defineProperty","bytes","cached","duration","id","bytesCached","license","renew","drmConfiguration","renewLicense","parameters","percentageCached","secondsCached","source","status","pause","pauseCachingTask","remove","removeCachingTask","start","startCachingTask"],"sources":["NativeCachingTaskAdapter.ts"],"sourcesContent":["import { DefaultEventDispatcher } from '../adapter/event/DefaultEventDispatcher';\nimport type {\n CachingTask,\n CachingTaskEventMap,\n CachingTaskLicense,\n CachingTaskParameters,\n SourceDescription,\n TimeRange,\n} from 'react-native-theoplayer';\nimport type { CacheTaskStatus } from 'react-native-theoplayer';\nimport { NativeModules } from 'react-native';\nimport type { DRMConfiguration } from 'react-native-theoplayer';\nimport { fromNativeCachingTaskParameters, NativeCachingTaskParameters } from \"./NativeCachingTaskParametersAdapter\";\n\nconst NativeCacheModule = NativeModules.THEORCTCacheModule;\n\nexport interface NativeCachingTask {\n readonly id: string;\n\n readonly status: CacheTaskStatus;\n\n readonly source: SourceDescription;\n\n readonly parameters: NativeCachingTaskParameters;\n\n readonly duration: number;\n\n readonly cached: TimeRange[];\n\n readonly secondsCached: number;\n\n readonly percentageCached: number;\n\n readonly bytes: number;\n\n readonly bytesCached: number;\n}\n\nexport class NativeCachingTaskAdapter extends DefaultEventDispatcher<CachingTaskEventMap> implements CachingTask {\n readonly bytes: number;\n readonly bytesCached: number;\n readonly cached: TimeRange[];\n readonly duration: number;\n readonly id: string;\n readonly license: CachingTaskLicense;\n readonly parameters: CachingTaskParameters;\n readonly percentageCached: number;\n readonly secondsCached: number;\n readonly source: SourceDescription;\n readonly status: CacheTaskStatus;\n\n constructor(task: NativeCachingTask) {\n super();\n this.bytes = task.bytes;\n this.cached = { ...task.cached };\n this.duration = task.duration;\n this.id = task.id;\n this.bytesCached = task.bytesCached;\n this.license = {\n renew(drmConfiguration?: DRMConfiguration) {\n NativeCacheModule.renewLicense(task.id, drmConfiguration);\n },\n };\n this.parameters = fromNativeCachingTaskParameters(task.parameters);\n this.percentageCached = task.percentageCached;\n this.secondsCached = task.secondsCached;\n // TODO!\n this.source = { ...task.source };\n this.status = task.status;\n }\n\n pause(): void {\n NativeCacheModule.pauseCachingTask(this.id);\n }\n\n remove(): void {\n NativeCacheModule.removeCachingTask(this.id);\n }\n\n start(): void {\n NativeCacheModule.startCachingTask(this.id);\n }\n}\n"],"mappings":";;;AAAA,SAASA,sBAAsB,QAAQ,yCAAyC;AAUhF,SAASC,aAAa,QAAQ,cAAc;AAE5C,SAASC,+BAA+B,QAAqC,sCAAsC;AAEnH,MAAMC,iBAAiB,GAAGF,aAAa,CAACG,kBAAkB;AAwB1D,OAAO,MAAMC,wBAAwB,SAASL,sBAAsB,CAA6C;EAa/GM,WAAWA,CAACC,IAAuB,EAAE;IACnC,KAAK,CAAC,CAAC;IAACC,eAAA;IAAAA,eAAA;IAAAA,eAAA;IAAAA,eAAA;IAAAA,eAAA;IAAAA,eAAA;IAAAA,eAAA;IAAAA,eAAA;IAAAA,eAAA;IAAAA,eAAA;IAAAA,eAAA;IACR,IAAI,CAACC,KAAK,GAAGF,IAAI,CAACE,KAAK;IACvB,IAAI,CAACC,MAAM,GAAG;MAAE,GAAGH,IAAI,CAACG;IAAO,CAAC;IAChC,IAAI,CAACC,QAAQ,GAAGJ,IAAI,CAACI,QAAQ;IAC7B,IAAI,CAACC,EAAE,GAAGL,IAAI,CAACK,EAAE;IACjB,IAAI,CAACC,WAAW,GAAGN,IAAI,CAACM,WAAW;IACnC,IAAI,CAACC,OAAO,GAAG;MACbC,KAAKA,CAACC,gBAAmC,EAAE;QACzCb,iBAAiB,CAACc,YAAY,CAACV,IAAI,CAACK,EAAE,EAAEI,gBAAgB,CAAC;MAC3D;IACF,CAAC;IACD,IAAI,CAACE,UAAU,GAAGhB,+BAA+B,CAACK,IAAI,CAACW,UAAU,CAAC;IAClE,IAAI,CAACC,gBAAgB,GAAGZ,IAAI,CAACY,gBAAgB;IAC7C,IAAI,CAACC,aAAa,GAAGb,IAAI,CAACa,aAAa;IACvC;IACA,IAAI,CAACC,MAAM,GAAG;MAAE,GAAGd,IAAI,CAACc;IAAO,CAAC;IAChC,IAAI,CAACC,MAAM,GAAGf,IAAI,CAACe,MAAM;EAC3B;EAEAC,KAAKA,CAAA,EAAS;IACZpB,iBAAiB,CAACqB,gBAAgB,CAAC,IAAI,CAACZ,EAAE,CAAC;EAC7C;EAEAa,MAAMA,CAAA,EAAS;IACbtB,iBAAiB,CAACuB,iBAAiB,CAAC,IAAI,CAACd,EAAE,CAAC;EAC9C;EAEAe,KAAKA,CAAA,EAAS;IACZxB,iBAAiB,CAACyB,gBAAgB,CAAC,IAAI,CAAChB,EAAE,CAAC;EAC7C;AACF"}
@@ -7,6 +7,7 @@ import { fromNativeLicenseResponse, toNativeLicenseResponseResult } from './Nati
7
7
  import { fromNativeCertificateRequest, toNativeCertificateRequest } from './NativeCertificateRequest';
8
8
  import { fromNativeCertificateResponse, toNativeCertificateResponseResult } from './NativeCertificateResponse';
9
9
  import { isBufferSource } from '../utils/TypeUtils';
10
+ const NativeContentProtectionModule = NativeModules.THEORCTContentProtectionModule;
10
11
  export class NativeContentProtectionRegistry {
11
12
  constructor() {
12
13
  _defineProperty(this, "emitter", void 0);
@@ -19,7 +20,7 @@ export class NativeContentProtectionRegistry {
19
20
  keySystemId,
20
21
  drmConfig
21
22
  } = event;
22
- console.log('ContentProtectionModule', `onBuildIntegrationRequest ${integrationId} ${keySystemId}`);
23
+ console.log('NativeContentProtectionModule', `onBuildIntegrationRequest ${integrationId} ${keySystemId}`);
23
24
  const factory = this.getFactory(integrationId, keySystemId);
24
25
  if (factory) {
25
26
  this.currentIntegration = {
@@ -27,12 +28,12 @@ export class NativeContentProtectionRegistry {
27
28
  keySystemId,
28
29
  integration: factory.build(drmConfig)
29
30
  };
30
- NativeModules.ContentProtectionModule.onBuildProcessed({
31
+ NativeContentProtectionModule.onBuildProcessed({
31
32
  requestId,
32
33
  resultString: 'success'
33
34
  });
34
35
  } else {
35
- NativeModules.ContentProtectionModule.onBuildProcessed({
36
+ NativeContentProtectionModule.onBuildProcessed({
36
37
  requestId,
37
38
  resultString: 'failed'
38
39
  });
@@ -44,20 +45,20 @@ export class NativeContentProtectionRegistry {
44
45
  integrationId,
45
46
  keySystemId
46
47
  } = request;
47
- console.log('ContentProtectionModule', `onCertificateRequest ${integrationId} ${keySystemId}`);
48
+ console.log('NativeContentProtectionModule', `onCertificateRequest ${integrationId} ${keySystemId}`);
48
49
  const integration = this.getIntegration(integrationId, keySystemId);
49
50
  if (integration !== null && integration !== void 0 && integration.onCertificateRequest) {
50
51
  const result = await integration.onCertificateRequest(fromNativeCertificateRequest(request));
51
52
  // TODO: we also want to support ArrayBufferView results
52
53
  if (isBufferSource(result)) {
53
54
  const nativeResponse = toNativeCertificateResponseResult(requestId, integrationId, keySystemId, result);
54
- NativeModules.ContentProtectionModule.onCertificateRequestProcessedAsCertificate(nativeResponse);
55
+ NativeContentProtectionModule.onCertificateRequestProcessedAsCertificate(nativeResponse);
55
56
  } else if (result) {
56
57
  const modifiedNativeRequest = toNativeCertificateRequest(requestId, integrationId, keySystemId, result);
57
- NativeModules.ContentProtectionModule.onCertificateRequestProcessedAsRequest(modifiedNativeRequest);
58
+ NativeContentProtectionModule.onCertificateRequestProcessedAsRequest(modifiedNativeRequest);
58
59
  }
59
60
  } else {
60
- NativeModules.ContentProtectionModule.onCertificateRequestProcessedAsRequest(request);
61
+ NativeContentProtectionModule.onCertificateRequestProcessedAsRequest(request);
61
62
  }
62
63
  });
63
64
  _defineProperty(this, "onCertificateResponse", async response => {
@@ -66,15 +67,15 @@ export class NativeContentProtectionRegistry {
66
67
  integrationId,
67
68
  keySystemId
68
69
  } = response;
69
- console.log('ContentProtectionModule', `onCertificateResponse ${integrationId} ${keySystemId}`);
70
+ console.log('NativeContentProtectionModule', `onCertificateResponse ${integrationId} ${keySystemId}`);
70
71
  const integration = this.getIntegration(integrationId, keySystemId);
71
72
  if (integration !== null && integration !== void 0 && integration.onCertificateResponse) {
72
73
  const responseResult = await integration.onCertificateResponse(fromNativeCertificateResponse(response));
73
74
  // TODO: we also want to support ArrayBufferView results
74
75
  const modifiedNativeResponse = toNativeCertificateResponseResult(requestId, integrationId, keySystemId, responseResult);
75
- NativeModules.ContentProtectionModule.onCertificateResponseProcessed(modifiedNativeResponse);
76
+ NativeContentProtectionModule.onCertificateResponseProcessed(modifiedNativeResponse);
76
77
  } else {
77
- NativeModules.ContentProtectionModule.onCertificateResponseProcessed(response);
78
+ NativeContentProtectionModule.onCertificateResponseProcessed(response);
78
79
  }
79
80
  });
80
81
  _defineProperty(this, "onLicenseRequest", async request => {
@@ -83,7 +84,7 @@ export class NativeContentProtectionRegistry {
83
84
  integrationId,
84
85
  keySystemId
85
86
  } = request;
86
- console.log('ContentProtectionModule', `onLicenseRequest ${integrationId} ${keySystemId}`);
87
+ console.log('NativeContentProtectionModule', `onLicenseRequest ${integrationId} ${keySystemId}`);
87
88
  const integration = this.getIntegration(integrationId, keySystemId);
88
89
  // Optionally let the custom integration modify the request.
89
90
  if (integration !== null && integration !== void 0 && integration.onLicenseRequest) {
@@ -91,13 +92,13 @@ export class NativeContentProtectionRegistry {
91
92
  // TODO: we also want to support ArrayBufferView results
92
93
  if (isBufferSource(result)) {
93
94
  const nativeResponse = toNativeLicenseResponseResult(requestId, integrationId, keySystemId, result);
94
- NativeModules.ContentProtectionModule.onLicenseRequestProcessedAsLicense(nativeResponse);
95
+ NativeContentProtectionModule.onLicenseRequestProcessedAsLicense(nativeResponse);
95
96
  } else if (result) {
96
97
  const modifiedNativeRequest = toNativeLicenseRequest(requestId, integrationId, keySystemId, result);
97
- NativeModules.ContentProtectionModule.onLicenseRequestProcessedAsRequest(modifiedNativeRequest);
98
+ NativeContentProtectionModule.onLicenseRequestProcessedAsRequest(modifiedNativeRequest);
98
99
  }
99
100
  } else {
100
- NativeModules.ContentProtectionModule.onLicenseRequestProcessedAsRequest(request);
101
+ NativeContentProtectionModule.onLicenseRequestProcessedAsRequest(request);
101
102
  }
102
103
  });
103
104
  _defineProperty(this, "onLicenseResponse", async response => {
@@ -106,15 +107,15 @@ export class NativeContentProtectionRegistry {
106
107
  integrationId,
107
108
  keySystemId
108
109
  } = response;
109
- console.log('ContentProtectionModule', `onLicenseResponse ${integrationId} ${keySystemId}`);
110
+ console.log('NativeContentProtectionModule', `onLicenseResponse ${integrationId} ${keySystemId}`);
110
111
  const integration = this.getIntegration(integrationId, keySystemId);
111
112
  if (integration !== null && integration !== void 0 && integration.onLicenseResponse) {
112
113
  const responseResult = await integration.onLicenseResponse(fromNativeLicenseResponse(response));
113
114
  // TODO: we also want to support ArrayBufferView results
114
115
  const modifiedNativeResponse = toNativeLicenseResponseResult(requestId, integrationId, keySystemId, responseResult);
115
- NativeModules.ContentProtectionModule.onLicenseResponseProcessed(modifiedNativeResponse);
116
+ NativeContentProtectionModule.onLicenseResponseProcessed(modifiedNativeResponse);
116
117
  } else {
117
- NativeModules.ContentProtectionModule.onLicenseResponseProcessed(response);
118
+ NativeContentProtectionModule.onLicenseResponseProcessed(response);
118
119
  }
119
120
  });
120
121
  _defineProperty(this, "onExtractFairplayContentId", async event => {
@@ -124,23 +125,23 @@ export class NativeContentProtectionRegistry {
124
125
  fairplaySkdUrl,
125
126
  requestId
126
127
  } = event;
127
- console.log('ContentProtectionModule', `onExtractFairplayContentId ${integrationId} ${keySystemId}`);
128
+ console.log('NativeContentProtectionModule', `onExtractFairplayContentId ${integrationId} ${keySystemId}`);
128
129
  const integration = this.getIntegration(integrationId, keySystemId);
129
130
  if (integration !== null && integration !== void 0 && integration.extractFairplayContentId) {
130
131
  const contentId = await integration.extractFairplayContentId(fairplaySkdUrl);
131
- NativeModules.ContentProtectionModule.onExtractFairplayContentIdProcessed({
132
+ NativeContentProtectionModule.onExtractFairplayContentIdProcessed({
132
133
  requestId,
133
134
  contentId
134
135
  });
135
136
  } else {
136
137
  const contentId = fairplaySkdUrl;
137
- NativeModules.ContentProtectionModule.onExtractFairplayContentIdProcessed({
138
+ NativeContentProtectionModule.onExtractFairplayContentIdProcessed({
138
139
  requestId,
139
140
  contentId
140
141
  });
141
142
  }
142
143
  });
143
- this.emitter = new NativeEventEmitter(NativeModules.ContentProtectionModule);
144
+ this.emitter = new NativeEventEmitter(NativeContentProtectionModule);
144
145
  this.emitter.addListener('onBuildIntegration', this.onBuildIntegrationRequest);
145
146
  this.emitter.addListener('onCertificateRequest', this.onCertificateRequest);
146
147
  this.emitter.addListener('onCertificateResponse', this.onCertificateResponse);
@@ -154,7 +155,7 @@ export class NativeContentProtectionRegistry {
154
155
  keySystemId,
155
156
  integrationFactory
156
157
  });
157
- NativeModules.ContentProtectionModule.registerContentProtectionIntegration(integrationId, keySystemId);
158
+ NativeContentProtectionModule.registerContentProtectionIntegration(integrationId, keySystemId);
158
159
  }
159
160
  getFactory(integrationId, keySystemId) {
160
161
  var _this$registeredFacto;
@@ -1 +1 @@
1
- {"version":3,"names":["NativeEventEmitter","NativeModules","fromNativeLicenseRequest","toNativeLicenseRequest","fromNativeLicenseResponse","toNativeLicenseResponseResult","fromNativeCertificateRequest","toNativeCertificateRequest","fromNativeCertificateResponse","toNativeCertificateResponseResult","isBufferSource","NativeContentProtectionRegistry","constructor","_defineProperty","undefined","event","requestId","integrationId","keySystemId","drmConfig","console","log","factory","getFactory","currentIntegration","integration","build","ContentProtectionModule","onBuildProcessed","resultString","request","getIntegration","onCertificateRequest","result","nativeResponse","onCertificateRequestProcessedAsCertificate","modifiedNativeRequest","onCertificateRequestProcessedAsRequest","response","onCertificateResponse","responseResult","modifiedNativeResponse","onCertificateResponseProcessed","onLicenseRequest","onLicenseRequestProcessedAsLicense","onLicenseRequestProcessedAsRequest","onLicenseResponse","onLicenseResponseProcessed","fairplaySkdUrl","extractFairplayContentId","contentId","onExtractFairplayContentIdProcessed","emitter","addListener","onBuildIntegrationRequest","onExtractFairplayContentId","registerContentProtectionIntegration","integrationFactory","registeredFactories","push","_this$registeredFacto","find","init","_this$currentIntegrat","_this$currentIntegrat2","_this$currentIntegrat3","ContentProtectionRegistry"],"sources":["ContentProtectionRegistry.ts"],"sourcesContent":["import type { CertificateRequest, ContentProtectionAPI, DRMConfiguration, LicenseRequest } from 'react-native-theoplayer';\nimport type { KeySystemId } from 'react-native-theoplayer';\nimport type { ContentProtectionIntegrationFactory } from 'react-native-theoplayer';\nimport { NativeEventEmitter, NativeModules } from 'react-native';\nimport type { ContentProtectionIntegration } from 'react-native-theoplayer';\nimport type { NativeContentProtectionEvent } from './NativeContentProtectionEvent';\nimport { fromNativeLicenseRequest, NativeLicenseRequest, toNativeLicenseRequest } from './NativeLicenseRequest';\nimport { fromNativeLicenseResponse, NativeLicenseResponse, toNativeLicenseResponseResult } from './NativeLicenseResponse';\nimport { fromNativeCertificateRequest, NativeCertificateRequest, toNativeCertificateRequest } from './NativeCertificateRequest';\nimport { fromNativeCertificateResponse, NativeCertificateResponse, toNativeCertificateResponseResult } from './NativeCertificateResponse';\nimport { isBufferSource } from '../utils/TypeUtils';\n\ninterface WrappedContentProtectionIntegrationFactory {\n integrationId: string;\n keySystemId: string;\n integrationFactory: ContentProtectionIntegrationFactory;\n}\n\ninterface WrappedContentProtectionIntegration {\n integrationId: string;\n keySystemId: string;\n integration: ContentProtectionIntegration;\n}\n\ninterface BuildEvent extends NativeContentProtectionEvent {\n drmConfig: DRMConfiguration;\n}\n\ninterface ExtractFaiplayContentIdEvent extends NativeContentProtectionEvent {\n fairplaySkdUrl: string;\n}\n\nexport class NativeContentProtectionRegistry implements ContentProtectionAPI {\n private emitter: NativeEventEmitter;\n private registeredFactories: WrappedContentProtectionIntegrationFactory[] = [];\n private currentIntegration: WrappedContentProtectionIntegration | undefined = undefined;\n\n constructor() {\n this.emitter = new NativeEventEmitter(NativeModules.ContentProtectionModule);\n this.emitter.addListener('onBuildIntegration', this.onBuildIntegrationRequest);\n this.emitter.addListener('onCertificateRequest', this.onCertificateRequest);\n this.emitter.addListener('onCertificateResponse', this.onCertificateResponse);\n this.emitter.addListener('onLicenseRequest', this.onLicenseRequest);\n this.emitter.addListener('onLicenseResponse', this.onLicenseResponse);\n this.emitter.addListener('onExtractFairplayContentId', this.onExtractFairplayContentId);\n }\n\n registerContentProtectionIntegration(integrationId: string, keySystemId: KeySystemId, integrationFactory: ContentProtectionIntegrationFactory) {\n this.registeredFactories.push({\n integrationId,\n keySystemId,\n integrationFactory,\n });\n NativeModules.ContentProtectionModule.registerContentProtectionIntegration(integrationId, keySystemId);\n }\n\n private getFactory(integrationId: string, keySystemId: string): ContentProtectionIntegrationFactory | undefined {\n return this.registeredFactories.find((init) => init.integrationId === integrationId && init.keySystemId === keySystemId)?.integrationFactory;\n }\n\n private getIntegration(integrationId: string, keySystemId: string): ContentProtectionIntegration | undefined {\n return this.currentIntegration?.integrationId === integrationId && this.currentIntegration?.keySystemId === keySystemId\n ? this.currentIntegration?.integration\n : undefined;\n }\n\n private onBuildIntegrationRequest = (event: BuildEvent) => {\n const { requestId, integrationId, keySystemId, drmConfig } = event;\n console.log('ContentProtectionModule', `onBuildIntegrationRequest ${integrationId} ${keySystemId}`);\n const factory = this.getFactory(integrationId, keySystemId);\n if (factory) {\n this.currentIntegration = {\n integrationId,\n keySystemId,\n integration: factory.build(drmConfig),\n };\n NativeModules.ContentProtectionModule.onBuildProcessed({ requestId, resultString: 'success' });\n } else {\n NativeModules.ContentProtectionModule.onBuildProcessed({\n requestId,\n resultString: 'failed',\n });\n }\n };\n\n private onCertificateRequest = async (request: NativeCertificateRequest) => {\n const { requestId, integrationId, keySystemId } = request;\n console.log('ContentProtectionModule', `onCertificateRequest ${integrationId} ${keySystemId}`);\n const integration = this.getIntegration(integrationId, keySystemId);\n if (integration?.onCertificateRequest) {\n const result = await integration.onCertificateRequest(fromNativeCertificateRequest(request));\n // TODO: we also want to support ArrayBufferView results\n if (isBufferSource(result)) {\n const nativeResponse = toNativeCertificateResponseResult(requestId, integrationId, keySystemId, result as ArrayBuffer);\n NativeModules.ContentProtectionModule.onCertificateRequestProcessedAsCertificate(nativeResponse);\n } else if (result as CertificateRequest) {\n const modifiedNativeRequest = toNativeCertificateRequest(requestId, integrationId, keySystemId, result as CertificateRequest);\n NativeModules.ContentProtectionModule.onCertificateRequestProcessedAsRequest(modifiedNativeRequest);\n }\n } else {\n NativeModules.ContentProtectionModule.onCertificateRequestProcessedAsRequest(request);\n }\n };\n\n private onCertificateResponse = async (response: NativeCertificateResponse) => {\n const { requestId, integrationId, keySystemId } = response;\n console.log('ContentProtectionModule', `onCertificateResponse ${integrationId} ${keySystemId}`);\n const integration = this.getIntegration(integrationId, keySystemId);\n if (integration?.onCertificateResponse) {\n const responseResult = await integration.onCertificateResponse(fromNativeCertificateResponse(response));\n // TODO: we also want to support ArrayBufferView results\n const modifiedNativeResponse = toNativeCertificateResponseResult(requestId, integrationId, keySystemId, responseResult as ArrayBuffer);\n NativeModules.ContentProtectionModule.onCertificateResponseProcessed(modifiedNativeResponse);\n } else {\n NativeModules.ContentProtectionModule.onCertificateResponseProcessed(response);\n }\n };\n\n private onLicenseRequest = async (request: NativeLicenseRequest) => {\n const { requestId, integrationId, keySystemId } = request;\n console.log('ContentProtectionModule', `onLicenseRequest ${integrationId} ${keySystemId}`);\n const integration = this.getIntegration(integrationId, keySystemId);\n // Optionally let the custom integration modify the request.\n if (integration?.onLicenseRequest) {\n const result = await integration.onLicenseRequest(fromNativeLicenseRequest(request));\n // TODO: we also want to support ArrayBufferView results\n if (isBufferSource(result)) {\n const nativeResponse = toNativeLicenseResponseResult(requestId, integrationId, keySystemId, result as ArrayBuffer);\n NativeModules.ContentProtectionModule.onLicenseRequestProcessedAsLicense(nativeResponse);\n } else if (result as LicenseRequest) {\n const modifiedNativeRequest = toNativeLicenseRequest(requestId, integrationId, keySystemId, result as LicenseRequest);\n NativeModules.ContentProtectionModule.onLicenseRequestProcessedAsRequest(modifiedNativeRequest);\n }\n } else {\n NativeModules.ContentProtectionModule.onLicenseRequestProcessedAsRequest(request);\n }\n };\n\n private onLicenseResponse = async (response: NativeLicenseResponse) => {\n const { requestId, integrationId, keySystemId } = response;\n console.log('ContentProtectionModule', `onLicenseResponse ${integrationId} ${keySystemId}`);\n const integration = this.getIntegration(integrationId, keySystemId);\n if (integration?.onLicenseResponse) {\n const responseResult = await integration.onLicenseResponse(fromNativeLicenseResponse(response));\n // TODO: we also want to support ArrayBufferView results\n const modifiedNativeResponse = toNativeLicenseResponseResult(requestId, integrationId, keySystemId, responseResult as ArrayBuffer);\n NativeModules.ContentProtectionModule.onLicenseResponseProcessed(modifiedNativeResponse);\n } else {\n NativeModules.ContentProtectionModule.onLicenseResponseProcessed(response);\n }\n };\n\n private onExtractFairplayContentId = async (event: ExtractFaiplayContentIdEvent) => {\n const { integrationId, keySystemId, fairplaySkdUrl, requestId } = event;\n console.log('ContentProtectionModule', `onExtractFairplayContentId ${integrationId} ${keySystemId}`);\n const integration = this.getIntegration(integrationId, keySystemId);\n if (integration?.extractFairplayContentId) {\n const contentId = await integration.extractFairplayContentId(fairplaySkdUrl);\n NativeModules.ContentProtectionModule.onExtractFairplayContentIdProcessed({\n requestId,\n contentId,\n });\n } else {\n const contentId = fairplaySkdUrl;\n NativeModules.ContentProtectionModule.onExtractFairplayContentIdProcessed({\n requestId,\n contentId,\n });\n }\n };\n}\n\nexport const ContentProtectionRegistry = new NativeContentProtectionRegistry();\n"],"mappings":";;;AAGA,SAASA,kBAAkB,EAAEC,aAAa,QAAQ,cAAc;AAGhE,SAASC,wBAAwB,EAAwBC,sBAAsB,QAAQ,wBAAwB;AAC/G,SAASC,yBAAyB,EAAyBC,6BAA6B,QAAQ,yBAAyB;AACzH,SAASC,4BAA4B,EAA4BC,0BAA0B,QAAQ,4BAA4B;AAC/H,SAASC,6BAA6B,EAA6BC,iCAAiC,QAAQ,6BAA6B;AACzI,SAASC,cAAc,QAAQ,oBAAoB;AAsBnD,OAAO,MAAMC,+BAA+B,CAAiC;EAK3EC,WAAWA,CAAA,EAAG;IAAAC,eAAA;IAAAA,eAAA,8BAH8D,EAAE;IAAAA,eAAA,6BACAC,SAAS;IAAAD,eAAA,oCA+BlDE,KAAiB,IAAK;MACzD,MAAM;QAAEC,SAAS;QAAEC,aAAa;QAAEC,WAAW;QAAEC;MAAU,CAAC,GAAGJ,KAAK;MAClEK,OAAO,CAACC,GAAG,CAAC,yBAAyB,EAAG,6BAA4BJ,aAAc,IAAGC,WAAY,EAAC,CAAC;MACnG,MAAMI,OAAO,GAAG,IAAI,CAACC,UAAU,CAACN,aAAa,EAAEC,WAAW,CAAC;MAC3D,IAAII,OAAO,EAAE;QACX,IAAI,CAACE,kBAAkB,GAAG;UACxBP,aAAa;UACbC,WAAW;UACXO,WAAW,EAAEH,OAAO,CAACI,KAAK,CAACP,SAAS;QACtC,CAAC;QACDlB,aAAa,CAAC0B,uBAAuB,CAACC,gBAAgB,CAAC;UAAEZ,SAAS;UAAEa,YAAY,EAAE;QAAU,CAAC,CAAC;MAChG,CAAC,MAAM;QACL5B,aAAa,CAAC0B,uBAAuB,CAACC,gBAAgB,CAAC;UACrDZ,SAAS;UACTa,YAAY,EAAE;QAChB,CAAC,CAAC;MACJ;IACF,CAAC;IAAAhB,eAAA,+BAE8B,MAAOiB,OAAiC,IAAK;M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AA;IAC9G,QAAAA,qBAAA,GAAO,IAAI,CAACF,mBAAmB,CAACG,IAAI,CAAEC,IAAI,IAAKA,IAAI,CAAC7C,aAAa,KAAKA,aAAa,IAAI6C,IAAI,CAAC5C,WAAW,KAAKA,WAAW,CAAC,cAAA0C,qBAAA,uBAAjHA,qBAAA,CAAmHH,kBAAkB;EAC9I;EAEQ1B,cAAcA,CAACd,aAAqB,EAAEC,WAAmB,EAA4C;IAAA,IAAA6C,qBAAA,EAAAC,sBAAA,EAAAC,sBAAA;IAC3G,OAAO,EAAAF,qBAAA,OAAI,CAACvC,kBAAkB,cAAAuC,qBAAA,uBAAvBA,qBAAA,CAAyB9C,aAAa,MAAKA,aAAa,IAAI,EAAA+C,sBAAA,OAAI,CAACxC,kBAAkB,cAAAwC,sBAAA,uBAAvBA,sBAAA,CAAyB9C,WAAW,MAAKA,WAAW,IAAA+C,sBAAA,GACnH,IAAI,CAACzC,kBAAkB,cAAAyC,sBAAA,uBAAvBA,sBAAA,CAAyBxC,WAAW,GACpCX,SAAS;EACf;AA0GF;AAEA,OAAO,MAAMoD,yBAAyB,GAAG,IAAIvD,+BAA+B,CAAC,CAAC"}
1
+ {"version":3,"names":["NativeEventEmitter","NativeModules","fromNativeLicenseRequest","toNativeLicenseRequest","fromNativeLicenseResponse","toNativeLicenseResponseResult","fromNativeCertificateRequest","toNativeCertificateRequest","fromNativeCertificateResponse","toNativeCertificateResponseResult","isBufferSource","NativeContentProtectionModule","THEORCTContentProtectionModule","NativeContentProtectionRegistry","constructor","_defineProperty","undefined","event","requestId","integrationId","keySystemId","drmConfig","console","log","factory","getFactory","currentIntegration","integration","build","onBuildProcessed","resultString","request","getIntegration","onCertificateRequest","result","nativeResponse","onCertificateRequestProcessedAsCertificate","modifiedNativeRequest","onCertificateRequestProcessedAsRequest","response","onCertificateResponse","responseResult","modifiedNativeResponse","onCertificateResponseProcessed","onLicenseRequest","onLicenseRequestProcessedAsLicense","onLicenseRequestProcessedAsRequest","onLicenseResponse","onLicenseResponseProcessed","fairplaySkdUrl","extractFairplayContentId","contentId","onExtractFairplayContentIdProcessed","emitter","addListener","onBuildIntegrationRequest","onExtractFairplayContentId","registerContentProtectionIntegration","integrationFactory","registeredFactories","push","_this$registeredFacto","find","init","_this$currentIntegrat","_this$currentIntegrat2","_this$currentIntegrat3","ContentProtectionRegistry"],"sources":["ContentProtectionRegistry.ts"],"sourcesContent":["import type { CertificateRequest, ContentProtectionAPI, DRMConfiguration, LicenseRequest } from 'react-native-theoplayer';\nimport type { KeySystemId } from 'react-native-theoplayer';\nimport type { ContentProtectionIntegrationFactory } from 'react-native-theoplayer';\nimport { NativeEventEmitter, NativeModules } from 'react-native';\nimport type { ContentProtectionIntegration } from 'react-native-theoplayer';\nimport type { NativeContentProtectionEvent } from './NativeContentProtectionEvent';\nimport { fromNativeLicenseRequest, NativeLicenseRequest, toNativeLicenseRequest } from './NativeLicenseRequest';\nimport { fromNativeLicenseResponse, NativeLicenseResponse, toNativeLicenseResponseResult } from './NativeLicenseResponse';\nimport { fromNativeCertificateRequest, NativeCertificateRequest, toNativeCertificateRequest } from './NativeCertificateRequest';\nimport { fromNativeCertificateResponse, NativeCertificateResponse, toNativeCertificateResponseResult } from './NativeCertificateResponse';\nimport { isBufferSource } from '../utils/TypeUtils';\n\nconst NativeContentProtectionModule = NativeModules.THEORCTContentProtectionModule;\n\ninterface WrappedContentProtectionIntegrationFactory {\n integrationId: string;\n keySystemId: string;\n integrationFactory: ContentProtectionIntegrationFactory;\n}\n\ninterface WrappedContentProtectionIntegration {\n integrationId: string;\n keySystemId: string;\n integration: ContentProtectionIntegration;\n}\n\ninterface BuildEvent extends NativeContentProtectionEvent {\n drmConfig: DRMConfiguration;\n}\n\ninterface ExtractFaiplayContentIdEvent extends NativeContentProtectionEvent {\n fairplaySkdUrl: string;\n}\n\nexport class NativeContentProtectionRegistry implements ContentProtectionAPI {\n private emitter: NativeEventEmitter;\n private registeredFactories: WrappedContentProtectionIntegrationFactory[] = [];\n private currentIntegration: WrappedContentProtectionIntegration | undefined = undefined;\n\n constructor() {\n this.emitter = new NativeEventEmitter(NativeContentProtectionModule);\n this.emitter.addListener('onBuildIntegration', this.onBuildIntegrationRequest);\n this.emitter.addListener('onCertificateRequest', this.onCertificateRequest);\n this.emitter.addListener('onCertificateResponse', this.onCertificateResponse);\n this.emitter.addListener('onLicenseRequest', this.onLicenseRequest);\n this.emitter.addListener('onLicenseResponse', this.onLicenseResponse);\n this.emitter.addListener('onExtractFairplayContentId', this.onExtractFairplayContentId);\n }\n\n registerContentProtectionIntegration(integrationId: string, keySystemId: KeySystemId, integrationFactory: ContentProtectionIntegrationFactory) {\n this.registeredFactories.push({\n integrationId,\n keySystemId,\n integrationFactory,\n });\n NativeContentProtectionModule.registerContentProtectionIntegration(integrationId, keySystemId);\n }\n\n private getFactory(integrationId: string, keySystemId: string): ContentProtectionIntegrationFactory | undefined {\n return this.registeredFactories.find((init) => init.integrationId === integrationId && init.keySystemId === keySystemId)?.integrationFactory;\n }\n\n private getIntegration(integrationId: string, keySystemId: string): ContentProtectionIntegration | undefined {\n return this.currentIntegration?.integrationId === integrationId && this.currentIntegration?.keySystemId === keySystemId\n ? this.currentIntegration?.integration\n : undefined;\n }\n\n private onBuildIntegrationRequest = (event: BuildEvent) => {\n const { requestId, integrationId, keySystemId, drmConfig } = event;\n console.log('NativeContentProtectionModule', `onBuildIntegrationRequest ${integrationId} ${keySystemId}`);\n const factory = this.getFactory(integrationId, keySystemId);\n if (factory) {\n this.currentIntegration = {\n integrationId,\n keySystemId,\n integration: factory.build(drmConfig),\n };\n NativeContentProtectionModule.onBuildProcessed({ requestId, resultString: 'success' });\n } else {\n NativeContentProtectionModule.onBuildProcessed({\n requestId,\n resultString: 'failed',\n });\n }\n };\n\n private onCertificateRequest = async (request: NativeCertificateRequest) => {\n const { requestId, integrationId, keySystemId } = request;\n console.log('NativeContentProtectionModule', `onCertificateRequest ${integrationId} ${keySystemId}`);\n const integration = this.getIntegration(integrationId, keySystemId);\n if (integration?.onCertificateRequest) {\n const result = await integration.onCertificateRequest(fromNativeCertificateRequest(request));\n // TODO: we also want to support ArrayBufferView results\n if (isBufferSource(result)) {\n const nativeResponse = toNativeCertificateResponseResult(requestId, integrationId, keySystemId, result as ArrayBuffer);\n NativeContentProtectionModule.onCertificateRequestProcessedAsCertificate(nativeResponse);\n } else if (result as CertificateRequest) {\n const modifiedNativeRequest = toNativeCertificateRequest(requestId, integrationId, keySystemId, result as CertificateRequest);\n NativeContentProtectionModule.onCertificateRequestProcessedAsRequest(modifiedNativeRequest);\n }\n } else {\n NativeContentProtectionModule.onCertificateRequestProcessedAsRequest(request);\n }\n };\n\n private onCertificateResponse = async (response: NativeCertificateResponse) => {\n const { requestId, integrationId, keySystemId } = response;\n console.log('NativeContentProtectionModule', `onCertificateResponse ${integrationId} ${keySystemId}`);\n const integration = this.getIntegration(integrationId, keySystemId);\n if (integration?.onCertificateResponse) {\n const responseResult = await integration.onCertificateResponse(fromNativeCertificateResponse(response));\n // TODO: we also want to support ArrayBufferView results\n const modifiedNativeResponse = toNativeCertificateResponseResult(requestId, integrationId, keySystemId, responseResult as ArrayBuffer);\n NativeContentProtectionModule.onCertificateResponseProcessed(modifiedNativeResponse);\n } else {\n NativeContentProtectionModule.onCertificateResponseProcessed(response);\n }\n };\n\n private onLicenseRequest = async (request: NativeLicenseRequest) => {\n const { requestId, integrationId, keySystemId } = request;\n console.log('NativeContentProtectionModule', `onLicenseRequest ${integrationId} ${keySystemId}`);\n const integration = this.getIntegration(integrationId, keySystemId);\n // Optionally let the custom integration modify the request.\n if (integration?.onLicenseRequest) {\n const result = await integration.onLicenseRequest(fromNativeLicenseRequest(request));\n // TODO: we also want to support ArrayBufferView results\n if (isBufferSource(result)) {\n const nativeResponse = toNativeLicenseResponseResult(requestId, integrationId, keySystemId, result as ArrayBuffer);\n NativeContentProtectionModule.onLicenseRequestProcessedAsLicense(nativeResponse);\n } else if (result as LicenseRequest) {\n const modifiedNativeRequest = toNativeLicenseRequest(requestId, integrationId, keySystemId, result as LicenseRequest);\n NativeContentProtectionModule.onLicenseRequestProcessedAsRequest(modifiedNativeRequest);\n }\n } else {\n NativeContentProtectionModule.onLicenseRequestProcessedAsRequest(request);\n }\n };\n\n private onLicenseResponse = async (response: NativeLicenseResponse) => {\n const { requestId, integrationId, keySystemId } = response;\n console.log('NativeContentProtectionModule', `onLicenseResponse ${integrationId} ${keySystemId}`);\n const integration = this.getIntegration(integrationId, keySystemId);\n if (integration?.onLicenseResponse) {\n const responseResult = await integration.onLicenseResponse(fromNativeLicenseResponse(response));\n // TODO: we also want to support ArrayBufferView results\n const modifiedNativeResponse = toNativeLicenseResponseResult(requestId, integrationId, keySystemId, responseResult as ArrayBuffer);\n NativeContentProtectionModule.onLicenseResponseProcessed(modifiedNativeResponse);\n } else {\n NativeContentProtectionModule.onLicenseResponseProcessed(response);\n }\n };\n\n private onExtractFairplayContentId = async (event: ExtractFaiplayContentIdEvent) => {\n const { integrationId, keySystemId, fairplaySkdUrl, requestId } = event;\n console.log('NativeContentProtectionModule', `onExtractFairplayContentId ${integrationId} ${keySystemId}`);\n const integration = this.getIntegration(integrationId, keySystemId);\n if (integration?.extractFairplayContentId) {\n const contentId = await integration.extractFairplayContentId(fairplaySkdUrl);\n NativeContentProtectionModule.onExtractFairplayContentIdProcessed({\n requestId,\n contentId,\n });\n } else {\n const contentId = fairplaySkdUrl;\n NativeContentProtectionModule.onExtractFairplayContentIdProcessed({\n requestId,\n contentId,\n });\n }\n };\n}\n\nexport const ContentProtectionRegistry = new NativeContentProtectionRegistry();\n"],"mappings":";;;AAGA,SAASA,kBAAkB,EAAEC,aAAa,QAAQ,cAAc;AAGhE,SAASC,wBAAwB,EAAwBC,sBAAsB,QAAQ,wBAAwB;AAC/G,SAASC,yBAAyB,EAAyBC,6BAA6B,QAAQ,yBAAyB;AACzH,SAASC,4BAA4B,EAA4BC,0BAA0B,QAAQ,4BAA4B;AAC/H,SAASC,6BAA6B,EAA6BC,iCAAiC,Q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AAW,MAAKA,WAAW,IAAA8C,sBAAA,GACnH,IAAI,CAACxC,kBAAkB,cAAAwC,sBAAA,uBAAvBA,sBAAA,CAAyBvC,WAAW,GACpCX,SAAS;EACf;AA0GF;AAEA,OAAO,MAAMmD,yBAAyB,GAAG,IAAItD,+BAA+B,CAAC,CAAC"}
@@ -66,6 +66,16 @@ export interface PlayerConfiguration {
66
66
  * <br/> - This parameter only applies to Web and Android platforms.
67
67
  */
68
68
  readonly retryConfiguration?: RetryConfiguration;
69
+ /**
70
+ * The offset in seconds used to determine the live point.
71
+ * This live point is the end of the manifest minus the provided offset.
72
+ *
73
+ * @defaultValue Three times the target duration of a segment, as specified by the manifest.
74
+ *
75
+ * @remarks
76
+ * <br/> - This parameter only applies to Web and Android platforms.
77
+ */
78
+ liveOffset?: number;
69
79
  }
70
80
  /**
71
81
  * The muted autoplay policy of a player for web.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-theoplayer",
3
- "version": "3.7.0",
3
+ "version": "3.8.0",
4
4
  "description": "A THEOplayer video component for react-native.",
5
5
  "main": "lib/commonjs/index",
6
6
  "module": "lib/module/index",
@@ -1,12 +1,17 @@
1
1
  require "json"
2
2
 
3
3
  package = JSON.parse(File.read(File.join(__dir__, "package.json")))
4
- theoconfigpath = File.join(__dir__ + "/../../", "react-native-theoplayer.json")
5
- if File.exist?(theoconfigpath)
6
- theoconfig = JSON.parse(File.read(theoconfigpath))
7
- theofeatures = theoconfig["ios"]["features"]
8
- else
9
- theofeatures = ["NONE"]
4
+
5
+ theofeatures = []
6
+ theoconfigfiles = ["theoplayer-config.json", "react-native-theoplayer.json"]
7
+ theoconfigfiles.each do |configfile|
8
+ configpath = File.join(__dir__ + "/../../", configfile)
9
+ if File.exist?(configpath)
10
+ puts "THEOplayer config found: #{configfile}"
11
+ theoconfig = JSON.parse(File.read(configpath))
12
+ theofeatures = theoconfig["ios"]["features"]
13
+ end
14
+ break if theofeatures.length() > 0
10
15
  end
11
16
 
12
17
  Pod::Spec.new do |s|
@@ -39,11 +44,13 @@ Pod::Spec.new do |s|
39
44
  s.dependency "THEOplayerSDK-core", "~> 6.9"
40
45
  if theofeatures.include?("GOOGLE_IMA")
41
46
  puts "Adding THEOplayer-Integration-GoogleIMA"
42
- s.dependency "THEOplayer-Integration-GoogleIMA", "~> 6.9"
47
+ s.dependency "THEOplayer-Integration-GoogleIMA/Base", "~> 6.9"
48
+ s.dependency "THEOplayer-Integration-GoogleIMA/Dependencies", "~> 6.9"
43
49
  end
44
50
  if theofeatures.include?("CHROMECAST")
45
51
  puts "Adding THEOplayer-Integration-GoogleCast"
46
- s.ios.dependency "THEOplayer-Integration-GoogleCast", "~> 6.9"
52
+ s.ios.dependency "THEOplayer-Integration-GoogleCast/Base", "~> 6.9"
53
+ s.ios.dependency "THEOplayer-Integration-GoogleCast/Dependencies", "~> 6.9"
47
54
  end
48
55
  if theofeatures.include?("SIDELOADED_TEXTTRACKS")
49
56
  puts "Adding THEOplayer-Connector-SideloadedSubtitle"
@@ -77,6 +77,17 @@ export interface PlayerConfiguration {
77
77
  * <br/> - This parameter only applies to Web and Android platforms.
78
78
  */
79
79
  readonly retryConfiguration?: RetryConfiguration;
80
+
81
+ /**
82
+ * The offset in seconds used to determine the live point.
83
+ * This live point is the end of the manifest minus the provided offset.
84
+ *
85
+ * @defaultValue Three times the target duration of a segment, as specified by the manifest.
86
+ *
87
+ * @remarks
88
+ * <br/> - This parameter only applies to Web and Android platforms.
89
+ */
90
+ liveOffset?: number;
80
91
  }
81
92
 
82
93
  /**