react-native-theoplayer 1.6.1 → 1.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (465) hide show
  1. package/README.md +4 -0
  2. package/android/build.gradle +70 -25
  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 +269 -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
@@ -1,7 +1,6 @@
1
1
  package com.theoplayer;
2
2
 
3
3
  import android.text.TextUtils;
4
- import android.util.Log;
5
4
 
6
5
  import androidx.annotation.NonNull;
7
6
  import androidx.annotation.Nullable;
@@ -9,7 +8,11 @@ import androidx.annotation.Nullable;
9
8
  import com.facebook.react.bridge.ReadableArray;
10
9
  import com.facebook.react.bridge.ReadableMap;
11
10
  import com.google.gson.Gson;
11
+ import com.theoplayer.android.api.error.ErrorCode;
12
+ import com.theoplayer.android.api.error.THEOplayerException;
13
+ import com.theoplayer.android.api.event.ads.AdIntegrationKind;
12
14
  import com.theoplayer.android.api.player.track.texttrack.TextTrackKind;
15
+ import com.theoplayer.android.api.source.GoogleDaiTypedSource;
13
16
  import com.theoplayer.android.api.source.SourceDescription;
14
17
  import com.theoplayer.android.api.source.SourceType;
15
18
  import com.theoplayer.android.api.source.TextTrackDescription;
@@ -17,17 +20,12 @@ import com.theoplayer.android.api.source.TypedSource;
17
20
  import com.theoplayer.android.api.source.addescription.AdDescription;
18
21
  import com.theoplayer.android.api.source.addescription.GoogleImaAdDescription;
19
22
  import com.theoplayer.android.api.source.drm.DRMConfiguration;
20
- import com.theoplayer.android.api.source.drm.DRMIntegrationId;
21
- import com.theoplayer.android.api.source.drm.preintegration.AxinomDRMConfiguration;
22
- import com.theoplayer.android.api.source.drm.preintegration.AzureDRMConfiguration;
23
- import com.theoplayer.android.api.source.drm.preintegration.ConaxDRMConfiguration;
24
- import com.theoplayer.android.api.source.drm.preintegration.DRMTodayConfiguration;
25
- import com.theoplayer.android.api.source.drm.preintegration.IrdetoConfiguration;
26
- import com.theoplayer.android.api.source.drm.preintegration.KeyOSDRMConfiguration;
27
- import com.theoplayer.android.api.source.drm.preintegration.TitaniumDRMConfiguration;
28
- import com.theoplayer.android.api.source.drm.preintegration.VudrmDRMConfiguration;
29
- import com.theoplayer.android.api.source.drm.preintegration.XstreamConfiguration;
30
23
  import com.theoplayer.android.api.source.hls.HlsPlaybackConfiguration;
24
+ import com.theoplayer.android.api.source.ssai.SsaiIntegration;
25
+ import com.theoplayer.android.api.source.ssai.YoSpaceDescription;
26
+ import com.theoplayer.android.api.source.ssai.dai.GoogleDaiLiveConfiguration;
27
+ import com.theoplayer.android.api.source.ssai.dai.GoogleDaiVodConfiguration;
28
+ import com.theoplayer.drm.ContentProtectionAdapter;
31
29
 
32
30
  import org.json.JSONArray;
33
31
  import org.json.JSONException;
@@ -42,18 +40,35 @@ import java.util.Map;
42
40
  */
