react-native-theoplayer 1.6.1 → 1.7.1

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 (465) hide show
  1. package/README.md +4 -0
  2. package/android/build.gradle +76 -33
  3. package/android/local/com/theoplayer/theoplayer-sdk-android/ads-wrapper/4.3.0/ads-wrapper-4.3.0.aar +0 -0
  4. package/android/local/com/theoplayer/theoplayer-sdk-android/ads-wrapper/4.3.0/ads-wrapper-4.3.0.pom +9 -0
  5. package/android/local/com/theoplayer/theoplayer-sdk-android/ads-wrapper/maven-metadata-local.xml +13 -0
  6. package/android/src/main/java/com/theoplayer/PlayerConfigHelper.java +40 -0
  7. package/android/src/main/java/com/theoplayer/ReactTHEOplayerPackage.java +8 -3
  8. package/android/src/main/java/com/theoplayer/ReactTHEOplayerView.java +131 -28
  9. package/android/src/main/java/com/theoplayer/ReactTHEOplayerViewManager.java +14 -1
  10. package/android/src/main/java/com/theoplayer/SourceHelper.java +137 -86
  11. package/android/src/main/java/com/theoplayer/VideoEventEmitter.java +44 -12
  12. package/android/src/main/java/com/theoplayer/abr/ABRConfigurationAdapter.kt +72 -0
  13. package/android/src/main/java/com/theoplayer/ads/AdEventAdapter.java +92 -0
  14. package/android/src/main/java/com/theoplayer/ads/AdInfo.java +168 -0
  15. package/android/src/main/java/com/theoplayer/ads/AdsModule.java +152 -0
  16. package/android/src/main/java/com/theoplayer/drm/ContentProtectionAdapter.kt +143 -0
  17. package/android/src/main/java/com/theoplayer/drm/ContentProtectionModule.kt +273 -0
  18. package/android/src/main/java/com/theoplayer/drm/KeySystemAdapter.kt +22 -0
  19. package/android/src/main/java/com/theoplayer/drm/ProxyContentProtectionIntegration.kt +33 -0
  20. package/android/src/main/java/com/theoplayer/drm/ProxyContentProtectionIntegrationFactory.kt +19 -0
  21. package/android/src/main/java/com/theoplayer/drm/RequestMethodAdapter.kt +28 -0
  22. package/android/src/main/java/com/theoplayer/track/QualityListAdapter.java +54 -0
  23. package/android/src/main/java/com/theoplayer/track/QualityListFilter.java +40 -0
  24. package/android/src/main/java/com/theoplayer/track/TrackListInfo.java +10 -2
  25. package/android/src/main/java/com/theoplayer/util/TypeUtils.kt +17 -0
  26. package/android/src/main/java/com/theoplayer/util/ViewResolver.java +42 -0
  27. package/ios/THEOplayerRCTAdAggregator.swift +158 -0
  28. package/ios/THEOplayerRCTAdsAPI.swift +296 -0
  29. package/ios/THEOplayerRCTBridge.m +65 -0
  30. package/ios/THEOplayerRCTContentProtectionAPI.swift +359 -0
  31. package/ios/THEOplayerRCTContentProtectionAggregator.swift +119 -0
  32. package/ios/THEOplayerRCTDebug.swift +11 -5
  33. package/ios/THEOplayerRCTMetadataAggregator.swift +1 -1
  34. package/ios/THEOplayerRCTNetworkUtils.swift +54 -0
  35. package/ios/THEOplayerRCTProxyContentProtectionIntegration.swift +155 -0
  36. package/ios/THEOplayerRCTProxyContentProtectionIntegrationFactory.swift +32 -0
  37. package/ios/THEOplayerRCTSourceDescriptionBuilder.swift +223 -30
  38. package/ios/THEOplayerRCTTypeUtils.swift +18 -0
  39. package/ios/THEOplayerRCTView.swift +109 -49
  40. package/ios/THEOplayerRCTViewAdEventHandler.swift +238 -0
  41. package/ios/{THEOplayerRCTViewEventHandler.swift → THEOplayerRCTViewMainEventHandler.swift} +7 -119
  42. package/ios/THEOplayerRCTViewTextTrackEventHandler.swift +134 -0
  43. package/ios/Theoplayer-Bridging-Header.h +3 -1
  44. package/ios/custom/Frameworks/ios/put_custom_ios_xcframework_here.txt +2 -0
  45. package/ios/custom/react-native-theoplayer_custom_ios.podspec +36 -0
  46. package/ios/custom/theofeatures.sh +14 -0
  47. package/lib/commonjs/api/THEOplayerView.js.map +1 -1
  48. package/lib/commonjs/api/abr/ABRConfiguration.js +2 -0
  49. package/lib/commonjs/api/abr/ABRConfiguration.js.map +1 -0
  50. package/lib/commonjs/api/abr/barrel.js +19 -0
  51. package/lib/commonjs/api/abr/barrel.js.map +1 -0
  52. package/lib/commonjs/api/ads/Ad.js +6 -0
  53. package/lib/commonjs/api/ads/Ad.js.map +1 -0
  54. package/lib/commonjs/api/ads/AdBreak.js +6 -0
  55. package/lib/commonjs/api/ads/AdBreak.js.map +1 -0
  56. package/lib/commonjs/api/ads/AdsAPI.js +6 -0
  57. package/lib/commonjs/api/ads/AdsAPI.js.map +1 -0
  58. package/lib/commonjs/api/ads/AdsConfiguration.js +6 -0
  59. package/lib/commonjs/api/ads/AdsConfiguration.js.map +1 -0
  60. package/lib/commonjs/api/ads/CompanionAd.js +2 -0
  61. package/lib/commonjs/api/ads/CompanionAd.js.map +1 -0
  62. package/lib/commonjs/api/ads/GoogleDai.js +2 -0
  63. package/lib/commonjs/api/ads/GoogleDai.js.map +1 -0
  64. package/lib/commonjs/api/ads/GoogleImaAd.js +6 -0
  65. package/lib/commonjs/api/ads/GoogleImaAd.js.map +1 -0
  66. package/lib/commonjs/api/ads/GoogleImaConfiguration.js +2 -0
  67. package/lib/commonjs/api/ads/GoogleImaConfiguration.js.map +1 -0
  68. package/lib/commonjs/api/ads/barrel.js +110 -0
  69. package/lib/commonjs/api/ads/barrel.js.map +1 -0
  70. package/lib/commonjs/api/barrel.js +58 -6
  71. package/lib/commonjs/api/barrel.js.map +1 -1
  72. package/lib/commonjs/api/config/PlayerConfiguration.js +4 -0
  73. package/lib/commonjs/api/config/PlayerConfiguration.js.map +1 -1
  74. package/lib/commonjs/api/drm/ContentProtectionAPI.js +6 -0
  75. package/lib/commonjs/api/drm/ContentProtectionAPI.js.map +1 -0
  76. package/lib/commonjs/api/drm/ContentProtectionIntegration.js +6 -0
  77. package/lib/commonjs/api/drm/ContentProtectionIntegration.js.map +1 -0
  78. package/lib/commonjs/api/drm/ContentProtectionIntegrationFactory.js +6 -0
  79. package/lib/commonjs/api/drm/ContentProtectionIntegrationFactory.js.map +1 -0
  80. package/lib/commonjs/api/drm/ContentProtectionRequest.js +2 -0
  81. package/lib/commonjs/api/drm/ContentProtectionRequest.js.map +1 -0
  82. package/lib/commonjs/api/drm/ContentProtectionResponse.js +6 -0
  83. package/lib/commonjs/api/drm/ContentProtectionResponse.js.map +1 -0
  84. package/lib/commonjs/api/drm/barrel.js +71 -0
  85. package/lib/commonjs/api/drm/barrel.js.map +1 -0
  86. package/lib/commonjs/api/event/AdEvent.js +89 -0
  87. package/lib/commonjs/api/event/AdEvent.js.map +1 -0
  88. package/lib/commonjs/api/event/barrel.js +13 -0
  89. package/lib/commonjs/api/event/barrel.js.map +1 -1
  90. package/lib/commonjs/api/source/SourceDescription.js.map +1 -1
  91. package/lib/commonjs/api/source/ads/FreeWheelAdDescription.js +6 -0
  92. package/lib/commonjs/api/source/ads/FreeWheelAdDescription.js.map +1 -0
  93. package/lib/commonjs/api/source/ads/IMAAdDescription.js +6 -0
  94. package/lib/commonjs/api/source/ads/IMAAdDescription.js.map +1 -0
  95. package/lib/commonjs/api/source/ads/SpotXAdDescription.js +6 -0
  96. package/lib/commonjs/api/source/ads/SpotXAdDescription.js.map +1 -0
  97. package/lib/commonjs/api/source/ads/THEOplayerAdDescription.js +6 -0
  98. package/lib/commonjs/api/source/ads/THEOplayerAdDescription.js.map +1 -0
  99. package/lib/commonjs/api/source/ads/barrel.js +84 -0
  100. package/lib/commonjs/api/source/ads/barrel.js.map +1 -0
  101. package/lib/commonjs/api/source/ads/ssai/GoogleDAIConfiguration.js +6 -0
  102. package/lib/commonjs/api/source/ads/ssai/GoogleDAIConfiguration.js.map +1 -0
  103. package/lib/commonjs/api/source/ads/ssai/ImagineServerSideAdInsertionConfiguration.js +6 -0
  104. package/lib/commonjs/api/source/ads/ssai/ImagineServerSideAdInsertionConfiguration.js.map +1 -0
  105. package/lib/commonjs/api/source/ads/ssai/ServerSideAdInsertionConfiguration.js +6 -0
  106. package/lib/commonjs/api/source/ads/ssai/ServerSideAdInsertionConfiguration.js.map +1 -0
  107. package/lib/commonjs/api/source/ads/ssai/YospaceServerSideAdInsertionConfiguration.js +6 -0
  108. package/lib/commonjs/api/source/ads/ssai/YospaceServerSideAdInsertionConfiguration.js.map +1 -0
  109. package/lib/commonjs/api/source/ads/ssai/barrel.js +58 -0
  110. package/lib/commonjs/api/source/ads/ssai/barrel.js.map +1 -0
  111. package/lib/commonjs/api/source/barrel.js +16 -3
  112. package/lib/commonjs/api/source/barrel.js.map +1 -1
  113. package/lib/commonjs/api/source/drm/DRMConfiguration.js.map +1 -1
  114. package/lib/commonjs/api/track/MediaTrack.js +29 -0
  115. package/lib/commonjs/api/track/MediaTrack.js.map +1 -1
  116. package/lib/commonjs/api/utils/TypeUtils.js +62 -0
  117. package/lib/commonjs/api/utils/TypeUtils.js.map +1 -0
  118. package/lib/commonjs/api/utils/barrel.js +19 -0
  119. package/lib/commonjs/api/utils/barrel.js.map +1 -0
  120. package/lib/commonjs/index.js +10 -1
  121. package/lib/commonjs/index.js.map +1 -1
  122. package/lib/commonjs/internal/THEOplayerView.js +42 -3
  123. package/lib/commonjs/internal/THEOplayerView.js.map +1 -1
  124. package/lib/commonjs/internal/THEOplayerView.web.js +41 -2
  125. package/lib/commonjs/internal/THEOplayerView.web.js.map +1 -1
  126. package/lib/commonjs/internal/ads/THEOplayerNativeAdsAPI.js +54 -0
  127. package/lib/commonjs/internal/ads/THEOplayerNativeAdsAPI.js.map +1 -0
  128. package/lib/commonjs/internal/ads/THEOplayerNativeGoogleDAI.js +34 -0
  129. package/lib/commonjs/internal/ads/THEOplayerNativeGoogleDAI.js.map +1 -0
  130. package/lib/commonjs/internal/ads/THEOplayerWebAdsAPI.js +78 -0
  131. package/lib/commonjs/internal/ads/THEOplayerWebAdsAPI.js.map +1 -0
  132. package/lib/commonjs/internal/ads/THEOplayerWebGoogleDAI.js +32 -0
  133. package/lib/commonjs/internal/ads/THEOplayerWebGoogleDAI.js.map +1 -0
  134. package/lib/commonjs/internal/drm/ContentProtectionRegistry.js +214 -0
  135. package/lib/commonjs/internal/drm/ContentProtectionRegistry.js.map +1 -0
  136. package/lib/commonjs/internal/drm/ContentProtectionRegistry.web.js +20 -0
  137. package/lib/commonjs/internal/drm/ContentProtectionRegistry.web.js.map +1 -0
  138. package/lib/commonjs/internal/drm/NativeCertificateRequest.js +41 -0
  139. package/lib/commonjs/internal/drm/NativeCertificateRequest.js.map +1 -0
  140. package/lib/commonjs/internal/drm/NativeCertificateResponse.js +41 -0
  141. package/lib/commonjs/internal/drm/NativeCertificateResponse.js.map +1 -0
  142. package/lib/commonjs/internal/drm/NativeContentProtectionEvent.js +2 -0
  143. package/lib/commonjs/internal/drm/NativeContentProtectionEvent.js.map +1 -0
  144. package/lib/commonjs/internal/drm/NativeLicenseRequest.js +44 -0
  145. package/lib/commonjs/internal/drm/NativeLicenseRequest.js.map +1 -0
  146. package/lib/commonjs/internal/drm/NativeLicenseResponse.js +41 -0
  147. package/lib/commonjs/internal/drm/NativeLicenseResponse.js.map +1 -0
  148. package/lib/commonjs/internal/utils/TypeUtils.js +41 -0
  149. package/lib/commonjs/internal/utils/TypeUtils.js.map +1 -0
  150. package/lib/commonjs/internal/web/TrackUtils.js +19 -0
  151. package/lib/commonjs/internal/web/TrackUtils.js.map +1 -1
  152. package/lib/module/api/THEOplayerView.js.map +1 -1
  153. package/lib/module/api/abr/ABRConfiguration.js +2 -0
  154. package/lib/module/api/abr/ABRConfiguration.js.map +1 -0
  155. package/lib/module/api/abr/barrel.js +2 -0
  156. package/lib/module/api/abr/barrel.js.map +1 -0
  157. package/lib/module/api/ads/Ad.js +2 -0
  158. package/lib/module/api/ads/Ad.js.map +1 -0
  159. package/lib/module/api/ads/AdBreak.js +2 -0
  160. package/lib/module/api/ads/AdBreak.js.map +1 -0
  161. package/lib/module/api/ads/AdsAPI.js +2 -0
  162. package/lib/module/api/ads/AdsAPI.js.map +1 -0
  163. package/lib/module/api/ads/AdsConfiguration.js +2 -0
  164. package/lib/module/api/ads/AdsConfiguration.js.map +1 -0
  165. package/lib/module/api/ads/CompanionAd.js +2 -0
  166. package/lib/module/api/ads/CompanionAd.js.map +1 -0
  167. package/lib/module/api/ads/GoogleDai.js +2 -0
  168. package/lib/module/api/ads/GoogleDai.js.map +1 -0
  169. package/lib/module/api/ads/GoogleImaAd.js +2 -0
  170. package/lib/module/api/ads/GoogleImaAd.js.map +1 -0
  171. package/lib/module/api/ads/GoogleImaConfiguration.js +2 -0
  172. package/lib/module/api/ads/GoogleImaConfiguration.js.map +1 -0
  173. package/lib/module/api/ads/barrel.js +9 -0
  174. package/lib/module/api/ads/barrel.js.map +1 -0
  175. package/lib/module/api/barrel.js +5 -1
  176. package/lib/module/api/barrel.js.map +1 -1
  177. package/lib/module/api/config/PlayerConfiguration.js +1 -1
  178. package/lib/module/api/config/PlayerConfiguration.js.map +1 -1
  179. package/lib/module/api/drm/ContentProtectionAPI.js +2 -0
  180. package/lib/module/api/drm/ContentProtectionAPI.js.map +1 -0
  181. package/lib/module/api/drm/ContentProtectionIntegration.js +2 -0
  182. package/lib/module/api/drm/ContentProtectionIntegration.js.map +1 -0
  183. package/lib/module/api/drm/ContentProtectionIntegrationFactory.js +2 -0
  184. package/lib/module/api/drm/ContentProtectionIntegrationFactory.js.map +1 -0
  185. package/lib/module/api/drm/ContentProtectionRequest.js +2 -0
  186. package/lib/module/api/drm/ContentProtectionRequest.js.map +1 -0
  187. package/lib/module/api/drm/ContentProtectionResponse.js +2 -0
  188. package/lib/module/api/drm/ContentProtectionResponse.js.map +1 -0
  189. package/lib/module/api/drm/barrel.js +6 -0
  190. package/lib/module/api/drm/barrel.js.map +1 -0
  191. package/lib/module/api/event/AdEvent.js +82 -0
  192. package/lib/module/api/event/AdEvent.js.map +1 -0
  193. package/lib/module/api/event/barrel.js +1 -0
  194. package/lib/module/api/event/barrel.js.map +1 -1
  195. package/lib/module/api/source/SourceDescription.js.map +1 -1
  196. package/lib/module/api/source/ads/FreeWheelAdDescription.js +2 -0
  197. package/lib/module/api/source/ads/FreeWheelAdDescription.js.map +1 -0
  198. package/lib/module/api/source/ads/IMAAdDescription.js +2 -0
  199. package/lib/module/api/source/ads/IMAAdDescription.js.map +1 -0
  200. package/lib/module/api/source/ads/SpotXAdDescription.js +2 -0
  201. package/lib/module/api/source/ads/SpotXAdDescription.js.map +1 -0
  202. package/lib/module/api/source/ads/THEOplayerAdDescription.js +2 -0
  203. package/lib/module/api/source/ads/THEOplayerAdDescription.js.map +1 -0
  204. package/lib/module/api/source/ads/barrel.js +7 -0
  205. package/lib/module/api/source/ads/barrel.js.map +1 -0
  206. package/lib/module/api/source/ads/ssai/GoogleDAIConfiguration.js +2 -0
  207. package/lib/module/api/source/ads/ssai/GoogleDAIConfiguration.js.map +1 -0
  208. package/lib/module/api/source/ads/ssai/ImagineServerSideAdInsertionConfiguration.js +2 -0
  209. package/lib/module/api/source/ads/ssai/ImagineServerSideAdInsertionConfiguration.js.map +1 -0
  210. package/lib/module/api/source/ads/ssai/ServerSideAdInsertionConfiguration.js +2 -0
  211. package/lib/module/api/source/ads/ssai/ServerSideAdInsertionConfiguration.js.map +1 -0
  212. package/lib/module/api/source/ads/ssai/YospaceServerSideAdInsertionConfiguration.js +2 -0
  213. package/lib/module/api/source/ads/ssai/YospaceServerSideAdInsertionConfiguration.js.map +1 -0
  214. package/lib/module/api/source/ads/ssai/barrel.js +5 -0
  215. package/lib/module/api/source/ads/ssai/barrel.js.map +1 -0
  216. package/lib/module/api/source/barrel.js +1 -0
  217. package/lib/module/api/source/barrel.js.map +1 -1
  218. package/lib/module/api/source/drm/DRMConfiguration.js.map +1 -1
  219. package/lib/module/api/track/MediaTrack.js +23 -1
  220. package/lib/module/api/track/MediaTrack.js.map +1 -1
  221. package/lib/module/api/utils/TypeUtils.js +36 -0
  222. package/lib/module/api/utils/TypeUtils.js.map +1 -0
  223. package/lib/module/api/utils/barrel.js +2 -0
  224. package/lib/module/api/utils/barrel.js.map +1 -0
  225. package/lib/module/index.js +1 -0
  226. package/lib/module/index.js.map +1 -1
  227. package/lib/module/internal/THEOplayerView.js +40 -3
  228. package/lib/module/internal/THEOplayerView.js.map +1 -1
  229. package/lib/module/internal/THEOplayerView.web.js +42 -4
  230. package/lib/module/internal/THEOplayerView.web.js.map +1 -1
  231. package/lib/module/internal/ads/THEOplayerNativeAdsAPI.js +43 -0
  232. package/lib/module/internal/ads/THEOplayerNativeAdsAPI.js.map +1 -0
  233. package/lib/module/internal/ads/THEOplayerNativeGoogleDAI.js +24 -0
  234. package/lib/module/internal/ads/THEOplayerNativeGoogleDAI.js.map +1 -0
  235. package/lib/module/internal/ads/THEOplayerWebAdsAPI.js +68 -0
  236. package/lib/module/internal/ads/THEOplayerWebAdsAPI.js.map +1 -0
  237. package/lib/module/internal/ads/THEOplayerWebGoogleDAI.js +23 -0
  238. package/lib/module/internal/ads/THEOplayerWebGoogleDAI.js.map +1 -0
  239. package/lib/module/internal/drm/ContentProtectionRegistry.js +188 -0
  240. package/lib/module/internal/drm/ContentProtectionRegistry.js.map +1 -0
  241. package/lib/module/internal/drm/ContentProtectionRegistry.web.js +9 -0
  242. package/lib/module/internal/drm/ContentProtectionRegistry.web.js.map +1 -0
  243. package/lib/module/internal/drm/NativeCertificateRequest.js +31 -0
  244. package/lib/module/internal/drm/NativeCertificateRequest.js.map +1 -0
  245. package/lib/module/internal/drm/NativeCertificateResponse.js +30 -0
  246. package/lib/module/internal/drm/NativeCertificateResponse.js.map +1 -0
  247. package/lib/module/internal/drm/NativeContentProtectionEvent.js +2 -0
  248. package/lib/module/internal/drm/NativeContentProtectionEvent.js.map +1 -0
  249. package/lib/module/internal/drm/NativeLicenseRequest.js +34 -0
  250. package/lib/module/internal/drm/NativeLicenseRequest.js.map +1 -0
  251. package/lib/module/internal/drm/NativeLicenseResponse.js +30 -0
  252. package/lib/module/internal/drm/NativeLicenseResponse.js.map +1 -0
  253. package/lib/module/internal/utils/TypeUtils.js +24 -0
  254. package/lib/module/internal/utils/TypeUtils.js.map +1 -0
  255. package/lib/module/internal/web/TrackUtils.js +15 -0
  256. package/lib/module/internal/web/TrackUtils.js.map +1 -1
  257. package/lib/typescript/lib/commonjs/api/abr/ABRConfiguration.d.ts +0 -0
  258. package/lib/typescript/lib/commonjs/api/abr/barrel.d.ts +1 -0
  259. package/lib/typescript/lib/commonjs/api/ads/Ad.d.ts +1 -0
  260. package/lib/typescript/lib/commonjs/api/ads/AdBreak.d.ts +1 -0
  261. package/lib/typescript/lib/commonjs/api/ads/AdsAPI.d.ts +1 -0
  262. package/lib/typescript/lib/commonjs/api/ads/AdsConfiguration.d.ts +1 -0
  263. package/lib/typescript/lib/commonjs/api/ads/CompanionAd.d.ts +0 -0
  264. package/lib/typescript/lib/commonjs/api/ads/GoogleDai.d.ts +0 -0
  265. package/lib/typescript/lib/commonjs/api/ads/GoogleImaAd.d.ts +1 -0
  266. package/lib/typescript/lib/commonjs/api/ads/GoogleImaConfiguration.d.ts +0 -0
  267. package/lib/typescript/lib/commonjs/api/ads/barrel.d.ts +1 -0
  268. package/lib/typescript/lib/commonjs/api/config/PlayerConfiguration.d.ts +1 -0
  269. package/lib/typescript/lib/commonjs/api/drm/ContentProtectionAPI.d.ts +1 -0
  270. package/lib/typescript/lib/commonjs/api/drm/ContentProtectionIntegration.d.ts +1 -0
  271. package/lib/typescript/lib/commonjs/api/drm/ContentProtectionIntegrationFactory.d.ts +1 -0
  272. package/lib/typescript/lib/commonjs/api/drm/ContentProtectionRequest.d.ts +0 -0
  273. package/lib/typescript/lib/commonjs/api/drm/ContentProtectionResponse.d.ts +1 -0
  274. package/lib/typescript/lib/commonjs/api/drm/barrel.d.ts +1 -0
  275. package/lib/typescript/lib/commonjs/api/event/AdEvent.d.ts +2 -0
  276. package/lib/typescript/lib/commonjs/api/source/ads/FreeWheelAdDescription.d.ts +1 -0
  277. package/lib/typescript/lib/commonjs/api/source/ads/IMAAdDescription.d.ts +1 -0
  278. package/lib/typescript/lib/commonjs/api/source/ads/SpotXAdDescription.d.ts +1 -0
  279. package/lib/typescript/lib/commonjs/api/source/ads/THEOplayerAdDescription.d.ts +1 -0
  280. package/lib/typescript/lib/commonjs/api/source/ads/barrel.d.ts +1 -0
  281. package/lib/typescript/lib/commonjs/api/source/ads/ssai/GoogleDAIConfiguration.d.ts +1 -0
  282. package/lib/typescript/lib/commonjs/api/source/ads/ssai/ImagineServerSideAdInsertionConfiguration.d.ts +1 -0
  283. package/lib/typescript/lib/commonjs/api/source/ads/ssai/ServerSideAdInsertionConfiguration.d.ts +1 -0
  284. package/lib/typescript/lib/commonjs/api/source/ads/ssai/YospaceServerSideAdInsertionConfiguration.d.ts +1 -0
  285. package/lib/typescript/lib/commonjs/api/source/ads/ssai/barrel.d.ts +1 -0
  286. package/lib/typescript/lib/commonjs/api/track/MediaTrack.d.ts +8 -0
  287. package/lib/typescript/lib/commonjs/api/utils/TypeUtils.d.ts +13 -0
  288. package/lib/typescript/lib/commonjs/api/utils/barrel.d.ts +1 -0
  289. package/lib/typescript/lib/commonjs/index.d.ts +2 -0
  290. package/lib/typescript/lib/commonjs/internal/THEOplayerView.d.ts +5 -0
  291. package/lib/typescript/lib/commonjs/internal/THEOplayerView.web.d.ts +4 -0
  292. package/lib/typescript/lib/commonjs/internal/ads/THEOplayerNativeAdsAPI.d.ts +14 -0
  293. package/lib/typescript/lib/commonjs/internal/ads/THEOplayerNativeGoogleDAI.d.ts +9 -0
  294. package/lib/typescript/lib/commonjs/internal/ads/THEOplayerWebAdsAPI.d.ts +14 -0
  295. package/lib/typescript/lib/commonjs/internal/ads/THEOplayerWebGoogleDAI.d.ts +9 -0
  296. package/lib/typescript/lib/commonjs/internal/drm/ContentProtectionRegistry.d.ts +14 -0
  297. package/lib/typescript/lib/commonjs/internal/drm/ContentProtectionRegistry.web.d.ts +5 -0
  298. package/lib/typescript/lib/commonjs/internal/drm/NativeCertificateRequest.d.ts +18 -0
  299. package/lib/typescript/lib/commonjs/internal/drm/NativeCertificateResponse.d.ts +21 -0
  300. package/lib/typescript/lib/commonjs/internal/drm/NativeContentProtectionEvent.d.ts +0 -0
  301. package/lib/typescript/lib/commonjs/internal/drm/NativeLicenseRequest.d.ts +20 -0
  302. package/lib/typescript/lib/commonjs/internal/drm/NativeLicenseResponse.d.ts +22 -0
  303. package/lib/typescript/lib/commonjs/internal/utils/TypeUtils.d.ts +6 -0
  304. package/lib/typescript/lib/commonjs/internal/web/TrackUtils.d.ts +2 -0
  305. package/lib/typescript/lib/module/api/abr/ABRConfiguration.d.ts +0 -0
  306. package/lib/typescript/lib/module/api/abr/barrel.d.ts +1 -0
  307. package/lib/typescript/lib/module/api/ads/Ad.d.ts +1 -0
  308. package/lib/typescript/lib/module/api/ads/AdBreak.d.ts +1 -0
  309. package/lib/typescript/lib/module/api/ads/AdsAPI.d.ts +1 -0
  310. package/lib/typescript/lib/module/api/ads/AdsConfiguration.d.ts +1 -0
  311. package/lib/typescript/lib/module/api/ads/CompanionAd.d.ts +0 -0
  312. package/lib/typescript/lib/module/api/ads/GoogleDai.d.ts +0 -0
  313. package/lib/typescript/lib/module/api/ads/GoogleImaAd.d.ts +1 -0
  314. package/lib/typescript/lib/module/api/ads/GoogleImaConfiguration.d.ts +0 -0
  315. package/lib/typescript/lib/module/api/ads/barrel.d.ts +5 -0
  316. package/lib/typescript/lib/module/api/barrel.d.ts +5 -1
  317. package/lib/typescript/lib/module/api/config/PlayerConfiguration.d.ts +1 -0
  318. package/lib/typescript/lib/module/api/config/barrel.d.ts +1 -1
  319. package/lib/typescript/lib/module/api/drm/ContentProtectionAPI.d.ts +1 -0
  320. package/lib/typescript/lib/module/api/drm/ContentProtectionIntegration.d.ts +1 -0
  321. package/lib/typescript/lib/module/api/drm/ContentProtectionIntegrationFactory.d.ts +1 -0
  322. package/lib/typescript/lib/module/api/drm/ContentProtectionRequest.d.ts +0 -0
  323. package/lib/typescript/lib/module/api/drm/ContentProtectionResponse.d.ts +1 -0
  324. package/lib/typescript/lib/module/api/drm/barrel.d.ts +4 -0
  325. package/lib/typescript/lib/module/api/event/AdEvent.d.ts +1 -0
  326. package/lib/typescript/lib/module/api/event/barrel.d.ts +1 -0
  327. package/lib/typescript/lib/module/api/source/ads/FreeWheelAdDescription.d.ts +1 -0
  328. package/lib/typescript/lib/module/api/source/ads/IMAAdDescription.d.ts +1 -0
  329. package/lib/typescript/lib/module/api/source/ads/SpotXAdDescription.d.ts +1 -0
  330. package/lib/typescript/lib/module/api/source/ads/THEOplayerAdDescription.d.ts +1 -0
  331. package/lib/typescript/lib/module/api/source/ads/barrel.d.ts +5 -0
  332. package/lib/typescript/lib/module/api/source/ads/ssai/GoogleDAIConfiguration.d.ts +1 -0
  333. package/lib/typescript/lib/module/api/source/ads/ssai/ImagineServerSideAdInsertionConfiguration.d.ts +1 -0
  334. package/lib/typescript/lib/module/api/source/ads/ssai/ServerSideAdInsertionConfiguration.d.ts +1 -0
  335. package/lib/typescript/lib/module/api/source/ads/ssai/YospaceServerSideAdInsertionConfiguration.d.ts +1 -0
  336. package/lib/typescript/lib/module/api/source/ads/ssai/barrel.d.ts +4 -0
  337. package/lib/typescript/lib/module/api/source/barrel.d.ts +1 -0
  338. package/lib/typescript/lib/module/api/track/MediaTrack.d.ts +8 -1
  339. package/lib/typescript/lib/module/api/utils/TypeUtils.d.ts +12 -0
  340. package/lib/typescript/lib/module/api/utils/barrel.d.ts +1 -0
  341. package/lib/typescript/lib/module/index.d.ts +1 -0
  342. package/lib/typescript/lib/module/internal/THEOplayerView.d.ts +8 -0
  343. package/lib/typescript/lib/module/internal/THEOplayerView.web.d.ts +4 -0
  344. package/lib/typescript/lib/module/internal/ads/THEOplayerNativeAdsAPI.d.ts +13 -0
  345. package/lib/typescript/lib/module/internal/ads/THEOplayerNativeGoogleDAI.d.ts +8 -0
  346. package/lib/typescript/lib/module/internal/ads/THEOplayerWebAdsAPI.d.ts +13 -0
  347. package/lib/typescript/lib/module/internal/ads/THEOplayerWebGoogleDAI.d.ts +8 -0
  348. package/lib/typescript/lib/module/internal/drm/ContentProtectionRegistry.d.ts +13 -0
  349. package/lib/typescript/lib/module/internal/drm/ContentProtectionRegistry.web.d.ts +4 -0
  350. package/lib/typescript/lib/module/internal/drm/NativeCertificateRequest.d.ts +17 -0
  351. package/lib/typescript/lib/module/internal/drm/NativeCertificateResponse.d.ts +20 -0
  352. package/lib/typescript/lib/module/internal/drm/NativeContentProtectionEvent.d.ts +0 -0
  353. package/lib/typescript/lib/module/internal/drm/NativeLicenseRequest.d.ts +19 -0
  354. package/lib/typescript/lib/module/internal/drm/NativeLicenseResponse.d.ts +21 -0
  355. package/lib/typescript/lib/module/internal/utils/TypeUtils.d.ts +5 -0
  356. package/lib/typescript/lib/module/internal/web/TrackUtils.d.ts +2 -0
  357. package/lib/typescript/src/api/THEOplayerView.d.ts +25 -4
  358. package/lib/typescript/src/api/abr/ABRConfiguration.d.ts +95 -0
  359. package/lib/typescript/src/api/abr/barrel.d.ts +1 -0
  360. package/lib/typescript/src/api/ads/Ad.d.ts +238 -0
  361. package/lib/typescript/src/api/ads/AdBreak.d.ts +39 -0
  362. package/lib/typescript/src/api/ads/AdsAPI.d.ts +46 -0
  363. package/lib/typescript/src/api/ads/AdsConfiguration.d.ts +69 -0
  364. package/lib/typescript/src/api/ads/CompanionAd.d.ts +59 -0
  365. package/lib/typescript/src/api/ads/GoogleDai.d.ts +29 -0
  366. package/lib/typescript/src/api/ads/GoogleImaAd.d.ts +78 -0
  367. package/lib/typescript/src/api/ads/GoogleImaConfiguration.d.ts +13 -0
  368. package/lib/typescript/src/api/ads/barrel.d.ts +8 -0
  369. package/lib/typescript/src/api/barrel.d.ts +5 -1
  370. package/lib/typescript/src/api/config/PlayerConfiguration.d.ts +5 -0
  371. package/lib/typescript/src/api/drm/ContentProtectionAPI.d.ts +5 -0
  372. package/lib/typescript/src/api/drm/ContentProtectionIntegration.d.ts +86 -0
  373. package/lib/typescript/src/api/drm/ContentProtectionIntegrationFactory.d.ts +15 -0
  374. package/lib/typescript/src/api/drm/ContentProtectionRequest.d.ts +56 -0
  375. package/lib/typescript/src/api/drm/ContentProtectionResponse.d.ts +56 -0
  376. package/lib/typescript/src/api/drm/barrel.d.ts +5 -0
  377. package/lib/typescript/src/api/event/AdEvent.d.ts +13 -0
  378. package/lib/typescript/src/api/event/barrel.d.ts +1 -0
  379. package/lib/typescript/src/api/source/SourceDescription.d.ts +8 -0
  380. package/lib/typescript/src/api/source/ads/FreeWheelAdDescription.d.ts +85 -0
  381. package/lib/typescript/src/api/source/ads/IMAAdDescription.d.ts +25 -0
  382. package/lib/typescript/src/api/source/ads/SpotXAdDescription.d.ts +115 -0
  383. package/lib/typescript/src/api/source/ads/THEOplayerAdDescription.d.ts +32 -0
  384. package/lib/typescript/src/api/source/ads/barrel.d.ts +6 -0
  385. package/lib/typescript/src/api/source/ads/ssai/GoogleDAIConfiguration.d.ts +130 -0
  386. package/lib/typescript/src/api/source/ads/ssai/ImagineServerSideAdInsertionConfiguration.d.ts +27 -0
  387. package/lib/typescript/src/api/source/ads/ssai/ServerSideAdInsertionConfiguration.d.ts +26 -0
  388. package/lib/typescript/src/api/source/ads/ssai/YospaceServerSideAdInsertionConfiguration.d.ts +46 -0
  389. package/lib/typescript/src/api/source/ads/ssai/barrel.d.ts +4 -0
  390. package/lib/typescript/src/api/source/barrel.d.ts +1 -0
  391. package/lib/typescript/src/api/source/drm/DRMConfiguration.d.ts +0 -30
  392. package/lib/typescript/src/api/track/MediaTrack.d.ts +5 -2
  393. package/lib/typescript/src/api/utils/TypeUtils.d.ts +20 -0
  394. package/lib/typescript/src/api/utils/barrel.d.ts +1 -0
  395. package/lib/typescript/src/index.d.ts +1 -0
  396. package/lib/typescript/src/internal/THEOplayerView.d.ts +10 -4
  397. package/lib/typescript/src/internal/THEOplayerView.web.d.ts +7 -2
  398. package/lib/typescript/src/internal/ads/THEOplayerNativeAdsAPI.d.ts +17 -0
  399. package/lib/typescript/src/internal/ads/THEOplayerNativeGoogleDAI.d.ts +10 -0
  400. package/lib/typescript/src/internal/ads/THEOplayerWebAdsAPI.d.ts +15 -0
  401. package/lib/typescript/src/internal/ads/THEOplayerWebGoogleDAI.d.ts +10 -0
  402. package/lib/typescript/src/internal/drm/ContentProtectionRegistry.d.ts +19 -0
  403. package/lib/typescript/src/internal/drm/ContentProtectionRegistry.web.d.ts +5 -0
  404. package/lib/typescript/src/internal/drm/NativeCertificateRequest.d.ts +13 -0
  405. package/lib/typescript/src/internal/drm/NativeCertificateResponse.d.ts +18 -0
  406. package/lib/typescript/src/internal/drm/NativeContentProtectionEvent.d.ts +5 -0
  407. package/lib/typescript/src/internal/drm/NativeLicenseRequest.d.ts +14 -0
  408. package/lib/typescript/src/internal/drm/NativeLicenseResponse.d.ts +18 -0
  409. package/lib/typescript/src/internal/utils/TypeUtils.d.ts +5 -0
  410. package/lib/typescript/src/internal/web/TrackUtils.d.ts +3 -1
  411. package/package.json +4 -3
  412. package/src/api/THEOplayerView.ts +29 -4
  413. package/src/api/abr/ABRConfiguration.ts +103 -0
  414. package/src/api/abr/barrel.ts +1 -0
  415. package/src/api/ads/Ad.ts +267 -0
  416. package/src/api/ads/AdBreak.ts +44 -0
  417. package/src/api/ads/AdsAPI.ts +53 -0
  418. package/src/api/ads/AdsConfiguration.ts +76 -0
  419. package/src/api/ads/CompanionAd.ts +65 -0
  420. package/src/api/ads/GoogleDai.ts +32 -0
  421. package/src/api/ads/GoogleImaAd.ts +86 -0
  422. package/src/api/ads/GoogleImaConfiguration.ts +13 -0
  423. package/src/api/ads/barrel.ts +8 -0
  424. package/src/api/barrel.ts +5 -1
  425. package/src/api/config/PlayerConfiguration.ts +7 -0
  426. package/src/api/drm/ContentProtectionAPI.ts +6 -0
  427. package/src/api/drm/ContentProtectionIntegration.ts +93 -0
  428. package/src/api/drm/ContentProtectionIntegrationFactory.ts +16 -0
  429. package/src/api/drm/ContentProtectionRequest.ts +60 -0
  430. package/src/api/drm/ContentProtectionResponse.ts +62 -0
  431. package/src/api/drm/barrel.ts +5 -0
  432. package/src/api/event/AdEvent.ts +117 -0
  433. package/src/api/event/barrel.ts +1 -0
  434. package/src/api/source/SourceDescription.ts +9 -0
  435. package/src/api/source/ads/FreeWheelAdDescription.ts +97 -0
  436. package/src/api/source/ads/IMAAdDescription.ts +26 -0
  437. package/src/api/source/ads/SpotXAdDescription.ts +126 -0
  438. package/src/api/source/ads/THEOplayerAdDescription.ts +34 -0
  439. package/src/api/source/ads/barrel.ts +6 -0
  440. package/src/api/source/ads/ssai/GoogleDAIConfiguration.ts +145 -0
  441. package/src/api/source/ads/ssai/ImagineServerSideAdInsertionConfiguration.ts +30 -0
  442. package/src/api/source/ads/ssai/ServerSideAdInsertionConfiguration.ts +28 -0
  443. package/src/api/source/ads/ssai/YospaceServerSideAdInsertionConfiguration.ts +51 -0
  444. package/src/api/source/ads/ssai/barrel.ts +4 -0
  445. package/src/api/source/barrel.ts +1 -0
  446. package/src/api/source/drm/DRMConfiguration.ts +0 -35
  447. package/src/api/track/MediaTrack.ts +22 -2
  448. package/src/api/utils/TypeUtils.ts +39 -0
  449. package/src/api/utils/barrel.ts +1 -0
  450. package/src/index.tsx +1 -0
  451. package/src/internal/THEOplayerView.tsx +49 -8
  452. package/src/internal/THEOplayerView.web.tsx +37 -7
  453. package/src/internal/ads/THEOplayerNativeAdsAPI.ts +44 -0
  454. package/src/internal/ads/THEOplayerNativeGoogleDAI.ts +23 -0
  455. package/src/internal/ads/THEOplayerWebAdsAPI.ts +51 -0
  456. package/src/internal/ads/THEOplayerWebGoogleDAI.ts +22 -0
  457. package/src/internal/drm/ContentProtectionRegistry.ts +173 -0
  458. package/src/internal/drm/ContentProtectionRegistry.web.ts +10 -0
  459. package/src/internal/drm/NativeCertificateRequest.ts +41 -0
  460. package/src/internal/drm/NativeCertificateResponse.ts +45 -0
  461. package/src/internal/drm/NativeContentProtectionEvent.ts +5 -0
  462. package/src/internal/drm/NativeLicenseRequest.ts +39 -0
  463. package/src/internal/drm/NativeLicenseResponse.ts +45 -0
  464. package/src/internal/utils/TypeUtils.ts +39 -0
  465. package/src/internal/web/TrackUtils.ts +22 -1
