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
@@ -7,13 +7,18 @@ import THEOplayerSDK
7
7
  class THEOplayerRCTView: UIView {
8
8
  // MARK: Members
9
9
  private var player: THEOplayer?
10
- private var eventHandler: THEOplayerRCTViewEventHandler
10
+ private var mainEventHandler: THEOplayerRCTViewMainEventHandler
11
+ private var textTrackEventHandler: THEOplayerRCTViewTextTrackEventHandler
12
+ private var adEventHandler: THEOplayerRCTViewAdEventHandler
11
13
 
12
14
  // MARK: Bridged props
13
15
  private var src: SourceDescription?
14
16
  private var license: String?
15
17
  private var licenseUrl: String?
16
18
  private var chromeless: Bool = true
19
+ private var adSUIEnabled: Bool = true
20
+ private var adPreloadType: THEOplayerSDK.AdPreloadType = THEOplayerSDK.AdPreloadType.MIDROLL_AND_POSTROLL
21
+ private var googleImaUsesNativeIma: Bool = true
17
22
  private var config: THEOplayerConfiguration?
18
23
  private var paused: Bool = false
19
24
  private var muted: Bool = true
@@ -26,19 +31,30 @@ class THEOplayerRCTView: UIView {
26
31
 
27
32
  // MARK: - Initialisation / view setup
28
33
  init() {
29
- // create an event handler to contain event props
30
- self.eventHandler = THEOplayerRCTViewEventHandler()
34
+ // create event handlers to maintain event props
35
+ self.mainEventHandler = THEOplayerRCTViewMainEventHandler()
36
+ self.textTrackEventHandler = THEOplayerRCTViewTextTrackEventHandler()
37
+ self.adEventHandler = THEOplayerRCTViewAdEventHandler()
31
38
 
32
39
  super.init(frame: .zero)
33
40
  }
34
41
 
35
42
  func destroy() {
36
- self.eventHandler.destroy()
43
+ self.mainEventHandler.destroy()
44
+ self.textTrackEventHandler.destroy()
45
+ self.adEventHandler.destroy()
37
46
  self.player?.destroy()
38
47
  self.player = nil
39
48
  if DEBUG_THEOPLAYER_INTERACTION { print("[NATIVE] THEOplayer instance destroyed.") }
40
49
  }
41
50
 
51
+ func ads() -> Ads? {
52
+ guard let player = self.player else {
53
+ return nil
54
+ }
55
+ return player.ads
56
+ }
57
+
42
58
  required init?(coder aDecoder: NSCoder) {
43
59
  fatalError("[NATIVE] init(coder:) has not been implemented")
44
60
  }
@@ -79,32 +95,56 @@ class THEOplayerRCTView: UIView {
79
95
  return
80
96
  }
81
97
 
82
- if (self.player == nil) {
83
- // 'lazy' init THEOplayer instance, performed on next runloop, to make sure all props have been set (license config is needed to init player)
84
- DispatchQueue.main.async {
85
- if DEBUG_THEOPLAYER_INTERACTION { print("[NATIVE] 'lazy' init THEOplayer instance") }
98
+ // reset player for new source
99
+ if self.player != nil {
100
+ self.player?.destroy()
101
+ self.player = nil
102
+ }
103
+ DispatchQueue.main.async {
104
+ self.initPlayer()
105
+ if let player = self.player {
106
+ // couple player instance to event handlers
107
+ self.mainEventHandler.setPlayer(player)
108
+ self.textTrackEventHandler.setPlayer(player)
109
+ self.adEventHandler.setPlayer(player)
110
+ // couple player instance to view
111
+ player.addAsSubview(of: self)
112
+ }
113
+ self.syncAllPlayerProps()
114
+ }
115
+ }
116
+
117
+ private func initPlayer() {
118
+ if DEBUG_THEOPLAYER_INTERACTION { print("[NATIVE] 'lazy' init THEOplayer instance") }
86
119
  #if os(tvOS)
87
- self.player = THEOplayer(configuration: THEOplayerConfiguration(chromeless: self.chromeless, license: self.license, licenseUrl: self.licenseUrl, pip: nil))
120
+ self.player = THEOplayer(configuration: THEOplayerConfiguration(chromeless: self.chromeless,
121
+ license: self.license,
122
+ licenseUrl: self.licenseUrl,
123
+ pip: nil))
88
124
  #else
89
- let stylePath = Bundle.main.path(forResource:"style", ofType: "css")
90
- let cssPaths = stylePath != nil ? [stylePath!] : []
91
- self.player = THEOplayer(configuration: THEOplayerConfiguration(chromeless: self.chromeless, cssPaths: cssPaths, pip: nil, license: self.license, licenseUrl: self.licenseUrl))
125
+ let stylePath = Bundle.main.path(forResource:"style", ofType: "css")
126
+ let cssPaths = stylePath != nil ? [stylePath!] : []
127
+ self.player = THEOplayer(configuration: THEOplayerConfiguration(chromeless: self.chromeless,
128
+ cssPaths: cssPaths,
129
+ pip: nil,
130
+ ads: self.initAdsConfiguration(),
131
+ license: self.license,
132
+ licenseUrl: self.licenseUrl))
92
133
  #endif
93
- if let player = self.player {
94
- // couple player instance to event handler
95
- self.eventHandler.setPlayer(player)
96
- // couple player instance to view
97
- player.addAsSubview(of: self)
98
- }
99
- self.syncAllPlayerProps()
100
- }
101
- } else {
102
- self.syncPlayerSrc()
103
- self.syncPlayerMuted()
104
- if !self.paused {
105
- self.player?.play()
106
- }
107
- }
134
+ }
135
+
136
+ private func initAdsConfiguration() -> AdsConfiguration? {
137
+ #if ADS && (GOOGLE_IMA || GOOGLE_DAI)
138
+ let googleIMAConfiguration = GoogleIMAConfiguration()
139
+ googleIMAConfiguration.useNativeIma = self.googleImaUsesNativeIma
140
+ googleIMAConfiguration.disableUI = !self.adSUIEnabled
141
+ return AdsConfiguration(showCountdown: self.adSUIEnabled,
142
+ preload: self.adPreloadType,
143
+ googleImaConfiguration: googleIMAConfiguration)
144
+ #else
145
+ return nil
146
+ #endif
147
+
108
148
  }
109
149
 
110
150
  private func syncPlayerSrc() {
@@ -121,6 +161,15 @@ class THEOplayerRCTView: UIView {
121
161
  self.license = configDict["license"] as? String
122
162
  self.licenseUrl = configDict["licenseUrl"] as? String
123
163
  self.chromeless = configDict["chromeless"] as? Bool ?? true
164
+ if let adsConfig = configDict["ads"] as? NSDictionary {
165
+ self.adSUIEnabled = adsConfig["uiEnabled"] as? Bool ?? true
166
+ if let adPreloadType = adsConfig["preload"] as? String {
167
+ self.adPreloadType = adPreloadType == "none" ? THEOplayerSDK.AdPreloadType.NONE : THEOplayerSDK.AdPreloadType.MIDROLL_AND_POSTROLL
168
+ }
169
+ if let googleImaConfiguration = adsConfig["googleImaConfiguration"] as? NSDictionary {
170
+ self.googleImaUsesNativeIma = googleImaConfiguration["useNativeIma"] as? Bool ?? true
171
+ }
172
+ }
124
173
  if DEBUG_PROP_UPDATES { print("[NATIVE] config prop updated.") }
125
174
  }
126
175
 
@@ -296,130 +345,141 @@ class THEOplayerRCTView: UIView {
296
345
  }
297
346
  }
298
347
 
299
- // MARK: - Listener based event bridging
348
+ // MARK: - Listener based MAIN event bridging
349
+
300
350
  @objc(setOnNativePlay:)
301
351
  func setOnNativePlay(nativePlay: @escaping RCTDirectEventBlock) {
302
- self.eventHandler.onNativePlay = nativePlay
352
+ self.mainEventHandler.onNativePlay = nativePlay
303
353
  if DEBUG_PROP_UPDATES { print("[NATIVE] nativePlay prop set.") }
304
354
  }
305
355
 
306
356
  @objc(setOnNativePause:)
307
357
  func setOnNativePause(nativePause: @escaping RCTDirectEventBlock) {
308
- self.eventHandler.onNativePause = nativePause
358
+ self.mainEventHandler.onNativePause = nativePause
309
359
  if DEBUG_PROP_UPDATES { print("[NATIVE] nativePause prop set.") }
310
360
  }
311
361
 
312
362
  @objc(setOnNativeSourceChange:)
313
363
  func setOnNativeSourceChange(nativeSourceChange: @escaping RCTDirectEventBlock) {
314
- self.eventHandler.onNativeSourceChange = nativeSourceChange
364
+ self.mainEventHandler.onNativeSourceChange = nativeSourceChange
315
365
  if DEBUG_PROP_UPDATES { print("[NATIVE] nativeSourceChange prop set.") }
316
366
  }
317
367
 
318
368
  @objc(setOnNativeLoadStart:)
319
369
  func setOnNativeLoadStart(nativeLoadStart: @escaping RCTDirectEventBlock) {
320
- self.eventHandler.onNativeLoadStart = nativeLoadStart
370
+ self.mainEventHandler.onNativeLoadStart = nativeLoadStart
321
371
  if DEBUG_PROP_UPDATES { print("[NATIVE] nativeLoadStart prop set.") }
322
372
  }
323
373
 
324
374
  @objc(setOnNativeReadyStateChange:)
325
375
  func setOnNativeReadyStateChange(nativeReadyStateChange: @escaping RCTDirectEventBlock) {
326
- self.eventHandler.onNativeReadyStateChange = nativeReadyStateChange
376
+ self.mainEventHandler.onNativeReadyStateChange = nativeReadyStateChange
327
377
  if DEBUG_PROP_UPDATES { print("[NATIVE] nativeReadyStateChange prop set.") }
328
378
  }
329
379
 
330
380
  @objc(setOnNativeDurationChange:)
331
381
  func setOnNativeDurationChange(nativeDurationChange: @escaping RCTDirectEventBlock) {
332
- self.eventHandler.onNativeDurationChange = nativeDurationChange
382
+ self.mainEventHandler.onNativeDurationChange = nativeDurationChange
333
383
  if DEBUG_PROP_UPDATES { print("[NATIVE] nativeDurationChange prop set.") }
334
384
  }
335
385
 
336
386
  @objc(setOnNativeProgress:)
337
387
  func setOnNativeProgress(nativeProgress: @escaping RCTBubblingEventBlock) {
338
- self.eventHandler.onNativeProgress = nativeProgress
388
+ self.mainEventHandler.onNativeProgress = nativeProgress
339
389
  if DEBUG_PROP_UPDATES { print("[NATIVE] nativeProgress prop set.") }
340
390
  }
341
391
 
342
392
  @objc(setOnNativeTimeUpdate:)
343
393
  func setOnNativeTimeUpdate(nativeTimeUpdate: @escaping RCTBubblingEventBlock) {
344
- self.eventHandler.onNativeTimeUpdate = nativeTimeUpdate
394
+ self.mainEventHandler.onNativeTimeUpdate = nativeTimeUpdate
345
395
  if DEBUG_PROP_UPDATES { print("[NATIVE] nativeTimeUpdate prop set.") }
346
396
  }
347
397
 
348
398
  @objc(setOnNativePlaying:)
349
399
  func setOnNativePlaying(nativePlaying: @escaping RCTDirectEventBlock) {
350
- self.eventHandler.onNativePlaying = nativePlaying
400
+ self.mainEventHandler.onNativePlaying = nativePlaying
351
401
  if DEBUG_PROP_UPDATES { print("[NATIVE] nativePlaying prop set.") }
352
402
  }
353
403
 
354
404
  @objc(setOnNativeSeeking:)
355
405
  func setOnNativeSeeking(nativeSeeking: @escaping RCTDirectEventBlock) {
356
- self.eventHandler.onNativeSeeking = nativeSeeking
406
+ self.mainEventHandler.onNativeSeeking = nativeSeeking
357
407
  if DEBUG_PROP_UPDATES { print("[NATIVE] nativeSeeking prop set.") }
358
408
  }
359
409
 
360
410
  @objc(setOnNativeSeeked:)
361
411
  func setOnNativeSeeked(nativeSeeked: @escaping RCTDirectEventBlock) {
362
- self.eventHandler.onNativeSeeked = nativeSeeked
412
+ self.mainEventHandler.onNativeSeeked = nativeSeeked
363
413
  if DEBUG_PROP_UPDATES { print("[NATIVE] nativeSeeked prop set.") }
364
414
  }
365
415
 
366
416
  @objc(setOnNativeEnded:)
367
417
  func setOnNativeEnded(nativeEnded: @escaping RCTDirectEventBlock) {
368
- self.eventHandler.onNativeEnded = nativeEnded
418
+ self.mainEventHandler.onNativeEnded = nativeEnded
369
419
  if DEBUG_PROP_UPDATES { print("[NATIVE] nativeEnded prop set.") }
370
420
  }
371
421
 
372
422
  @objc(setOnNativeError:)
373
423
  func setOnNativeError(nativeError: @escaping RCTDirectEventBlock) {
374
- self.eventHandler.onNativeError = nativeError
424
+ self.mainEventHandler.onNativeError = nativeError
375
425
  if DEBUG_PROP_UPDATES { print("[NATIVE] nativeError prop set.") }
376
426
  }
377
427
 
378
428
  @objc(setOnNativeLoadedData:)
379
429
  func setOnNativeLoadedData(nativeLoadedData: @escaping RCTDirectEventBlock) {
380
- self.eventHandler.onNativeLoadedData = nativeLoadedData
430
+ self.mainEventHandler.onNativeLoadedData = nativeLoadedData
381
431
  if DEBUG_PROP_UPDATES { print("[NATIVE] nativeLoadedData prop set.") }
382
432
  }
383
433
 
384
434
  @objc(setOnNativeLoadedMetadata:)
385
435
  func setOnNativeLoadedMetadata(nativeLoadedMetadata: @escaping RCTDirectEventBlock) {
386
- self.eventHandler.onNativeLoadedMetadata = nativeLoadedMetadata
436
+ self.mainEventHandler.onNativeLoadedMetadata = nativeLoadedMetadata
387
437
  if DEBUG_PROP_UPDATES { print("[NATIVE] nativeLoadedMetadata prop set.") }
388
438
  }
389
439
 
390
440
  @objc(setOnNativeFullscreenPlayerWillPresent:)
391
441
  func setOnNativeFullscreenPlayerWillPresent(nativeFullscreenPlayerWillPresent: @escaping RCTDirectEventBlock) {
392
- self.eventHandler.onNativeFullscreenPlayerWillPresent = nativeFullscreenPlayerWillPresent
442
+ self.mainEventHandler.onNativeFullscreenPlayerWillPresent = nativeFullscreenPlayerWillPresent
393
443
  if DEBUG_PROP_UPDATES { print("[NATIVE] nativeFullscreenPlayerWillPresent prop set.") }
394
444
  }
395
445
 
396
446
  @objc(setOnNativeFullscreenPlayerDidPresent:)
397
447
  func setOnNativeFullscreenPlayerDidPresent(nativeFullscreenPlayerDidPresent: @escaping RCTDirectEventBlock) {
398
- self.eventHandler.onNativeFullscreenPlayerDidPresent = nativeFullscreenPlayerDidPresent
448
+ self.mainEventHandler.onNativeFullscreenPlayerDidPresent = nativeFullscreenPlayerDidPresent
399
449
  if DEBUG_PROP_UPDATES { print("[NATIVE] nativeFullscreenPlayerDidPresent prop set.") }
400
450
  }
401
451
 
402
452
  @objc(setOnNativeFullscreenPlayerWillDismiss:)
403
453
  func setOnNativeFullscreenPlayerWillDismiss(nativeFullscreenPlayerWillDismiss: @escaping RCTDirectEventBlock) {
404
- self.eventHandler.onNativeFullscreenPlayerWillDismiss = nativeFullscreenPlayerWillDismiss
454
+ self.mainEventHandler.onNativeFullscreenPlayerWillDismiss = nativeFullscreenPlayerWillDismiss
405
455
  if DEBUG_PROP_UPDATES { print("[NATIVE] nativeFullscreenPlayerWillDismiss prop set.") }
406
456
  }
407
457
 
408
458
  @objc(setOnNativeFullscreenPlayerDidDismiss:)
409
459
  func setOnNativeFullscreenPlayerDidDismiss(nativeFullscreenPlayerDidDismiss: @escaping RCTDirectEventBlock) {
410
- self.eventHandler.onNativeFullscreenPlayerDidDismiss = nativeFullscreenPlayerDidDismiss
460
+ self.mainEventHandler.onNativeFullscreenPlayerDidDismiss = nativeFullscreenPlayerDidDismiss
411
461
  if DEBUG_PROP_UPDATES { print("[NATIVE] nativeFullscreenPlayerDidDismiss prop set.") }
412
462
  }
413
463
 
464
+ // MARK: - Listener based TEXTTRACK event bridging
465
+
414
466
  @objc(setOnNativeTextTrackListEvent:)
415
467
  func setOnNativeTextTrackListEvent(nativeTextTrackListEvent: @escaping RCTDirectEventBlock) {
416
- self.eventHandler.onNativeTextTrackListEvent = nativeTextTrackListEvent
468
+ self.textTrackEventHandler.onNativeTextTrackListEvent = nativeTextTrackListEvent
417
469
  if DEBUG_PROP_UPDATES { print("[NATIVE] nativeTextTrackListEvent prop set.") }
418
470
  }
419
471
 
420
472
  @objc(setOnNativeTextTrackEvent:)
421
473
  func setOnNativeTextTrackEvent(nativeTextTrackEvent: @escaping RCTDirectEventBlock) {
422
- self.eventHandler.onNativeTextTrackEvent = nativeTextTrackEvent
474
+ self.textTrackEventHandler.onNativeTextTrackEvent = nativeTextTrackEvent
423
475
  if DEBUG_PROP_UPDATES { print("[NATIVE] nativeTextTrackEvent prop set.") }
424
476
  }
477
+
478
+ // MARK: - Listener based AD event bridging
479
+
480
+ @objc(setOnNativeAdEvent:)
481
+ func setOnNativeAdEvent(nativeAdEvent: @escaping RCTDirectEventBlock) {
482
+ self.adEventHandler.onNativeAdEvent = nativeAdEvent
483
+ if DEBUG_PROP_UPDATES { print("[NATIVE] nativeAdEvent prop set.") }
484
+ }
425
485
  }