43
41
  public class SourceHelper {
44
42
 
45
- private static final String TAG = "SourceHelper";
46
-
47
43
  private static final String PROP_CONTENT_PROTECTION = "contentProtection";
48
- private static final String PROP_CONTENT_PROTECTION_INTEGRATION = "integration";
49
44
  private static final String PROP_LIVE_OFFSET = "liveOffset";
50
45
  private static final String PROP_HLS_DATERANGE = "hlsDateRange";
51
46
  private static final String PROP_HLS_PLAYBACK_CONFIG = "hls";
52
47
  private static final String PROP_TIME_SERVER = "timeServer";
48
+ public static final String PROP_SSAI = "ssai";
49
+ public static final String PROP_TYPE = "type";
50
+ public static final String PROP_SRC = "src";
51
+ public static final String PROP_SOURCES = "sources";
52
+ public static final String PROP_DEFAULT = "default";
53
+ public static final String PROP_LABEL = "label";
54
+ public static final String PROP_KIND = "kind";
55
+ public static final String PROP_TIME_OFFSET = "timeOffset";
56
+ public static final String PROP_INTEGRATION = "integration";
57
+ public static final String PROP_TEXT_TRACKS = "textTracks";
58
+ public static final String PROP_POSTER = "poster";
59
+ public static final String PROP_ADS = "ads";
60
+ public static final String PROP_AVAILABILITY_TYPE = "availabilityType";
61
+
62
+ private static final String ERROR_DAI_NOT_ENABLED = "Google DAI support not enabled.";
63
+ private static final String ERROR_UNSUPPORTED_SSAI_INTEGRATION = "Unsupported SSAI integration";
64
+ private static final String ERROR_MISSING_SSAI_INTEGRATION = "Missing SSAI integration";
65
+ private static final String ERROR_IMA_NOT_ENABLED = "Google IMA support not enabled.";
66
+ private static final String ERROR_UNSUPPORTED_CSAI_INTEGRATION = "Unsupported CSAI integration";
67
+ private static final String ERROR_MISSING_CSAI_INTEGRATION = "Missing CSAI integration";
53
68
 
54
69
  private final Gson gson = new Gson();
55
70
 
56
- public SourceDescription parseSourceFromJS(ReadableMap source) {
71
+ public SourceDescription parseSourceFromJS(ReadableMap source) throws THEOplayerException {
57
72
  HashMap<String, Object> hashmap = eliminateReadables(source);
58
73
  try {
59
74
  String json = gson.toJson(hashmap);
@@ -63,7 +78,7 @@ public class SourceHelper {
63
78
  ArrayList<TypedSource> typedSources = new ArrayList<>();
64
79
 
65
80
  // sources can be an array or single object
66
- JSONArray jsonSources = jsonSourceObject.optJSONArray("sources");
81
+ JSONArray jsonSources = jsonSourceObject.optJSONArray(PROP_SOURCES);
67
82
  if (jsonSources != null) {
68
83
  for (int i = 0 ; i < jsonSources.length(); i++) {
69
84
  TypedSource typedSource = parseTypedSource((JSONObject)jsonSources.get(i));
@@ -72,32 +87,29 @@ public class SourceHelper {
72
87
  }
73
88
  }
74
89
  } else {
75
- TypedSource typedSource = parseTypedSource(jsonSourceObject.getJSONObject("sources"));
90
+ TypedSource typedSource = parseTypedSource(jsonSourceObject.getJSONObject(PROP_SOURCES));
76
91
  if (typedSource != null) {
77
92
  typedSources.add(typedSource);
78
93
  }
79
94
  }
80
95
 
81
96
  // poster
82
- String poster = jsonSourceObject.optString("poster");
97
+ String poster = jsonSourceObject.optString(PROP_POSTER);
83
98
 
84
99
  // ads
85
- JSONArray jsonAds = jsonSourceObject.optJSONArray("ads");
100
+ JSONArray jsonAds = jsonSourceObject.optJSONArray(PROP_ADS);
86
101
  ArrayList<AdDescription> ads = new ArrayList<>();
87
102
  if (jsonAds != null) {
88
103
  for (int i = 0 ; i < jsonAds.length(); i++) {
89
104
  JSONObject jsonAdDescription = (JSONObject) jsonAds.get(i);
90
105
 
91
106
  // Currently only ima-ads are supported.
92
- GoogleImaAdDescription ad = parseImaAdFromJS(jsonAdDescription);
93
- if (ad != null) {
94
- ads.add(ad);
95
- }
107
+ ads.add(parseAdFromJS(jsonAdDescription));
96
108
  }
97
109
  }
98
110
 
99
111
  // Side-loaded text tracks
100
- JSONArray textTracks = jsonSourceObject.optJSONArray("textTracks");
112
+ JSONArray textTracks = jsonSourceObject.optJSONArray(PROP_TEXT_TRACKS);
101
113
  ArrayList<TextTrackDescription> sideLoadedTextTracks = new ArrayList<>();
102
114
  if (textTracks != null) {
103
115
  for (int i = 0 ; i < textTracks.length(); i++) {
@@ -119,11 +131,47 @@ public class SourceHelper {
119
131
  }
120
132
 
121
133
  @Nullable
122
- private TypedSource parseTypedSource(@NonNull final JSONObject jsonTypedSource) {
134
+ private TypedSource parseTypedSource(@NonNull final JSONObject jsonTypedSource) throws THEOplayerException {
123
135
  try {
136
+ TypedSource.Builder tsBuilder = TypedSource.Builder.typedSource();
124
137
  SourceType sourceType = parseSourceType(jsonTypedSource);
125
- String src = jsonTypedSource.getString("src");
126
- TypedSource.Builder tsBuilder = TypedSource.Builder.typedSource().src(src);
138
+
139
+ if (jsonTypedSource.has(PROP_SSAI)) {
140
+ final JSONObject ssaiJson = jsonTypedSource.getJSONObject(PROP_SSAI);
141
+
142
+ // Check for valid SsaiIntegration
143
+ final String ssaiIntegrationStr = ssaiJson.optString(PROP_INTEGRATION);
144
+ if (!TextUtils.isEmpty(ssaiIntegrationStr)) {
145
+ SsaiIntegration ssaiIntegration = SsaiIntegration.from(ssaiIntegrationStr);
146
+ if (ssaiIntegration == null) {
147
+ throw new THEOplayerException(ErrorCode.AD_ERROR, ERROR_UNSUPPORTED_SSAI_INTEGRATION + ": " + ssaiIntegrationStr);
148
+ }
149
+ switch (ssaiIntegration) {
150
+ case GOOGLE_DAI:
151
+ if (!BuildConfig.EXTENSION_GOOGLE_DAI) {
152
+ throw new THEOplayerException(ErrorCode.AD_ERROR, ERROR_DAI_NOT_ENABLED);
153
+ }
154
+ if (ssaiJson.optString(PROP_AVAILABILITY_TYPE).equals("vod")) {
155
+ tsBuilder = new GoogleDaiTypedSource.Builder(gson.fromJson(ssaiJson.toString(), GoogleDaiVodConfiguration.class));
156
+ } else {
157
+ tsBuilder = new GoogleDaiTypedSource.Builder(gson.fromJson(ssaiJson.toString(), GoogleDaiLiveConfiguration.class));
158
+ }
159
+ // Prefer DASH if not SSAI type specified
160
+ if (sourceType == null) {
161
+ tsBuilder.type(SourceType.DASH);
162
+ }
163
+ break;
164
+ case YOSPACE:
165
+ tsBuilder.ssai(gson.fromJson(ssaiJson.toString(), YoSpaceDescription.class));
166
+ break;
167
+ default:
168
+ throw new THEOplayerException(ErrorCode.AD_ERROR, ERROR_UNSUPPORTED_SSAI_INTEGRATION + ": " + ssaiIntegrationStr);
169
+ }
170
+ } else {
171
+ throw new THEOplayerException(ErrorCode.AD_ERROR, ERROR_MISSING_SSAI_INTEGRATION);
172
+ }
173
+ }
174
+ tsBuilder.src(jsonTypedSource.optString(PROP_SRC));
127
175
  if (sourceType != null) {
128
176
  tsBuilder.type(sourceType);
129
177
  }
@@ -142,54 +190,21 @@ public class SourceHelper {
142
190
  tsBuilder.timeServer(jsonTypedSource.getString(PROP_TIME_SERVER));
143
191
  }
144
192
  if (jsonTypedSource.has(PROP_CONTENT_PROTECTION)) {
145
- JSONObject contentProtection = jsonTypedSource.getJSONObject(PROP_CONTENT_PROTECTION);
146
-
147
- // Look for specific DRM pre-integration, otherwise use default.
148
- final String integration = contentProtection.optString(PROP_CONTENT_PROTECTION_INTEGRATION);
149
- DRMIntegrationId integrationId = null;
150
- if (!TextUtils.isEmpty(integration)) {
151
- integrationId = DRMIntegrationId.from(integration);
152
- if (integrationId == null) {
153
- Log.e(TAG, "ContentProtection integration not supported: " + integration);
154
- }
155
- }
156
- if (integrationId != null) {
157
- switch (integrationId) {
158
- case AXINOM:
159
- tsBuilder.drm(gson.fromJson(contentProtection.toString(), AxinomDRMConfiguration.class)); break;
160
- case AZURE:
161
- tsBuilder.drm(gson.fromJson(contentProtection.toString(), AzureDRMConfiguration.class)); break;
162
- case CONAX:
163
- tsBuilder.drm(gson.fromJson(contentProtection.toString(), ConaxDRMConfiguration.class)); break;
164
- case DRMTODAY:
165
- tsBuilder.drm(gson.fromJson(contentProtection.toString(), DRMTodayConfiguration.class)); break;
166
- case IRDETO:
167
- tsBuilder.drm(gson.fromJson(contentProtection.toString(), IrdetoConfiguration.class)); break;
168
- case KEYOS:
169
- tsBuilder.drm(gson.fromJson(contentProtection.toString(), KeyOSDRMConfiguration.class)); break;
170
- case TITANIUM:
171
- tsBuilder.drm(gson.fromJson(contentProtection.toString(), TitaniumDRMConfiguration.class)); break;
172
- case VUDRM:
173
- tsBuilder.drm(gson.fromJson(contentProtection.toString(), VudrmDRMConfiguration.class)); break;
174
- case XSTREAM:
175
- tsBuilder.drm(gson.fromJson(contentProtection.toString(), XstreamConfiguration.class)); break;
176
- default:
177
- Log.e(TAG, "ContentProtection integration not supported: " + integration);
178
- }
179
- } else {
180
- tsBuilder.drm(gson.fromJson(jsonTypedSource.get(PROP_CONTENT_PROTECTION).toString(), DRMConfiguration.class));
193
+ DRMConfiguration drmConfig =
194
+ ContentProtectionAdapter.INSTANCE.drmConfigurationFromJson(jsonTypedSource.getJSONObject(PROP_CONTENT_PROTECTION));
195
+ if (drmConfig != null) {
196
+ tsBuilder.drm(drmConfig);
181
197
  }
182
198
  }
183
199
  return tsBuilder.build();
184
- }
185
- catch(JSONException e) {
200
+ } catch (JSONException e) {
186
201
  e.printStackTrace();
187
202
  }
188
203
  return null;
189
204
  }
190
205
 
191
206
  private static SourceType parseSourceType(@NonNull final JSONObject jsonTypedSource) {
192
- String type = jsonTypedSource.optString("type");
207
+ String type = jsonTypedSource.optString(PROP_TYPE);
193
208
  if (!type.isEmpty()) {
194
209
  if ("application/dash+xml".equals(type)) {
195
210
  return SourceType.DASH;
@@ -211,7 +226,7 @@ public class SourceHelper {
211
226
  }
212
227
  } else {
213
228
  // No type given, check for known extension.
214
- String src = jsonTypedSource.optString("src");
229
+ String src = jsonTypedSource.optString(PROP_SRC);
215
230
  if (src.endsWith(".mpd")) {
216
231
  return SourceType.DASH;
217
232
  }
@@ -229,22 +244,64 @@ public class SourceHelper {
229
244
  }
230
245
 
231
246
  @Nullable
232
- private static GoogleImaAdDescription parseImaAdFromJS(JSONObject jsonAdDescription) throws JSONException {
233
- if (jsonAdDescription.optString("integration").equals("google-ima")) {
234
- return GoogleImaAdDescription.Builder.googleImaAdDescription()
235
- .source(jsonAdDescription.optString("sources"))
236
- .timeOffset(jsonAdDescription.optString("timeOffset"))
237
- .build();
247
+ public AdDescription parseAdFromJS(ReadableMap map) throws THEOplayerException {
248
+ HashMap<String, Object> hashmap = eliminateReadables(map);
249
+ try {
250
+ JSONObject jsonAdDescription = new JSONObject(gson.toJson(hashmap));
251
+ return parseAdFromJS(jsonAdDescription);
252
+ } catch(JSONException e) {
253
+ e.printStackTrace();
254
+ return null;
238
255
  }
239
- return null;
256
+ }
257
+
258
+ @NonNull
259
+ public static AdDescription parseAdFromJS(JSONObject jsonAdDescription) throws JSONException, THEOplayerException {
260
+ final String integrationKindStr = jsonAdDescription.optString(PROP_INTEGRATION);
261
+ if (!TextUtils.isEmpty(integrationKindStr)) {
262
+ AdIntegrationKind integrationKind = AdIntegrationKind.from(integrationKindStr);
263
+ switch (integrationKind) {
264
+ // Currently only IMA is supported.
265
+ case GOOGLE_IMA:
266
+ return parseImaAdFromJS(jsonAdDescription);
267
+ case DEFAULT:
268
+ case THEO:
269
+ case FREEWHEEL:
270
+ case SPOTX:
271
+ default: {
272
+ throw new THEOplayerException(ErrorCode.AD_ERROR, ERROR_UNSUPPORTED_CSAI_INTEGRATION + ": " + integrationKindStr);
273
+ }
274
+ }
275
+ } else {
276
+ throw new THEOplayerException(ErrorCode.AD_ERROR, ERROR_MISSING_CSAI_INTEGRATION + ": " + integrationKindStr);
277
+ }
278
+ }
279
+
280
+ @NonNull
281
+ private static GoogleImaAdDescription parseImaAdFromJS(JSONObject jsonAdDescription) throws THEOplayerException {
282
+ if (!BuildConfig.EXTENSION_GOOGLE_IMA) {
283
+ throw new THEOplayerException(ErrorCode.AD_ERROR, ERROR_IMA_NOT_ENABLED);
284
+ }
285
+ String source;
286
+ // Property `sources` is of type string | AdSource.
287
+ JSONObject sourceObj = jsonAdDescription.optJSONObject(PROP_SOURCES);
288
+ if (sourceObj != null) {
289
+ source = sourceObj.optString(PROP_SRC);
290
+ } else {
291
+ source = jsonAdDescription.optString(PROP_SOURCES);
292
+ }
293
+ return GoogleImaAdDescription.Builder.googleImaAdDescription()
294
+ .source(source)
295
+ .timeOffset(jsonAdDescription.optString(PROP_TIME_OFFSET))
296
+ .build();
240
297
  }
241
298
 
242
299
  private static TextTrackDescription parseTextTrackFromJS(JSONObject jsonTextTrack) throws JSONException {
243
300
  TextTrackDescription.Builder builder = TextTrackDescription.Builder.textTrackDescription()
244
- .isDefault(jsonTextTrack.optBoolean("default"))
245
- .src(jsonTextTrack.optString("src"))
246
- .label(jsonTextTrack.optString("label"))
247
- .kind(parseTextTrackKind(jsonTextTrack.optString("kind")));
301
+ .isDefault(jsonTextTrack.optBoolean(PROP_DEFAULT))
302
+ .src(jsonTextTrack.optString(PROP_SRC))
303
+ .label(jsonTextTrack.optString(PROP_LABEL))
304
+ .kind(parseTextTrackKind(jsonTextTrack.optString(PROP_KIND)));
248
305
  return builder.build();
249
306
  }
250
307
 
@@ -263,10 +320,7 @@ public class SourceHelper {
263
320
  }
264
321
 
265
322
  /**
266
- * Eliminate all the Readable* classes from the map
267
- *
268
- * @param readableMap
269
- * @return
323
+ * Eliminate all the Readable* classes from the map.
270
324
  */
271
325
  protected static HashMap<String, Object> eliminateReadables(ReadableMap readableMap) {
272
326
  HashMap<String, Object> hashMap = readableMap.toHashMap();
@@ -285,10 +339,7 @@ public class SourceHelper {
285
339
  }
286
340
 
287
341
  /**
288
- * Eliminate all the Readable* classes from the array
289
- *
290
- * @param readableArray
291
- * @return
342
+ * Eliminate all the Readable* classes from the array.
292
343
  */
293
344
  protected static ArrayList<Object> eliminateReadables(ReadableArray readableArray) {
294
345
  ArrayList<Object> arrayList = readableArray.toArrayList();
@@ -21,6 +21,7 @@ import android.util.Log;
21
21
  import android.view.View;
22
22
 
23
23
  import androidx.annotation.NonNull;
24
+ import androidx.annotation.Nullable;
24
25
  import androidx.annotation.StringDef;
25
26
 
26
27
  import com.facebook.react.bridge.Arguments;
@@ -28,12 +29,14 @@ import com.facebook.react.bridge.ReactContext;
28
29
  import com.facebook.react.bridge.WritableArray;
29
30
  import com.facebook.react.bridge.WritableMap;
30
31
  import com.facebook.react.uimanager.events.RCTEventEmitter;
32
+ import com.theoplayer.ads.AdEventAdapter;
31
33
  import com.theoplayer.android.api.error.THEOplayerException;
32
34
  import com.theoplayer.android.api.event.EventListener;
33
35
  import com.theoplayer.android.api.event.EventType;
34
36
  import com.theoplayer.android.api.event.player.DurationChangeEvent;
35
37
  import com.theoplayer.android.api.event.player.ErrorEvent;
36
38
  import com.theoplayer.android.api.event.player.LoadedMetadataEvent;
39
+ import com.theoplayer.android.api.event.player.PauseEvent;
37
40
  import com.theoplayer.android.api.event.player.ReadyStateChangeEvent;
38
41
  import com.theoplayer.android.api.event.player.SeekedEvent;
39
42
  import com.theoplayer.android.api.event.player.SeekingEvent;
@@ -52,6 +55,7 @@ import com.theoplayer.android.api.player.track.mediatrack.quality.VideoQuality;
52
55
  import com.theoplayer.android.api.player.track.texttrack.TextTrack;
53
56
  import com.theoplayer.track.TextTrackCueEventType;
54
57
  import com.theoplayer.track.TrackEventType;
58
+ import com.theoplayer.util.TypeUtils;
55
59
 
56
60
  import java.lang.annotation.Retention;
57
61
  import java.lang.annotation.RetentionPolicy;
@@ -59,7 +63,8 @@ import java.util.Date;
59
63
  import java.util.HashMap;
60
64
  import java.util.Map;
61
65
 
62
- class VideoEventEmitter {
66
+ @SuppressWarnings({"rawtypes", "unchecked"})
67
+ public class VideoEventEmitter {
63
68
 
64
69
  private static final String EVENT_SOURCECHANGE = "onNativeSourceChange";
65
70
  private static final String EVENT_LOADSTART = "onNativeLoadStart";
@@ -79,6 +84,7 @@ class VideoEventEmitter {
79
84
  private static final String EVENT_SEGMENTNOTFOUND = "onNativeSegmentNotFound";
80
85
  private static final String EVENT_TEXTTRACK_LIST_EVENT = "onNativeTextTrackListEvent";
81
86
  private static final String EVENT_TEXTTRACK_EVENT = "onNativeTextTrackEvent";
87
+ private static final String EVENT_AD_EVENT = "onNativeAdEvent";
82
88
  private static final String EVENT_FULLSCREEN_WILL_PRESENT = "onNativeFullscreenPlayerWillPresent";
83
89
  private static final String EVENT_FULLSCREEN_DID_PRESENT = "onNativeFullscreenPlayerDidPresent";
84
90
  private static final String EVENT_FULLSCREEN_WILL_DISMISS = "onNativeFullscreenPlayerWillDismiss";
@@ -105,6 +111,7 @@ class VideoEventEmitter {
105
111
  EVENT_SEGMENTNOTFOUND,
106
112
  EVENT_TEXTTRACK_LIST_EVENT,
107
113
  EVENT_TEXTTRACK_EVENT,
114
+ EVENT_AD_EVENT,
108
115
  EVENT_FULLSCREEN_WILL_PRESENT,
109
116
  EVENT_FULLSCREEN_DID_PRESENT,
110
117
  EVENT_FULLSCREEN_WILL_DISMISS,
@@ -131,12 +138,13 @@ class VideoEventEmitter {
131
138
  EVENT_SEGMENTNOTFOUND,
132
139
  EVENT_TEXTTRACK_LIST_EVENT,
133
140
  EVENT_TEXTTRACK_EVENT,
141
+ EVENT_AD_EVENT,
134
142
  EVENT_FULLSCREEN_WILL_PRESENT,
135
143
  EVENT_FULLSCREEN_DID_PRESENT,
136
144
  EVENT_FULLSCREEN_WILL_DISMISS,
137
145
  EVENT_FULLSCREEN_DID_DISMISS
138
146
  })
139
- @interface VideoEvents {
147
+ public @interface VideoEvents {
140
148
  }
141
149
 
142
150
  private static final String EVENT_PROP_CURRENT_TIME = "currentTime";
@@ -166,9 +174,9 @@ class VideoEventEmitter {
166
174
  private int viewId = View.NO_ID;
167
175
  private final HashMap<EventType, EventListener> playerListeners = new HashMap<>();
168
176
  private final HashMap<EventType, EventListener> textTrackListeners = new HashMap<>();
169
-
170
177
  private final ReactTHEOplayerView playerView;
171
178
 
179
+ private AdEventAdapter adEventAdapter;
172
180
  private long lastTimeUpdate = 0;
173
181
  private double lastCurrentTime = 0.0;
174
182
 
@@ -191,7 +199,7 @@ class VideoEventEmitter {
191
199
  playerListeners.put(PROGRESS, event -> onProgress());
192
200
  playerListeners.put(TIMEUPDATE, (EventListener<TimeUpdateEvent>) this::onTimeUpdate);
193
201
  playerListeners.put(DURATIONCHANGE, (EventListener<DurationChangeEvent>) this::onDurationChange);
194
- playerListeners.put(PAUSE, event -> receiveEvent(EVENT_PAUSE, null));
202
+ playerListeners.put(PAUSE, (EventListener<PauseEvent>) this::onPause);
195
203
  playerListeners.put(SEGMENTNOTFOUND, (EventListener<SegmentNotFoundEvent>) this::onSegmentNotFound);
196
204
 
197
205
  textTrackListeners.put(TextTrackListEventTypes.ADDTRACK, (EventListener<AddTrackEvent>) this::onTextTrackAdd);
@@ -202,6 +210,19 @@ class VideoEventEmitter {
202
210
  this.viewId = viewId;
203
211
  }
204
212
 
213
+ public void emitError(@NonNull THEOplayerException exception) {
214
+ emitError(exception.getCode().name(), exception.getMessage());
215
+ }
216
+
217
+ public void emitError(@NonNull String code, @Nullable String message) {
218
+ WritableMap error = Arguments.createMap();
219
+ error.putString(EVENT_PROP_ERROR_CODE, code);
220
+ error.putString(EVENT_PROP_ERROR_MESSAGE, message != null ? message : "");
221
+ WritableMap payload = Arguments.createMap();
222
+ payload.putMap(EVENT_PROP_ERROR, error);
223
+ receiveEvent(EVENT_ERROR, payload);
224
+ }
225
+
205
226
  private void onLoadedMetadata(final LoadedMetadataEvent event) {
206
227
  WritableMap payload = Arguments.createMap();
207
228
  payload.putArray(EVENT_PROP_TEXT_TRACKS, playerView.getTextTrackInfo());
@@ -255,6 +276,14 @@ class VideoEventEmitter {
255
276
  (timeUpdateRate == TimeUpdateRate.LIMITED_THREE_HZ && dt < 333);
256
277
  }
257
278
 
279
+ private void onPause(@NonNull final PauseEvent event) {
280
+ Player player = playerView.getPlayer();
281
+ // Do not forward the pause event in case the content player is paused because the ad player starts.
282
+ if (player != null && !playerView.getAdsApi().isPlaying()) {
283
+ receiveEvent(EVENT_PAUSE, null);
284
+ }
285
+ }
286
+
258
287
  private void onTimeUpdate(@NonNull final TimeUpdateEvent event) {
259
288
  final long now = System.currentTimeMillis();
260
289
  final double currentTime = event.getCurrentTime();
@@ -283,18 +312,12 @@ class VideoEventEmitter {
283
312
 
284
313
  private void onDurationChange(final @NonNull DurationChangeEvent event) {
285
314
  WritableMap payload = Arguments.createMap();
286
- payload.putDouble(EVENT_PROP_DURATION, 1e03 * event.getDuration());
315
+ payload.putDouble(EVENT_PROP_DURATION, TypeUtils.INSTANCE.encodeInfNan(1e03 * event.getDuration()));
287
316
  receiveEvent(EVENT_DURATIONCHANGE, payload);
288
317
  }
289
318
 
290
319
  private void onError(@NonNull final ErrorEvent event) {
291
- WritableMap error = Arguments.createMap();
292
- final THEOplayerException exception = event.getErrorObject();
293
- error.putString(EVENT_PROP_ERROR_CODE, exception.getCode().name());
294
- error.putString(EVENT_PROP_ERROR_MESSAGE, exception.getMessage());
295
- WritableMap payload = Arguments.createMap();
296
- payload.putMap(EVENT_PROP_ERROR, error);
297
- receiveEvent(EVENT_ERROR, payload);
320
+ emitError(event.getErrorObject());
298
321
  }
299
322
 
300
323
  private void onProgress() {
@@ -394,6 +417,11 @@ class VideoEventEmitter {
394
417
  for (Map.Entry<EventType, EventListener> entry : textTrackListeners.entrySet()) {
395
418
  player.getTextTracks().addEventListener(entry.getKey(), entry.getValue());
396
419
  }
420
+
421
+ // Attach AdStateHolder
422
+ if (BuildConfig.EXTENSION_ADS) {
423
+ adEventAdapter = new AdEventAdapter(playerView.getAdsApi(), payload -> receiveEvent(EVENT_AD_EVENT, payload));
424
+ }
397
425
  }
398
426
 
399
427
  public void removeListeners(@NonNull Player player) {
@@ -406,5 +434,9 @@ class VideoEventEmitter {
406
434
  for (Map.Entry<EventType, EventListener> entry : textTrackListeners.entrySet()) {
407
435
  player.getTextTracks().removeEventListener(entry.getKey(), entry.getValue());
408
436
  }
437
+
438
+ if (adEventAdapter != null) {
439
+ adEventAdapter.destroy();
440
+ }
409
441
  }
410
442
  }
@@ -0,0 +1,72 @@
1
+ package com.theoplayer.abr
2
+
3
+ import com.facebook.react.bridge.ReadableMap
4
+ import com.theoplayer.android.api.abr.AbrStrategyConfiguration
5
+ import com.theoplayer.android.api.abr.AbrStrategyMetadata
6
+ import com.theoplayer.android.api.abr.AbrStrategyType
7
+ import com.theoplayer.android.api.player.Player
8
+
9
+ object ABRConfigurationAdapter {
10
+ private const val PROP_TARGET_BUFFER = "targetBuffer"
11
+ private const val PROP_STRATEGY = "strategy"
12
+ private const val PROP_METADATA = "metadata"
13
+ private const val PROP_TYPE = "type"
14
+ private const val PROP_BITRATE = "bitrate"
15
+
16
+ fun applyABRConfigurationFromProps(player: Player?, abrProps: ReadableMap?) {
17
+ if (abrProps == null || player == null) {
18
+ return
19
+ }
20
+ if (abrProps.hasKey(PROP_TARGET_BUFFER)) {
21
+ player.abr.targetBuffer = abrProps.getInt(PROP_TARGET_BUFFER)
22
+ }
23
+ // Strategy can be either a string or an object
24
+ try {
25
+ val abrStrategyPropsString = abrProps.getString(PROP_STRATEGY)
26
+ if (abrStrategyPropsString != null) {
27
+ AbrStrategyConfiguration.Builder().apply {
28
+ abrStrategyTypeFromString(abrStrategyPropsString)?.let { type ->
29
+ setType(type)
30
+ }
31
+ player.abr.abrStrategy = build()
32
+ }
33
+ }
34
+ } catch (_: Exception) {
35
+ }
36
+ try {
37
+ val abrStrategyPropsMap = abrProps.getMap(PROP_STRATEGY)
38
+ if (abrStrategyPropsMap != null) {
39
+ AbrStrategyConfiguration.Builder().apply {
40
+ abrMetadataFromProps(abrStrategyPropsMap.getMap(PROP_METADATA))?.let { metadata ->
41
+ setMetadata(metadata)
42
+ }
43
+ abrStrategyTypeFromString(abrStrategyPropsMap.getString(PROP_TYPE))?.let { type ->
44
+ setType(type)
45
+ }
46
+ player.abr.abrStrategy = build()
47
+ }
48
+ }
49
+ } catch (_: Exception) {
50
+ }
51
+ }
52
+
53
+ private fun abrMetadataFromProps(props: ReadableMap?): AbrStrategyMetadata? {
54
+ if (props == null) {
55
+ return null
56
+ }
57
+ val builder = AbrStrategyMetadata.Builder()
58
+ if (props.hasKey(PROP_BITRATE)) {
59
+ builder.setBitrate(props.getInt(PROP_BITRATE))
60
+ }
61
+ return builder.build()
62
+ }
63
+
64
+ private fun abrStrategyTypeFromString(type: String?): AbrStrategyType? {
65
+ return when (type) {
66
+ "performance" -> AbrStrategyType.PERFORMANCE
67
+ "quality" -> AbrStrategyType.QUALITY
68
+ "bandwidth" -> AbrStrategyType.BANDWIDTH
69
+ else -> return null
70
+ }
71
+ }
72
+ }
@@ -0,0 +1,92 @@
1
+ package com.theoplayer.ads;
2
+
3
+ import com.facebook.react.bridge.Arguments;
4
+ import com.facebook.react.bridge.WritableMap;
5
+ import com.theoplayer.android.api.ads.wrapper.AdEventListener;
6
+ import com.theoplayer.android.api.ads.wrapper.AdsApiWrapper;
7
+ import com.theoplayer.android.api.ads.Ad;
8
+ import com.theoplayer.android.api.ads.AdBreak;
9
+ import com.theoplayer.android.api.ads.ima.GoogleImaAdEventType;
10
+ import com.theoplayer.android.api.event.EventType;
11
+ import com.theoplayer.android.api.event.ads.AdEvent;
12
+
13
+ public class AdEventAdapter {
14
+ private final AdsApiWrapper adsApi;
15
+ private final AdEventListener eventListener;
16
+
17
+ private static final String EVENT_PROP_AD = "ad";
18
+ private static final String EVENT_PROP_TYPE = "type";
19
+
20
+ private final static GoogleImaAdEventType[] ALL_AD_EVENTS = {
21
+ GoogleImaAdEventType.LOADED,
22
+ GoogleImaAdEventType.AD_BREAK_STARTED,
23
+ GoogleImaAdEventType.STARTED,
24
+ GoogleImaAdEventType.FIRST_QUARTILE,
25
+ GoogleImaAdEventType.MIDPOINT,
26
+ GoogleImaAdEventType.THIRD_QUARTILE,
27
+ GoogleImaAdEventType.COMPLETED,
28
+ GoogleImaAdEventType.AD_BREAK_ENDED,
29
+ GoogleImaAdEventType.SKIPPED,
30
+ GoogleImaAdEventType.AD_ERROR,
31
+ GoogleImaAdEventType.AD_BUFFERING,
32
+ GoogleImaAdEventType.AD_BREAK_FETCH_ERROR
33
+ };
34
+
35
+ public interface AdEventEmitter {
36
+ void emit(WritableMap payload);
37
+ }
38
+
39
+ public AdEventAdapter(AdsApiWrapper adsApi, AdEventEmitter eventEmitter) {
40
+ this.adsApi = adsApi;
41
+
42
+ eventListener = new AdEventListener() {
43
+ @Override
44
+ public <E extends AdEvent<?>> void onAdEvent(EventType<E> eventType, Ad ad) {
45
+ WritableMap payload = Arguments.createMap();
46
+ payload.putString(EVENT_PROP_TYPE, mapAdType(eventType));
47
+ if (ad != null) {
48
+ payload.putMap(EVENT_PROP_AD, AdInfo.fromAd(ad));
49
+ }
50
+ eventEmitter.emit(payload);
51
+ }
52
+
53
+ @Override
54
+ public <E extends AdEvent<?>> void onAdBreakEvent(EventType<E> eventType, AdBreak adBreak) {
55
+ WritableMap payload = Arguments.createMap();
56
+ payload.putString(EVENT_PROP_TYPE, mapAdType(eventType));
57
+ if (adBreak != null) {
58
+ payload.putMap(EVENT_PROP_AD, AdInfo.fromAdBreak(adBreak));
59
+ }
60
+ eventEmitter.emit(payload);
61
+ }
62
+ };
63
+
64
+ for (GoogleImaAdEventType eventType: ALL_AD_EVENTS) {
65
+ adsApi.addEventListener(eventType, eventListener);
66
+ }
67
+ }
68
+
69
+ private String mapAdType(EventType<?> eventType) {
70
+ switch ((GoogleImaAdEventType)eventType) {
71
+ case LOADED: return "adloaded";
72
+ case STARTED: return "adbegin";
73
+ case FIRST_QUARTILE: return "adfirstquartile";
74
+ case MIDPOINT: return "admidpoint";
75
+ case THIRD_QUARTILE: return "adthirdquartile";
76
+ case COMPLETED: return "adend";
77
+ case SKIPPED: return "adskip";
78
+ case AD_ERROR: return "aderror";
79
+ case AD_BUFFERING: return "adbuffering";
80
+ case AD_BREAK_STARTED: return "adbreakbegin";
81
+ case AD_BREAK_ENDED: return "adbreakend";
82
+ case AD_BREAK_FETCH_ERROR: return "aderror";
83
+ default: return eventType.getName().toLowerCase();
84
+ }
85
+ }
86
+
87
+ public void destroy() {
88
+ for (GoogleImaAdEventType eventType: ALL_AD_EVENTS) {
89
+ adsApi.removeEventListener(eventType, eventListener);
90
+ }
91
+ }
92
+ }