@@ -0,0 +1,39 @@
1
+ import { Buffer } from 'buffer';
2
+
3
+ // from object
4
+ export function fromObjectToString(obj: { [key: string]: any }): string {
5
+ return JSON.stringify(obj);
6
+ }
7
+ export function fromObjectToBase64String(obj: { [key: string]: any }): string {
8
+ return fromStringToBase64String(fromObjectToString(obj));
9
+ }
10
+ export function fromObjectToUint8Array(obj: { [key: string]: any }): Uint8Array {
11
+ return fromStringToUint8Array(fromObjectToString(obj));
12
+ }
13
+
14
+ // from string
15
+ export function fromStringToBase64String(str: string): string {
16
+ return Buffer.from(str, 'utf8').toString('base64');
17
+ }
18
+ export function fromStringToUint8Array(str: string): Uint8Array {
19
+ return Buffer.from(str, 'utf8');
20
+ }
21
+ export function fromStringToObject(str: string): { [key: string]: any } {
22
+ return JSON.parse(str);
23
+ }
24
+
25
+ // from base64 string
26
+ export function fromBase64StringToUint8Array(str: string): Uint8Array {
27
+ return Buffer.from(str, 'base64');
28
+ }
29
+
30
+ // from uint8Array
31
+ export function fromUint8ArrayToBase64String(array: Uint8Array): string {
32
+ return Buffer.from(array).toString('base64');
33
+ }
34
+ export function fromUint8ArrayToString(array: Uint8Array): string {
35
+ return Buffer.from(array).toString('utf8');
36
+ }
37
+ export function fromUint8ArrayToObject(array: Uint8Array): { [key: string]: any } {
38
+ return fromStringToObject(fromUint8ArrayToString(array));
39
+ }
@@ -0,0 +1 @@
1
+ export * from './TypeUtils';
package/src/index.tsx CHANGED
@@ -1,2 +1,3 @@
1
1
  export * from './api/barrel';