@@ -0,0 +1,238 @@
1
+ // THEOplayerRCTViewAdEventHandler.swift
2
+
3
+ import Foundation
4
+ import THEOplayerSDK
5
+
6
+ let AD_EVENT_PROP_TYPE: String = "type"
7
+ let AD_EVENT_PROP_AD: String = "ad"
8
+
9
+ let EVENT_TYPE_AD_BEGIN: String = "adbegin"
10
+ let EVENT_TYPE_AD_END: String = "adend"
11
+ let EVENT_TYPE_ADBREAK_BEGIN: String = "adbreakbegin"
12
+ let EVENT_TYPE_ADBREAK_END: String = "adbreakend"
13
+ let EVENT_TYPE_AD_ERROR: String = "aderror"
14
+ let EVENT_TYPE_AD_FIRST_QUARTILE: String = "adfirstquartile"
15
+ let EVENT_TYPE_AD_THIRD_QUARTILE: String = "adthirdquartile"
16
+ let EVENT_TYPE_AD_MIDPOINT: String = "admidpoint"
17
+ let EVENT_TYPE_AD_LOADED: String = "adloaded"
18
+
19
+ class THEOplayerRCTViewAdEventHandler {
20
+ // MARK: Members
21
+ private weak var player: THEOplayer?
22
+
23
+ // MARK: Events
24
+ var onNativeAdEvent: RCTDirectEventBlock?
25
+
26
+ // MARK: Ad Listeners
27
+ private var adBeginListener: EventListener?
28
+ private var adEndListener: EventListener?
29
+ private var adBreakBeginListener: EventListener?
30
+ private var adBreakEndListener: EventListener?
31
+ private var adErrorListener: EventListener?
32
+ private var adFirstQuartileListener: EventListener?
33
+ private var adMidpointListener: EventListener?
34
+ private var adThirdQuartileListener: EventListener?
35
+ private var adLoadedListener: EventListener?
36
+
37
+ // MARK: - destruction
38
+ func destroy() {
39
+ // dettach listeners
40
+ #if ADS && (GOOGLE_IMA || GOOLGE_DAI)
41
+ self.dettachListeners()
42
+ #endif
43
+ }
44
+
45
+ // MARK: - player setup / breakdown
46
+ func setPlayer(_ player: THEOplayer) {
47
+ self.player = player;
48
+
49
+ // attach listeners
50
+ #if ADS && (GOOGLE_IMA || GOOLGE_DAI)
51
+ self.attachListeners()
52
+ #endif
53
+ }
54
+
55
+ // MARK: - attach/dettach Listeners
56
+ private func attachListeners() {
57
+ guard let player = self.player else {
58
+ return
59
+ }
60
+
61
+ // AD_BEGIN
62
+ self.adBeginListener = player.ads.addEventListener(type: AdsEventTypes.AD_BEGIN) { [weak self] event in
63
+ if DEBUG_THEOPLAYER_EVENTS { print("[NATIVE] Received AD_BEGIN event from THEOplayer Ads") }
64
+ if let forwardedAdEvent = self?.onNativeAdEvent,
65
+ let ad = event.ad {
66
+ forwardedAdEvent([
67
+ AD_EVENT_PROP_TYPE: EVENT_TYPE_AD_BEGIN,
68
+ AD_EVENT_PROP_AD: THEOplayerRCTAdAggregator.aggregateAd(ad: ad)
69
+ ])
70
+ }
71
+ }
72
+ if DEBUG_EVENTHANDLER { print("[NATIVE] AdBegin listener attached to THEOplayer.ads") }
73
+
74
+ // AD_END
75
+ self.adEndListener = player.ads.addEventListener(type: AdsEventTypes.AD_END) { [weak self] event in
76
+ if DEBUG_THEOPLAYER_EVENTS { print("[NATIVE] Received AD_END event from THEOplayer Ads") }
77
+ if let forwardedAdEvent = self?.onNativeAdEvent,
78
+ let ad = event.ad {
79
+ forwardedAdEvent([
80
+ AD_EVENT_PROP_TYPE: EVENT_TYPE_AD_END,
81
+ AD_EVENT_PROP_AD: THEOplayerRCTAdAggregator.aggregateAd(ad: ad)
82
+ ])
83
+ }
84
+ }
85
+ if DEBUG_EVENTHANDLER { print("[NATIVE] AdEnd listener attached to THEOplayer.ads") }
86
+
87
+ // AD_BREAK_BEGIN
88
+ self.adBreakBeginListener = player.ads.addEventListener(type: AdsEventTypes.AD_BREAK_BEGIN) { [weak self] event in
89
+ if DEBUG_THEOPLAYER_EVENTS { print("[NATIVE] Received AD_BREAK_BEGIN event from THEOplayer Ads") }
90
+ if let forwardedAdEvent = self?.onNativeAdEvent,
91
+ let adBreak = event.ad {
92
+ forwardedAdEvent([
93
+ AD_EVENT_PROP_TYPE: EVENT_TYPE_ADBREAK_BEGIN,
94
+ AD_EVENT_PROP_AD: THEOplayerRCTAdAggregator.aggregateAdBreak(adBreak: adBreak)
95
+ ])
96
+ }
97
+ }
98
+ if DEBUG_EVENTHANDLER { print("[NATIVE] AdBreakBegin listener attached to THEOplayer.ads") }
99
+
100
+ // AD_BREAK_END
101
+ self.adBreakEndListener = player.ads.addEventListener(type: AdsEventTypes.AD_BREAK_END) { [weak self] event in
102
+ if DEBUG_THEOPLAYER_EVENTS { print("[NATIVE] Received AD_BREAK_END event from THEOplayer Ads") }
103
+ if let forwardedAdEvent = self?.onNativeAdEvent,
104
+ let adBreak = event.ad {
105
+ forwardedAdEvent([
106
+ AD_EVENT_PROP_TYPE: EVENT_TYPE_ADBREAK_END,
107
+ AD_EVENT_PROP_AD: THEOplayerRCTAdAggregator.aggregateAdBreak(adBreak: adBreak)
108
+ ])
109
+ }
110
+ }
111
+ if DEBUG_EVENTHANDLER { print("[NATIVE] AdBreakEnd listener attached to THEOplayer.ads") }
112
+
113
+ // AD_ERROR
114
+ self.adErrorListener = player.ads.addEventListener(type: AdsEventTypes.AD_ERROR) { [weak self] event in
115
+ if DEBUG_THEOPLAYER_EVENTS { print("[NATIVE] Received AD_ERROR event from THEOplayer Ads") }
116
+ if let forwardedAdEvent = self?.onNativeAdEvent,
117
+ let ad = event.ad {
118
+ forwardedAdEvent([
119
+ AD_EVENT_PROP_TYPE: EVENT_TYPE_AD_ERROR,
120
+ AD_EVENT_PROP_AD: THEOplayerRCTAdAggregator.aggregateAd(ad: ad)
121
+ ])
122
+ }
123
+ }
124
+ if DEBUG_EVENTHANDLER { print("[NATIVE] AdError listener attached to THEOplayer.ads") }
125
+
126
+ // AD_FIRST_QUARTILE
127
+ self.adFirstQuartileListener = player.ads.addEventListener(type: AdsEventTypes.AD_FIRST_QUARTILE) { [weak self] event in
128
+ if DEBUG_THEOPLAYER_EVENTS { print("[NATIVE] Received AD_FIRST_QUARTILE event from THEOplayer Ads") }
129
+ if let forwardedAdEvent = self?.onNativeAdEvent,
130
+ let ad = event.ad {
131
+ forwardedAdEvent([
132
+ AD_EVENT_PROP_TYPE: EVENT_TYPE_AD_FIRST_QUARTILE,
133
+ AD_EVENT_PROP_AD: THEOplayerRCTAdAggregator.aggregateAd(ad: ad)
134
+ ])
135
+ }
136
+ }
137
+ if DEBUG_EVENTHANDLER { print("[NATIVE] AdFirstQuartile listener attached to THEOplayer.ads") }
138
+
139
+ // AD_MIDPOINT
140
+ self.adMidpointListener = player.ads.addEventListener(type: AdsEventTypes.AD_MIDPOINT) { [weak self] event in
141
+ if DEBUG_THEOPLAYER_EVENTS { print("[NATIVE] Received AD_MIDPOINT event from THEOplayer Ads") }
142
+ if let forwardedAdEvent = self?.onNativeAdEvent,
143
+ let ad = event.ad {
144
+ forwardedAdEvent([
145
+ AD_EVENT_PROP_TYPE: EVENT_TYPE_AD_MIDPOINT,
146
+ AD_EVENT_PROP_AD: THEOplayerRCTAdAggregator.aggregateAd(ad: ad)
147
+ ])
148
+ }
149
+ }
150
+ if DEBUG_EVENTHANDLER { print("[NATIVE] AdMidpoint listener attached to THEOplayer.ads") }
151
+
152
+ // AD_THIRD_QUARTILE
153
+ self.adThirdQuartileListener = player.ads.addEventListener(type: AdsEventTypes.AD_THIRD_QUARTILE) { [weak self] event in
154
+ if DEBUG_THEOPLAYER_EVENTS { print("[NATIVE] Received AD_THIRD_QUARTILE event from THEOplayer Ads") }
155
+ if let forwardedAdEvent = self?.onNativeAdEvent,
156
+ let ad = event.ad {
157
+ forwardedAdEvent([
158
+ AD_EVENT_PROP_TYPE: EVENT_TYPE_AD_THIRD_QUARTILE,
159
+ AD_EVENT_PROP_AD: THEOplayerRCTAdAggregator.aggregateAd(ad: ad)
160
+ ])
161
+ }
162
+ }
163
+ if DEBUG_EVENTHANDLER { print("[NATIVE] AdThirdQuartile listener attached to THEOplayer.ads") }
164
+
165
+ // AD_LOADED
166
+ self.adLoadedListener = player.ads.addEventListener(type: AdsEventTypes.AD_LOADED) { [weak self] event in
167
+ if DEBUG_THEOPLAYER_EVENTS { print("[NATIVE] Received AD_LOADED event from THEOplayer Ads") }
168
+ if let forwardedAdEvent = self?.onNativeAdEvent,
169
+ let ad = event.ad {
170
+ forwardedAdEvent([
171
+ AD_EVENT_PROP_TYPE: EVENT_TYPE_AD_LOADED,
172
+ AD_EVENT_PROP_AD: THEOplayerRCTAdAggregator.aggregateAd(ad: ad)
173
+ ])
174
+ }
175
+ }
176
+ if DEBUG_EVENTHANDLER { print("[NATIVE] AdThirdQuartile listener attached to THEOplayer.ads") }
177
+ }
178
+
179
+ private func dettachListeners() {
180
+ guard let player = self.player else {
181
+ return
182
+ }
183
+
184
+ // AD_BEGIN
185
+ if let adBeginListener = self.adBeginListener {
186
+ player.ads.removeEventListener(type: AdsEventTypes.AD_BEGIN, listener: adBeginListener)
187
+ if DEBUG_EVENTHANDLER { print("[NATIVE] AdBegin listener dettached from THEOplayer.ads") }
188
+ }
189
+
190
+ // AD_END
191
+ if let adEndListener = self.adEndListener {
192
+ player.ads.removeEventListener(type: AdsEventTypes.AD_END, listener: adEndListener)
193
+ if DEBUG_EVENTHANDLER { print("[NATIVE] AdEnd listener dettached from THEOplayer.ads") }
194
+ }
195
+
196
+ // AD_BREAK_BEGIN
197
+ if let adBreakBeginListener = self.adBreakBeginListener {
198
+ player.ads.removeEventListener(type: AdsEventTypes.AD_BREAK_BEGIN, listener: adBreakBeginListener)
199
+ if DEBUG_EVENTHANDLER { print("[NATIVE] AdBreakBegin listener dettached from THEOplayer.ads") }
200
+ }
201
+
202
+ // AD_BREAK_END
203
+ if let adBreakEndListener = self.adBreakEndListener {
204
+ player.ads.removeEventListener(type: AdsEventTypes.AD_BREAK_END, listener: adBreakEndListener)
205
+ if DEBUG_EVENTHANDLER { print("[NATIVE] AdBreakEnd listener dettached from THEOplayer.ads") }
206
+ }
207
+
208
+ // AD_ERROR
209
+ if let adErrorListener = self.adErrorListener {
210
+ player.ads.removeEventListener(type: AdsEventTypes.AD_ERROR, listener: adErrorListener)
211
+ if DEBUG_EVENTHANDLER { print("[NATIVE] AdError listener dettached from THEOplayer.ads") }
212
+ }
213
+
214
+ // AD_FIRST_QUARTILE
215
+ if let adFirstQuartileListener = self.adFirstQuartileListener {
216
+ player.ads.removeEventListener(type: AdsEventTypes.AD_FIRST_QUARTILE, listener: adFirstQuartileListener)
217
+ if DEBUG_EVENTHANDLER { print("[NATIVE] adFirstQuartileListener listener dettached from THEOplayer.ads") }
218
+ }
219
+
220
+ // AD_MIDPOINT
221
+ if let adMidpointListener = self.adMidpointListener {
222
+ player.ads.removeEventListener(type: AdsEventTypes.AD_MIDPOINT, listener: adMidpointListener)
223
+ if DEBUG_EVENTHANDLER { print("[NATIVE] adMidpointListener listener dettached from THEOplayer.ads") }
224
+ }
225
+
226
+ // AD_THIRD_QUARTILE
227
+ if let adThirdQuartileListener = self.adThirdQuartileListener {
228
+ player.ads.removeEventListener(type: AdsEventTypes.AD_THIRD_QUARTILE, listener: adThirdQuartileListener)
229
+ if DEBUG_EVENTHANDLER { print("[NATIVE] adThirdQuartileListener listener dettached from THEOplayer.ads") }
230
+ }
231
+
232
+ // AD_LOADED
233
+ if let adLoadedListener = self.adLoadedListener {
234
+ player.ads.removeEventListener(type: AdsEventTypes.AD_LOADED, listener: adLoadedListener)
235
+ if DEBUG_EVENTHANDLER { print("[NATIVE] adLoadedListener listener dettached from THEOplayer.ads") }
236
+ }
237
+ }
238
+ }