2
2
  export { THEOplayerView } from './internal/THEOplayerView';
3
+ export { ContentProtectionRegistry } from './internal/drm/ContentProtectionRegistry';
@@ -1,5 +1,5 @@
1
1
  import React, { PureComponent } from 'react';
2
- import { findNodeHandle, StyleSheet, requireNativeComponent, View, UIManager, Platform, NativeSyntheticEvent } from 'react-native';
2
+ import { findNodeHandle, StyleSheet, requireNativeComponent, View, UIManager, Platform, NativeSyntheticEvent, HostComponent } from 'react-native';
3
3
  import type {
4
4
  DurationChangeEvent,
5
5
  ErrorEvent,
@@ -13,10 +13,14 @@ import type {
13
13
  SegmentNotFoundEvent,
14
14
  TextTrackListEvent,
15
15
  TextTrackEvent,
16
+ AdEvent,
17
+ AdsAPI,
16
18
  } from 'react-native-theoplayer';
17
19
 
18
20
  import styles from './THEOplayerView.style';
19
21
  import type { SourceDescription } from 'react-native-theoplayer';
22
+ import { THEOplayerNativeAdsAPI } from './ads/THEOplayerNativeAdsAPI';
23
+ import { decodeNanInf } from './utils/TypeUtils';
20
24
 
21
25
  interface THEOplayerRCTViewProps extends THEOplayerViewProps {
22
26
  ref: React.RefObject<THEOplayerViewNativeComponent>;
@@ -41,6 +45,7 @@ interface THEOplayerRCTViewProps extends THEOplayerViewProps {
41
45
  onNativeSegmentNotFound: (event: NativeSyntheticEvent<SegmentNotFoundEvent>) => void;
42
46
  onNativeTextTrackListEvent: (event: NativeSyntheticEvent<TextTrackListEvent>) => void;
43
47
  onNativeTextTrackEvent: (event: NativeSyntheticEvent<TextTrackEvent>) => void;
48
+ onNativeAdEvent: (event: NativeSyntheticEvent<AdEvent>) => void;
44
49
  onNativeFullscreenPlayerWillPresent?: () => void;
45
50
  onNativeFullscreenPlayerDidPresent?: () => void;
46
51
  onNativeFullscreenPlayerWillDismiss?: () => void;
@@ -52,12 +57,13 @@ interface THEOplayerRCTViewState {
52
57
  error?: PlayerError;
53
58
  }
54
59
 
55
- interface THEOplayerViewNativeComponent extends THEOplayerViewComponent {
60
+ interface THEOplayerViewNativeComponent extends THEOplayerViewComponent, HostComponent<THEOplayerViewProps> {
56
61
  setNativeProps: (props: Partial<THEOplayerRCTViewProps>) => void;
57
62
  }
58
63
 
59
- export class THEOplayerView extends PureComponent<THEOplayerViewProps, THEOplayerRCTViewState> {
64
+ export class THEOplayerView extends PureComponent<THEOplayerViewProps, THEOplayerRCTViewState> implements THEOplayerViewComponent {
60
65
  private readonly _root: React.RefObject<THEOplayerViewNativeComponent>;
66
+ private readonly _adsApi: THEOplayerNativeAdsAPI;
61
67
 
62
68
  private static initialState: THEOplayerRCTViewState = {
63
69
  isBuffering: false,
@@ -68,6 +74,7 @@ export class THEOplayerView extends PureComponent<THEOplayerViewProps, THEOplaye
68
74
  super(props);
69
75
  this._root = React.createRef();
70
76
  this.state = THEOplayerView.initialState;
77
+ this._adsApi = new THEOplayerNativeAdsAPI(this);
71
78
  }
72
79
 
73
80
  componentWillUnmount() {
@@ -79,7 +86,7 @@ export class THEOplayerView extends PureComponent<THEOplayerViewProps, THEOplaye
79
86
 
80
87
  private destroyTheoPlayer() {
81
88
  const node = findNodeHandle(this._root.current);
82
- const command = (UIManager as {[index: string]: any})['THEOplayerRCTView'].Commands.destroy;
89
+ const command = (UIManager as { [index: string]: any })['THEOplayerRCTView'].Commands.destroy;
83
90
  const params: any[] = [];
84
91
  UIManager.dispatchViewManagerCommand(node, command, params);
85
92
  }
@@ -91,6 +98,14 @@ export class THEOplayerView extends PureComponent<THEOplayerViewProps, THEOplaye
91
98
  this.setNativeProps({ seek: time });
92
99
  }
93
100
 
101
+ public get nativeHandle(): number | null {
102
+ return findNodeHandle(this._root.current);
103
+ }
104
+
105
+ public get ads(): AdsAPI {
106
+ return this._adsApi;
107
+ }
108
+
94
109
  private reset() {
95
110
  this.setState(THEOplayerView.initialState);
96
111
  }
@@ -140,7 +155,10 @@ export class THEOplayerView extends PureComponent<THEOplayerViewProps, THEOplaye
140
155
 
141
156
  private _onLoadedMetadata = (event: NativeSyntheticEvent<LoadedMetadataEvent>) => {
142
157
  if (this.props.onLoadedMetadata) {
143
- this.props.onLoadedMetadata(event.nativeEvent);
158
+ this.props.onLoadedMetadata({
159
+ ...event.nativeEvent,
160
+ duration: decodeNanInf(event.nativeEvent.duration),
161
+ });
144
162
  }
145
163
  };
146
164
 
@@ -169,6 +187,9 @@ export class THEOplayerView extends PureComponent<THEOplayerViewProps, THEOplaye
169
187
  };
170
188
 
171
189
  private _onPlaying = () => {
190
+ // potentially notify change in buffering state
191
+ this.maybeChangeBufferingState(false);
192
+
172
193
  if (this.props.onPlaying) {
173
194
  this.props.onPlaying();
174
195
  }
@@ -215,7 +236,9 @@ export class THEOplayerView extends PureComponent<THEOplayerViewProps, THEOplaye
215
236
 
216
237
  private _onDurationChange = (event: NativeSyntheticEvent<DurationChangeEvent>) => {
217
238
  if (this.props.onDurationChange) {
218
- this.props.onDurationChange(event.nativeEvent);
239
+ this.props.onDurationChange({
240
+ duration: decodeNanInf(event.nativeEvent.duration),
241
+ });
219
242
  }
220
243
  };
221
244
 
@@ -237,6 +260,12 @@ export class THEOplayerView extends PureComponent<THEOplayerViewProps, THEOplaye
237
260
  }
238
261
  };
239
262
 
263
+ private _onAdEvent = (event: NativeSyntheticEvent<AdEvent>) => {
264
+ if (this.props.onAdEvent) {
265
+ this.props.onAdEvent(event.nativeEvent);
266
+ }
267
+ };
268
+
240
269
  private _onFullscreenPlayerWillPresent = () => {
241
270
  if (this.props.onFullscreenPlayerWillPresent) {
242
271
  this.props.onFullscreenPlayerWillPresent();
@@ -261,9 +290,20 @@ export class THEOplayerView extends PureComponent<THEOplayerViewProps, THEOplaye
261
290
  }
262
291
  };
263
292
 
264
- public render(): JSX.Element {
265
- const wrapperProps = Object.assign({}, this.props);
293
+ private buildWrapperProps(): THEOplayerViewProps {
294
+ const { targetVideoQuality } = this.props;
295
+ return Object.assign(
296
+ {},
297
+ {
298
+ ...this.props,
299
+ // Always pass an array for targetVideoQuality.
300
+ targetVideoQuality: !targetVideoQuality ? [] : Array.isArray(targetVideoQuality) ? targetVideoQuality : [targetVideoQuality],
301
+ },
302
+ );
303
+ }
266
304
 
305
+ public render(): JSX.Element {
306
+ const wrapperProps = this.buildWrapperProps();
267
307
  return (
268
308
  <View style={[styles.base, wrapperProps.style]}>
269
309
  <THEOplayerRCTView
@@ -287,6 +327,7 @@ export class THEOplayerView extends PureComponent<THEOplayerViewProps, THEOplaye
287
327
  onNativeSegmentNotFound={this._onSegmentNotFound}
288
328
  onNativeTextTrackListEvent={this._onTextTrackListEvent}
289
329
  onNativeTextTrackEvent={this._onTextTrackEvent}
330
+ onNativeAdEvent={this._onAdEvent}
290
331
  onNativeFullscreenPlayerWillPresent={this._onFullscreenPlayerWillPresent}
291
332
  onNativeFullscreenPlayerDidPresent={this._onFullscreenPlayerDidPresent}
292
333
  onNativeFullscreenPlayerWillDismiss={this._onFullscreenPlayerWillDismiss}
@@ -1,7 +1,7 @@
1
1
  import React, { PureComponent } from 'react';
2
2
 
3
- import type { PlayerError, TextTrack, THEOplayerViewProps, TimeRange } from 'react-native-theoplayer';
4
- import { TextTrackEventType, TrackListEventType } from 'react-native-theoplayer';
3
+ import type { AdEvent, AdsAPI, PlayerError, TextTrack, THEOplayerViewProps, TimeRange } from 'react-native-theoplayer';
4
+ import { AdEventNames, TextTrackEventType, THEOplayerViewComponent, TrackListEventType } from 'react-native-theoplayer';
5
5
  import type { Event, TextTrackCue as NativeTextTrackCue } from 'theoplayer';
6
6
 
7
7
  import type {
@@ -13,15 +13,17 @@ import type {
13
13
  TextTrack as NativeTextTrack,
14
14
  } from 'theoplayer';
15
15
  import * as THEOplayer from 'theoplayer';
16
- import { fromNativeCue, fromNativeMediaTrack, fromNativeTextTrack } from './web/TrackUtils';
16
+ import { findNativeQualitiesByUid, fromNativeCue, fromNativeMediaTrack, fromNativeTextTrack } from './web/TrackUtils';
17
+ import { THEOplayerWebAdsAPI } from './ads/THEOplayerWebAdsAPI';
17
18
 
18
19
  interface THEOplayerRCTViewState {
19
20
  isBuffering: boolean;
20
21
  error?: PlayerError;
21
22
  }
22
23
 
23
- export class THEOplayerView extends PureComponent<THEOplayerViewProps, THEOplayerRCTViewState> {
24
+ export class THEOplayerView extends PureComponent<THEOplayerViewProps, THEOplayerRCTViewState> implements THEOplayerViewComponent {
24
25
  private _player: THEOplayer.ChromelessPlayer | null = null;
26
+ private _adsApi: THEOplayerWebAdsAPI;
25
27
 
26
28
  private static initialState: THEOplayerRCTViewState = {
27
29
  isBuffering: false,
@@ -31,10 +33,11 @@ export class THEOplayerView extends PureComponent<THEOplayerViewProps, THEOplaye
31
33
  constructor(props: THEOplayerViewProps) {
32
34
  super(props);
33
35
  this.state = THEOplayerView.initialState;
36
+ this._adsApi = new THEOplayerWebAdsAPI(this);
34
37
  }
35
38
 
36
39
  componentDidMount() {
37
- const { config, source } = this.props;
40
+ const { config, source, abrConfig } = this.props;
38
41
  const element = document.querySelector('.theoplayer-container') as HTMLElement;
39
42
  if (config?.chromeless === true || config?.chromeless === undefined) {
40
43
  this._player = new THEOplayer.ChromelessPlayer(element, {
@@ -50,6 +53,8 @@ export class THEOplayerView extends PureComponent<THEOplayerViewProps, THEOplaye
50
53
  },
51
54
  });
52
55
  }
56
+
57
+ Object.assign(this._player.abr, abrConfig);
53
58
  this._player.prepareWithUserAction();
54
59
  this._player.source = source;
55
60
  this.addEventListeners();
@@ -70,6 +75,14 @@ export class THEOplayerView extends PureComponent<THEOplayerViewProps, THEOplaye
70
75
  }
71
76
  }
72
77
 
78
+ public get ads(): AdsAPI {
79
+ return this._adsApi;
80
+ }
81
+
82
+ public get nativePlayer(): THEOplayer.ChromelessPlayer | null {
83
+ return this._player;
84
+ }
85
+
73
86
  private reset() {
74
87
  this.setState(THEOplayerView.initialState);
75
88
  }
@@ -79,12 +92,14 @@ export class THEOplayerView extends PureComponent<THEOplayerViewProps, THEOplaye
79
92
  return;
80
93
  }
81
94
  // track property changes
82
- const { paused, volume, selectedTextTrack, selectedAudioTrack, selectedVideoTrack, source, muted, playbackRate, fullscreen } = this.props;
95
+ const { paused, volume, selectedTextTrack, selectedAudioTrack, selectedVideoTrack, targetVideoQuality, source, muted, playbackRate, fullscreen } =
96
+ this.props;
83
97
  const {
84
98
  paused: wasPaused,
85
99
  selectedTextTrack: prevSelectedTextTrack,
86
100
  selectedAudioTrack: prevSelectedAudioTrack,
87
101
  selectedVideoTrack: prevSelectedVideoTrack,
102
+ targetVideoQuality: prevTargetVideoQuality,
88
103
  source: prevSource,
89
104
  muted: wasMuted,
90
105
  playbackRate: prevPlaybackRate,
@@ -141,6 +156,12 @@ export class THEOplayerView extends PureComponent<THEOplayerViewProps, THEOplaye
141
156
  videoTrack.enabled = videoTrack.uid === selectedVideoTrack;
142
157
  });
143
158
  }
159
+ if (targetVideoQuality != prevTargetVideoQuality) {
160
+ const videoTrack = this._player.videoTracks.find((videoTrack: NativeMediaTrack) => videoTrack.uid === selectedVideoTrack);
161
+ if (videoTrack) {
162
+ videoTrack.targetQuality = findNativeQualitiesByUid(videoTrack, targetVideoQuality);
163
+ }
164
+ }
144
165
  }
145
166
 
146
167
  private maybeChangeBufferingState(isBuffering: boolean) {
@@ -227,7 +248,7 @@ export class THEOplayerView extends PureComponent<THEOplayerViewProps, THEOplaye
227
248
  textTracks: player.textTracks.map((textTrack: NativeTextTrack) => fromNativeTextTrack(textTrack)),
228
249
  audioTracks: player.audioTracks.map((audioTrack: NativeMediaTrack) => fromNativeMediaTrack(audioTrack)),
229
250
  videoTracks: player.videoTracks.map((videoTrack: NativeMediaTrack) => fromNativeMediaTrack(videoTrack)),
230
- duration: 1e03 * player.duration,
251
+ duration: 1e3 * player.duration,
231
252
  selectedTextTrack: player.textTracks.find((track: NativeTextTrack) => track.mode === 'showing')?.uid,
232
253
  selectedVideoTrack: player.videoTracks.find((track: NativeMediaTrack) => track.enabled)?.uid,
233
254
  selectedAudioTrack: player.audioTracks.find((track: NativeMediaTrack) => track.enabled)?.uid,
@@ -274,6 +295,9 @@ export class THEOplayerView extends PureComponent<THEOplayerViewProps, THEOplaye
274
295
  });
275
296
 
276
297
  player.addEventListener('playing', () => {
298
+ // potentially notify change in buffering state
299
+ this.maybeChangeBufferingState(false);
300
+
277
301
  const { onPlaying } = this.props;
278
302
  if (onPlaying) {
279
303
  onPlaying();
@@ -384,6 +408,12 @@ export class THEOplayerView extends PureComponent<THEOplayerViewProps, THEOplaye
384
408
  });
385
409
  }
386
410
  });
411
+ player.ads?.addEventListener(AdEventNames, (event) => {
412
+ const { onAdEvent } = this.props;
413
+ if (onAdEvent) {
414
+ onAdEvent(event as AdEvent);
415
+ }
416
+ });
387
417
  }
388
418
 
389
419
  public render(): JSX.Element {
@@ -0,0 +1,44 @@
1
+ import type { AdBreak, AdsAPI } from "react-native-theoplayer";
2
+ import { NativeModules } from "react-native";
3
+ import type { AdDescription } from "react-native-theoplayer";
4
+ import type { Ad } from "react-native-theoplayer";
5
+ import type { THEOplayerView } from "react-native-theoplayer";
6
+ import type { GoogleDAI } from "react-native-theoplayer";
7
+ import { THEOplayerNativeGoogleDAI } from "./THEOplayerNativeGoogleDAI";
8
+
9
+ export class THEOplayerNativeAdsAPI implements AdsAPI {
10
+
11
+ private readonly _dai: GoogleDAI;
12
+
13
+ constructor(private _player: THEOplayerView) {
14
+ this._dai = new THEOplayerNativeGoogleDAI(this._player);
15
+ }
16
+
17
+ playing(): Promise<boolean> {
18
+ return NativeModules.AdsModule.playing(this._player.nativeHandle);
19
+ }
20
+
21
+ skip(): void {
22
+ NativeModules.AdsModule.skip(this._player.nativeHandle);
23
+ }
24
+
25
+ currentAdBreak(): Promise<AdBreak> {
26
+ return NativeModules.AdsModule.currentAdBreak(this._player.nativeHandle);
27
+ }
28
+
29
+ currentAds(): Promise<Ad[]> {
30
+ return NativeModules.AdsModule.currentAds(this._player.nativeHandle);
31
+ }
32
+
33
+ scheduledAdBreaks(): Promise<AdBreak[]> {
34
+ return NativeModules.AdsModule.scheduledAdBreaks(this._player.nativeHandle);
35
+ }
36
+
37
+ schedule(ad: AdDescription): void {
38
+ NativeModules.AdsModule.schedule(this._player.nativeHandle, ad);
39
+ }
40
+
41
+ get dai(): GoogleDAI | undefined {
42
+ return this._dai;
43
+ }
44
+ }
@@ -0,0 +1,23 @@
1
+ import type { GoogleDAI } from 'react-native-theoplayer';
2
+ import { NativeModules } from 'react-native';
3
+ import type { THEOplayerView } from 'react-native-theoplayer';
4
+
5
+ export class THEOplayerNativeGoogleDAI implements GoogleDAI {
6
+ public constructor(private readonly _player: THEOplayerView) {}
7
+
8
+ get snapback(): Promise<boolean> {
9
+ return NativeModules.AdsModule.daiSnapback(this._player.nativeHandle);
10
+ }
11
+
12
+ setSnapback(enabled: boolean): void {
13
+ NativeModules.AdsModule.daiSetSnapback(this._player.nativeHandle, enabled);
14
+ }
15
+
16
+ contentTimeForStreamTime(time: number): Promise<number> {
17
+ return NativeModules.AdsModule.daiContentTimeForStreamTime(this._player.nativeHandle, time);
18
+ }
19
+
20
+ streamTimeForContentTime(time: number): Promise<number> {
21
+ return NativeModules.AdsModule.daiStreamTimeForContentTime(this._player.nativeHandle, time);
22
+ }
23
+ }
@@ -0,0 +1,51 @@
1
+ import type { Ad, AdDescription, AdBreak, AdsAPI } from "react-native-theoplayer";
2
+ import type { THEOplayerView } from "../THEOplayerView.web";
3
+ import type { GoogleDAI } from "react-native-theoplayer";
4
+ import { THEOplayerWebGoogleDAI } from "./THEOplayerWebGoogleDAI";
5
+
6
+ export class THEOplayerWebAdsAPI implements AdsAPI {
7
+
8
+ private _dai: GoogleDAI | undefined;
9
+
10
+ constructor(private readonly _player: THEOplayerView) {
11
+ }
12
+
13
+ currentAdBreak(): Promise<AdBreak> {
14
+ const adBreak = this._player.nativePlayer?.ads?.currentAdBreak;
15
+ return adBreak ? Promise.resolve(adBreak) : Promise.reject<AdBreak>();
16
+ }
17
+
18
+ currentAds(): Promise<Ad[]> {
19
+ const ads = this._player.nativePlayer?.ads?.currentAds;
20
+ return ads ? Promise.resolve(ads) : Promise.reject<Ad[]>();
21
+ }
22
+
23
+ playing(): Promise<boolean> {
24
+ return Promise.resolve<boolean>(this._player.nativePlayer?.ads?.playing || false);
25
+ }
26
+
27
+ schedule(ad: AdDescription): void {
28
+ this._player.nativePlayer?.ads?.schedule(ad);
29
+ }
30
+
31
+ scheduledAdBreaks(): Promise<AdBreak[]> {
32
+ const adBreaks = this._player.nativePlayer?.ads?.scheduledAdBreaks;
33
+ return adBreaks ? Promise.resolve(adBreaks) : Promise.reject<AdBreak[]>();
34
+ }
35
+
36
+ skip(): void {
37
+ this._player.nativePlayer?.ads?.skip();
38
+ }
39
+
40
+ get dai(): GoogleDAI | undefined {
41
+ if (!this._dai) {
42
+ const nativeDai = this._player.nativePlayer?.ads?.dai;
43
+ if (!nativeDai) {
44
+ // Not native DAI available
45
+ return undefined;
46
+ }
47
+ this._dai = new THEOplayerWebGoogleDAI(nativeDai);
48
+ }
49
+ return this._dai;
50
+ }
51
+ }
@@ -0,0 +1,22 @@
1
+ import type { GoogleDAI } from 'react-native-theoplayer';
2
+ import type { GoogleDAI as NativeGoogleDAI } from 'theoplayer';
3
+
4
+ export class THEOplayerWebGoogleDAI implements GoogleDAI {
5
+ public constructor(private readonly _googleDAI: NativeGoogleDAI) {}
6
+
7
+ get snapback(): Promise<boolean> {
8
+ return Promise.resolve(this._googleDAI.snapback);
9
+ }
10
+
11
+ setSnapback(enabled: boolean): void {
12
+ this._googleDAI.snapback = enabled;
13
+ }
14
+
15
+ contentTimeForStreamTime(time: number): Promise<number> {
16
+ return Promise.resolve(this._googleDAI.contentTimeForStreamTime(time));
17
+ }
18
+
19
+ streamTimeForContentTime(time: number): Promise<number> {
20
+ return Promise.resolve(this._googleDAI.streamTimeForContentTime(time));
21
+ }
22
+ }
@@ -0,0 +1,173 @@
1
+ import type { CertificateRequest, ContentProtectionAPI, DRMConfiguration, LicenseRequest } from 'react-native-theoplayer';
2
+ import type { KeySystemId } from 'react-native-theoplayer';
3
+ import type { ContentProtectionIntegrationFactory } from 'react-native-theoplayer';
4
+ import { NativeEventEmitter, NativeModules } from 'react-native';
5
+ import type { ContentProtectionIntegration } from 'react-native-theoplayer';
6
+ import type { NativeContentProtectionEvent } from './NativeContentProtectionEvent';
7
+ import { fromNativeLicenseRequest, NativeLicenseRequest, toNativeLicenseRequest } from './NativeLicenseRequest';
8
+ import { fromNativeLicenseResponse, NativeLicenseResponse, toNativeLicenseResponseResult } from './NativeLicenseResponse';
9
+ import { fromNativeCertificateRequest, NativeCertificateRequest, toNativeCertificateRequest } from './NativeCertificateRequest';
10
+ import { fromNativeCertificateResponse, NativeCertificateResponse, toNativeCertificateResponseResult } from './NativeCertificateResponse';
11
+ import { isBufferSource } from '../utils/TypeUtils';
12
+
13
+ interface WrappedContentProtectionIntegrationFactory {
14
+ integrationId: string;
15
+ keySystemId: string;
16
+ integrationFactory: ContentProtectionIntegrationFactory;
17
+ }
18
+
19
+ interface WrappedContentProtectionIntegration {
20
+ integrationId: string;
21
+ keySystemId: string;
22
+ integration: ContentProtectionIntegration;
23
+ }
24
+
25
+ interface BuildEvent extends NativeContentProtectionEvent {
26
+ drmConfig: DRMConfiguration;
27
+ }
28
+
29
+ interface ExtractFaiplayContentIdEvent extends NativeContentProtectionEvent {
30
+ fairplaySkdUrl: string;
31
+ }
32
+
33
+ export class NativeContentProtectionRegistry implements ContentProtectionAPI {
34
+ private emitter: NativeEventEmitter;
35
+ private registeredFactories: WrappedContentProtectionIntegrationFactory[] = [];
36
+ private currentIntegration: WrappedContentProtectionIntegration | undefined = undefined;
37
+
38
+ constructor() {
39
+ this.emitter = new NativeEventEmitter(NativeModules.ContentProtectionModule);
40
+ this.emitter.addListener('onBuildIntegration', this.onBuildIntegrationRequest);
41
+ this.emitter.addListener('onCertificateRequest', this.onCertificateRequest);
42
+ this.emitter.addListener('onCertificateResponse', this.onCertificateResponse);
43
+ this.emitter.addListener('onLicenseRequest', this.onLicenseRequest);
44
+ this.emitter.addListener('onLicenseResponse', this.onLicenseResponse);
45
+ this.emitter.addListener('onExtractFairplayContentId', this.onExtractFairplayContentId);
46
+ }
47
+
48
+ registerContentProtectionIntegration(integrationId: string, keySystemId: KeySystemId, integrationFactory: ContentProtectionIntegrationFactory) {
49
+ this.registeredFactories.push({
50
+ integrationId,
51
+ keySystemId,
52
+ integrationFactory,
53
+ });
54
+ NativeModules.ContentProtectionModule.registerContentProtectionIntegration(integrationId, keySystemId);
55
+ }
56
+
57
+ private getFactory(integrationId: string, keySystemId: string): ContentProtectionIntegrationFactory | undefined {
58
+ return this.registeredFactories.find((init) => init.integrationId === integrationId && init.keySystemId === keySystemId)?.integrationFactory;
59
+ }
60
+
61
+ private getIntegration(integrationId: string, keySystemId: string): ContentProtectionIntegration | undefined {
62
+ return this.currentIntegration?.integrationId === integrationId && this.currentIntegration?.keySystemId === keySystemId
63
+ ? this.currentIntegration?.integration
64
+ : undefined;
65
+ }
66
+
67
+ private onBuildIntegrationRequest = (event: BuildEvent) => {
68
+ const { requestId, integrationId, keySystemId, drmConfig } = event;
69
+ console.log('ContentProtectionModule', `onBuildIntegrationRequest ${integrationId} ${keySystemId}`);
70
+ const factory = this.getFactory(integrationId, keySystemId);
71
+ if (factory) {
72
+ this.currentIntegration = {
73
+ integrationId,
74
+ keySystemId,
75
+ integration: factory.build(drmConfig),
76
+ };
77
+ NativeModules.ContentProtectionModule.onBuildProcessed({ requestId, resultString: 'success' });
78
+ } else {
79
+ NativeModules.ContentProtectionModule.onBuildProcessed({
80
+ requestId,
81
+ resultString: 'failed',
82
+ });
83
+ }
84
+ };
85
+
86
+ private onCertificateRequest = async (request: NativeCertificateRequest) => {
87
+ const { requestId, integrationId, keySystemId } = request;
88
+ console.log('ContentProtectionModule', `onCertificateRequest ${integrationId} ${keySystemId}`);
89
+ const integration = this.getIntegration(integrationId, keySystemId);
90
+ if (integration?.onCertificateRequest) {
91
+ const result = await integration.onCertificateRequest(fromNativeCertificateRequest(request));
92
+ // TODO: we also want to support ArrayBufferView results
93
+ if (isBufferSource(result)) {
94
+ const nativeResponse = toNativeCertificateResponseResult(requestId, integrationId, keySystemId, result as ArrayBuffer);
95
+ NativeModules.ContentProtectionModule.onCertificateRequestProcessedAsCertificate(nativeResponse);
96
+ } else if (result as CertificateRequest) {
97
+ const modifiedNativeRequest = toNativeCertificateRequest(requestId, integrationId, keySystemId, result as CertificateRequest);
98
+ NativeModules.ContentProtectionModule.onCertificateRequestProcessedAsRequest(modifiedNativeRequest);
99
+ }
100
+ } else {
101
+ NativeModules.ContentProtectionModule.onCertificateRequestProcessedAsRequest(request);
102
+ }
103
+ };
104
+
105
+ private onCertificateResponse = async (response: NativeCertificateResponse) => {
106
+ const { requestId, integrationId, keySystemId } = response;
107
+ console.log('ContentProtectionModule', `onCertificateResponse ${integrationId} ${keySystemId}`);
108
+ const integration = this.getIntegration(integrationId, keySystemId);
109
+ if (integration?.onCertificateResponse) {
110
+ const responseResult = await integration.onCertificateResponse(fromNativeCertificateResponse(response));
111
+ // TODO: we also want to support ArrayBufferView results
112
+ const modifiedNativeResponse = toNativeCertificateResponseResult(requestId, integrationId, keySystemId, responseResult as ArrayBuffer);
113
+ NativeModules.ContentProtectionModule.onCertificateResponseProcessed(modifiedNativeResponse);
114
+ } else {
115
+ NativeModules.ContentProtectionModule.onCertificateResponseProcessed(response);
116
+ }
117
+ };
118
+
119
+ private onLicenseRequest = async (request: NativeLicenseRequest) => {
120
+ const { requestId, integrationId, keySystemId } = request;
121
+ console.log('ContentProtectionModule', `onLicenseRequest ${integrationId} ${keySystemId}`);
122
+ const integration = this.getIntegration(integrationId, keySystemId);
123
+ // Optionally let the custom integration modify the request.
124
+ if (integration?.onLicenseRequest) {
125
+ const result = await integration.onLicenseRequest(fromNativeLicenseRequest(request));
126
+ // TODO: we also want to support ArrayBufferView results
127
+ if (isBufferSource(result)) {
128
+ const nativeResponse = toNativeLicenseResponseResult(requestId, integrationId, keySystemId, result as ArrayBuffer);
129
+ NativeModules.ContentProtectionModule.onLicenseRequestProcessedAsLicense(nativeResponse);
130
+ } else if (result as LicenseRequest) {
131
+ const modifiedNativeRequest = toNativeLicenseRequest(requestId, integrationId, keySystemId, result as LicenseRequest);
132
+ NativeModules.ContentProtectionModule.onLicenseRequestProcessedAsRequest(modifiedNativeRequest);
133
+ }
134
+ } else {
135
+ NativeModules.ContentProtectionModule.onLicenseRequestProcessedAsRequest(request);
136
+ }
137
+ };
138
+
139
+ private onLicenseResponse = async (response: NativeLicenseResponse) => {
140
+ const { requestId, integrationId, keySystemId } = response;
141
+ console.log('ContentProtectionModule', `onLicenseResponse ${integrationId} ${keySystemId}`);
142
+ const integration = this.getIntegration(integrationId, keySystemId);
143
+ if (integration?.onLicenseResponse) {
144
+ const responseResult = await integration.onLicenseResponse(fromNativeLicenseResponse(response));
145
+ // TODO: we also want to support ArrayBufferView results
146
+ const modifiedNativeResponse = toNativeLicenseResponseResult(requestId, integrationId, keySystemId, responseResult as ArrayBuffer);
147
+ NativeModules.ContentProtectionModule.onLicenseResponseProcessed(modifiedNativeResponse);
148
+ } else {
149
+ NativeModules.ContentProtectionModule.onLicenseResponseProcessed(response);
150
+ }
151
+ };
152
+
153
+ private onExtractFairplayContentId = async (event: ExtractFaiplayContentIdEvent) => {
154
+ const { integrationId, keySystemId, fairplaySkdUrl, requestId } = event;
155
+ console.log('ContentProtectionModule', `onExtractFairplayContentId ${integrationId} ${keySystemId}`);
156
+ const integration = this.getIntegration(integrationId, keySystemId);
157
+ if (integration?.extractFairplayContentId) {
158
+ const contentId = await integration.extractFairplayContentId(fairplaySkdUrl);
159
+ NativeModules.ContentProtectionModule.onExtractFairplayContentIdProcessed({
160
+ requestId,
161
+ contentId,
162
+ });
163
+ } else {
164
+ const contentId = fairplaySkdUrl;
165
+ NativeModules.ContentProtectionModule.onExtractFairplayContentIdProcessed({
166
+ requestId,
167
+ contentId,
168
+ });
169
+ }
170
+ };
171
+ }
172
+
173
+ export const ContentProtectionRegistry = new NativeContentProtectionRegistry();
@@ -0,0 +1,10 @@
1
+ import type { ContentProtectionAPI, ContentProtectionIntegrationFactory, KeySystemId } from 'react-native-theoplayer';
2
+ import { registerContentProtectionIntegration } from 'theoplayer';
3
+
4
+ export class WebContentProtectionRegistry implements ContentProtectionAPI {
5
+ registerContentProtectionIntegration(integrationId: string, keySystem: KeySystemId, integrationFactory: ContentProtectionIntegrationFactory): void {
6
+ registerContentProtectionIntegration(integrationId, keySystem, integrationFactory);
7
+ }
8
+ }
9
+
10
+ export const ContentProtectionRegistry = new WebContentProtectionRegistry();