react-native-theoplayer 2.16.1 → 3.0.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 (316) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/README.md +1 -0
  3. package/android/build.gradle +19 -22
  4. package/android/src/main/java/com/theoplayer/PlayerConfigAdapter.kt +87 -101
  5. package/android/src/main/java/com/theoplayer/ReactTHEOplayerContext.kt +30 -30
  6. package/android/src/main/java/com/theoplayer/ReactTHEOplayerPackage.kt +3 -1
  7. package/android/src/main/java/com/theoplayer/ReactTHEOplayerView.kt +1 -1
  8. package/android/src/main/java/com/theoplayer/cache/CacheAdapter.kt +127 -0
  9. package/android/src/main/java/com/theoplayer/cache/CacheModule.kt +238 -0
  10. package/android/src/main/java/com/theoplayer/player/PlayerModule.kt +27 -12
  11. package/android/src/main/java/com/theoplayer/source/SourceAdapter.kt +16 -37
  12. package/android/src/main/java/com/theoplayer/util/BridgeUtils.kt +60 -0
  13. package/android/src/main/java/com/theoplayer/util/PayloadBuilder.kt +10 -10
  14. package/ios/THEOplayerRCTBridge.m +22 -0
  15. package/ios/THEOplayerRCTDebug.swift +7 -1
  16. package/ios/THEOplayerRCTMainEventHandler.swift +25 -27
  17. package/ios/THEOplayerRCTSourceDescriptionAggregator.swift +41 -0
  18. package/ios/THEOplayerRCTSourceDescriptionBuilder.swift +3 -2
  19. package/ios/THEOplayerRCTTypeUtils.swift +37 -0
  20. package/ios/THEOplayerRCTView.swift +1 -2
  21. package/ios/ads/THEOplayerRCTAdsAPI+DAI.swift +3 -13
  22. package/ios/ads/THEOplayerRCTAdsAPI.swift +14 -48
  23. package/ios/ads/THEOplayerRCTView+AdsConfig.swift +0 -13
  24. package/ios/backgroundAudio/THEOplayerRCTNowPlayingManager.swift +24 -36
  25. package/ios/backgroundAudio/THEOplayerRCTRemoteCommandsManager.swift +2 -10
  26. package/ios/cache/THEOplayerRCTCacheAPI.swift +203 -0
  27. package/ios/cache/THEOplayerRCTCacheAggregator.swift +87 -0
  28. package/ios/cache/THEOplayerRCTCachingParametersBuilder.swift +27 -0
  29. package/ios/pip/THEOplayerRCTPipControlsManager.swift +2 -4
  30. package/lib/commonjs/api/abr/ABRConfiguration.js +21 -7
  31. package/lib/commonjs/api/abr/ABRConfiguration.js.map +1 -1
  32. package/lib/commonjs/api/ads/GoogleImaConfiguration.js.map +1 -1
  33. package/lib/commonjs/api/barrel.js +30 -19
  34. package/lib/commonjs/api/barrel.js.map +1 -1
  35. package/lib/commonjs/api/cache/CachingPreferredTrackSelection.js +2 -0
  36. package/lib/commonjs/api/cache/CachingPreferredTrackSelection.js.map +1 -0
  37. package/lib/commonjs/api/cache/CachingTask.js +30 -0
  38. package/lib/commonjs/api/cache/CachingTask.js.map +1 -0
  39. package/lib/commonjs/api/cache/CachingTaskLicense.js +6 -0
  40. package/lib/commonjs/api/cache/CachingTaskLicense.js.map +1 -0
  41. package/lib/commonjs/api/cache/CachingTaskList.js +6 -0
  42. package/lib/commonjs/api/cache/CachingTaskList.js.map +1 -0
  43. package/lib/commonjs/api/cache/CachingTaskParameters.js +6 -0
  44. package/lib/commonjs/api/cache/CachingTaskParameters.js.map +1 -0
  45. package/lib/commonjs/api/cache/MediaCacheAPI.js +24 -0
  46. package/lib/commonjs/api/cache/MediaCacheAPI.js.map +1 -0
  47. package/lib/commonjs/api/cache/barrel.js +83 -0
  48. package/lib/commonjs/api/cache/barrel.js.map +1 -0
  49. package/lib/commonjs/api/cache/events/CacheEvent.js +28 -0
  50. package/lib/commonjs/api/cache/events/CacheEvent.js.map +1 -0
  51. package/lib/commonjs/api/cache/events/CachingTaskEvent.js +17 -0
  52. package/lib/commonjs/api/cache/events/CachingTaskEvent.js.map +1 -0
  53. package/lib/commonjs/api/cache/events/barrel.js +28 -0
  54. package/lib/commonjs/api/cache/events/barrel.js.map +1 -0
  55. package/lib/commonjs/api/cache/hooks/barrel.js +39 -0
  56. package/lib/commonjs/api/cache/hooks/barrel.js.map +1 -0
  57. package/lib/commonjs/api/cache/hooks/useCachingTaskList.js +31 -0
  58. package/lib/commonjs/api/cache/hooks/useCachingTaskList.js.map +1 -0
  59. package/lib/commonjs/api/cache/hooks/useCachingTaskProgress.js +28 -0
  60. package/lib/commonjs/api/cache/hooks/useCachingTaskProgress.js.map +1 -0
  61. package/lib/commonjs/api/cache/hooks/useCachingTaskStatus.js +28 -0
  62. package/lib/commonjs/api/cache/hooks/useCachingTaskStatus.js.map +1 -0
  63. package/lib/commonjs/api/cast/CastState.js +3 -4
  64. package/lib/commonjs/api/cast/CastState.js.map +1 -1
  65. package/lib/commonjs/api/config/PlayerConfiguration.js.map +1 -1
  66. package/lib/commonjs/api/event/AdEvent.js +3 -4
  67. package/lib/commonjs/api/event/AdEvent.js.map +1 -1
  68. package/lib/commonjs/api/event/CastEvent.js +3 -4
  69. package/lib/commonjs/api/event/CastEvent.js.map +1 -1
  70. package/lib/commonjs/api/event/PlayerEvent.js +3 -4
  71. package/lib/commonjs/api/event/PlayerEvent.js.map +1 -1
  72. package/lib/commonjs/api/event/TrackEvent.js +12 -16
  73. package/lib/commonjs/api/event/TrackEvent.js.map +1 -1
  74. package/lib/commonjs/api/player/PlayerEventMap.js +7 -8
  75. package/lib/commonjs/api/player/PlayerEventMap.js.map +1 -1
  76. package/lib/commonjs/api/player/THEOplayer.js +6 -4
  77. package/lib/commonjs/api/player/THEOplayer.js.map +1 -1
  78. package/lib/commonjs/api/presentation/PresentationMode.js +3 -4
  79. package/lib/commonjs/api/presentation/PresentationMode.js.map +1 -1
  80. package/lib/commonjs/api/source/ads/Ads.js +3 -4
  81. package/lib/commonjs/api/source/ads/Ads.js.map +1 -1
  82. package/lib/commonjs/api/track/TextTrack.js +9 -12
  83. package/lib/commonjs/api/track/TextTrack.js.map +1 -1
  84. package/lib/commonjs/api/track/TextTrackStyle.js +3 -4
  85. package/lib/commonjs/api/track/TextTrackStyle.js.map +1 -1
  86. package/lib/commonjs/index.js +9 -1
  87. package/lib/commonjs/index.js.map +1 -1
  88. package/lib/commonjs/internal/THEOplayerView.js +1 -1
  89. package/lib/commonjs/internal/THEOplayerView.js.map +1 -1
  90. package/lib/commonjs/internal/THEOplayerView.style.js +1 -2
  91. package/lib/commonjs/internal/THEOplayerView.style.js.map +1 -1
  92. package/lib/commonjs/internal/THEOplayerView.web.js +5 -5
  93. package/lib/commonjs/internal/THEOplayerView.web.js.map +1 -1
  94. package/lib/commonjs/internal/adapter/THEOplayerAdapter.js.map +1 -1
  95. package/lib/commonjs/internal/adapter/THEOplayerWebAdapter.js +12 -13
  96. package/lib/commonjs/internal/adapter/THEOplayerWebAdapter.js.map +1 -1
  97. package/lib/commonjs/internal/adapter/WebEventForwarder.js +10 -10
  98. package/lib/commonjs/internal/adapter/WebEventForwarder.js.map +1 -1
  99. package/lib/commonjs/internal/adapter/abr/AbrAdapter.js.map +1 -1
  100. package/lib/commonjs/internal/adapter/ads/THEOplayerWebAdsAdapter.js +2 -2
  101. package/lib/commonjs/internal/adapter/ads/THEOplayerWebAdsAdapter.js.map +1 -1
  102. package/lib/commonjs/internal/adapter/cast/THEOplayerNativeCastAdapter.js +1 -1
  103. package/lib/commonjs/internal/adapter/cast/THEOplayerNativeCastAdapter.js.map +1 -1
  104. package/lib/commonjs/internal/adapter/cast/THEOplayerWebCastAdapter.js.map +1 -1
  105. package/lib/commonjs/internal/adapter/event/BaseEvent.js.map +1 -1
  106. package/lib/commonjs/internal/adapter/event/DefaultEventDispatcher.js +1 -1
  107. package/lib/commonjs/internal/adapter/event/DefaultEventDispatcher.js.map +1 -1
  108. package/lib/commonjs/internal/adapter/event/native/NativeTrackEvent.js +12 -16
  109. package/lib/commonjs/internal/adapter/event/native/NativeTrackEvent.js.map +1 -1
  110. package/lib/commonjs/internal/adapter/track/TextTrackStyleAdapter.js.map +1 -1
  111. package/lib/commonjs/internal/adapter/web/FullscreenAPI.js +1 -2
  112. package/lib/commonjs/internal/adapter/web/FullscreenAPI.js.map +1 -1
  113. package/lib/commonjs/internal/adapter/web/WebMediaSession.js +9 -11
  114. package/lib/commonjs/internal/adapter/web/WebMediaSession.js.map +1 -1
  115. package/lib/commonjs/internal/adapter/web/WebPresentationModeManager.js +4 -4
  116. package/lib/commonjs/internal/adapter/web/WebPresentationModeManager.js.map +1 -1
  117. package/lib/commonjs/internal/cache/MediaCache.js +117 -0
  118. package/lib/commonjs/internal/cache/MediaCache.js.map +1 -0
  119. package/lib/commonjs/internal/cache/MediaCache.web.js +54 -0
  120. package/lib/commonjs/internal/cache/MediaCache.web.js.map +1 -0
  121. package/lib/commonjs/internal/cache/NativeCachingTaskAdapter.js +59 -0
  122. package/lib/commonjs/internal/cache/NativeCachingTaskAdapter.js.map +1 -0
  123. package/lib/commonjs/internal/cache/NativeCachingTaskParametersAdapter.js +27 -0
  124. package/lib/commonjs/internal/cache/NativeCachingTaskParametersAdapter.js.map +1 -0
  125. package/lib/commonjs/internal/cache/WebCachingTaskAdapter.js +71 -0
  126. package/lib/commonjs/internal/cache/WebCachingTaskAdapter.js.map +1 -0
  127. package/lib/commonjs/internal/drm/ContentProtectionRegistry.js +1 -2
  128. package/lib/commonjs/internal/drm/ContentProtectionRegistry.js.map +1 -1
  129. package/lib/commonjs/internal/drm/ContentProtectionRegistry.web.js +1 -2
  130. package/lib/commonjs/internal/drm/ContentProtectionRegistry.web.js.map +1 -1
  131. package/lib/commonjs/internal/drm/NativeCertificateResponse.js.map +1 -1
  132. package/lib/commonjs/internal/drm/NativeLicenseResponse.js.map +1 -1
  133. package/lib/commonjs/internal/utils/TypeUtils.js +2 -4
  134. package/lib/commonjs/internal/utils/TypeUtils.js.map +1 -1
  135. package/lib/module/api/abr/ABRConfiguration.js +24 -6
  136. package/lib/module/api/abr/ABRConfiguration.js.map +1 -1
  137. package/lib/module/api/ads/GoogleImaConfiguration.js.map +1 -1
  138. package/lib/module/api/barrel.js +1 -0
  139. package/lib/module/api/barrel.js.map +1 -1
  140. package/lib/module/api/cache/CachingPreferredTrackSelection.js +2 -0
  141. package/lib/module/api/cache/CachingPreferredTrackSelection.js.map +1 -0
  142. package/lib/module/api/cache/CachingTask.js +25 -0
  143. package/lib/module/api/cache/CachingTask.js.map +1 -0
  144. package/lib/module/api/cache/CachingTaskLicense.js +2 -0
  145. package/lib/module/api/cache/CachingTaskLicense.js.map +1 -0
  146. package/lib/module/api/cache/CachingTaskList.js +2 -0
  147. package/lib/module/api/cache/CachingTaskList.js.map +1 -0
  148. package/lib/module/api/cache/CachingTaskParameters.js +2 -0
  149. package/lib/module/api/cache/CachingTaskParameters.js.map +1 -0
  150. package/lib/module/api/cache/MediaCacheAPI.js +19 -0
  151. package/lib/module/api/cache/MediaCacheAPI.js.map +1 -0
  152. package/lib/module/api/cache/barrel.js +8 -0
  153. package/lib/module/api/cache/barrel.js.map +1 -0
  154. package/lib/module/api/cache/events/CacheEvent.js +25 -0
  155. package/lib/module/api/cache/events/CacheEvent.js.map +1 -0
  156. package/lib/module/api/cache/events/CachingTaskEvent.js +12 -0
  157. package/lib/module/api/cache/events/CachingTaskEvent.js.map +1 -0
  158. package/lib/module/api/cache/events/barrel.js +3 -0
  159. package/lib/module/api/cache/events/barrel.js.map +1 -0
  160. package/lib/module/api/cache/hooks/barrel.js +4 -0
  161. package/lib/module/api/cache/hooks/barrel.js.map +1 -0
  162. package/lib/module/api/cache/hooks/useCachingTaskList.js +24 -0
  163. package/lib/module/api/cache/hooks/useCachingTaskList.js.map +1 -0
  164. package/lib/module/api/cache/hooks/useCachingTaskProgress.js +21 -0
  165. package/lib/module/api/cache/hooks/useCachingTaskProgress.js.map +1 -0
  166. package/lib/module/api/cache/hooks/useCachingTaskStatus.js +21 -0
  167. package/lib/module/api/cache/hooks/useCachingTaskStatus.js.map +1 -0
  168. package/lib/module/api/cast/CastState.js +3 -3
  169. package/lib/module/api/cast/CastState.js.map +1 -1
  170. package/lib/module/api/config/PlayerConfiguration.js.map +1 -1
  171. package/lib/module/api/event/AdEvent.js +3 -3
  172. package/lib/module/api/event/AdEvent.js.map +1 -1
  173. package/lib/module/api/event/CastEvent.js +3 -3
  174. package/lib/module/api/event/CastEvent.js.map +1 -1
  175. package/lib/module/api/event/PlayerEvent.js +3 -3
  176. package/lib/module/api/event/PlayerEvent.js.map +1 -1
  177. package/lib/module/api/event/TrackEvent.js +12 -12
  178. package/lib/module/api/event/TrackEvent.js.map +1 -1
  179. package/lib/module/api/player/PlayerEventMap.js +8 -8
  180. package/lib/module/api/player/PlayerEventMap.js.map +1 -1
  181. package/lib/module/api/player/THEOplayer.js +7 -3
  182. package/lib/module/api/player/THEOplayer.js.map +1 -1
  183. package/lib/module/api/presentation/PresentationMode.js +3 -3
  184. package/lib/module/api/presentation/PresentationMode.js.map +1 -1
  185. package/lib/module/api/source/ads/Ads.js +3 -3
  186. package/lib/module/api/source/ads/Ads.js.map +1 -1
  187. package/lib/module/api/track/TextTrack.js +9 -9
  188. package/lib/module/api/track/TextTrack.js.map +1 -1
  189. package/lib/module/api/track/TextTrackStyle.js +3 -3
  190. package/lib/module/api/track/TextTrackStyle.js.map +1 -1
  191. package/lib/module/index.js +1 -0
  192. package/lib/module/index.js.map +1 -1
  193. package/lib/module/internal/THEOplayerView.js +1 -1
  194. package/lib/module/internal/THEOplayerView.js.map +1 -1
  195. package/lib/module/internal/THEOplayerView.web.js +5 -5
  196. package/lib/module/internal/THEOplayerView.web.js.map +1 -1
  197. package/lib/module/internal/adapter/THEOplayerAdapter.js.map +1 -1
  198. package/lib/module/internal/adapter/THEOplayerWebAdapter.js +12 -11
  199. package/lib/module/internal/adapter/THEOplayerWebAdapter.js.map +1 -1
  200. package/lib/module/internal/adapter/WebEventForwarder.js +10 -10
  201. package/lib/module/internal/adapter/WebEventForwarder.js.map +1 -1
  202. package/lib/module/internal/adapter/abr/AbrAdapter.js.map +1 -1
  203. package/lib/module/internal/adapter/ads/THEOplayerWebAdsAdapter.js +2 -2
  204. package/lib/module/internal/adapter/ads/THEOplayerWebAdsAdapter.js.map +1 -1
  205. package/lib/module/internal/adapter/cast/THEOplayerNativeCastAdapter.js +1 -1
  206. package/lib/module/internal/adapter/cast/THEOplayerNativeCastAdapter.js.map +1 -1
  207. package/lib/module/internal/adapter/cast/THEOplayerWebCastAdapter.js.map +1 -1
  208. package/lib/module/internal/adapter/event/BaseEvent.js.map +1 -1
  209. package/lib/module/internal/adapter/event/DefaultEventDispatcher.js +1 -1
  210. package/lib/module/internal/adapter/event/DefaultEventDispatcher.js.map +1 -1
  211. package/lib/module/internal/adapter/event/native/NativeTrackEvent.js +12 -12
  212. package/lib/module/internal/adapter/event/native/NativeTrackEvent.js.map +1 -1
  213. package/lib/module/internal/adapter/track/TextTrackStyleAdapter.js.map +1 -1
  214. package/lib/module/internal/adapter/web/FullscreenAPI.js.map +1 -1
  215. package/lib/module/internal/adapter/web/WebMediaSession.js +8 -9
  216. package/lib/module/internal/adapter/web/WebMediaSession.js.map +1 -1
  217. package/lib/module/internal/adapter/web/WebPresentationModeManager.js +4 -4
  218. package/lib/module/internal/adapter/web/WebPresentationModeManager.js.map +1 -1
  219. package/lib/module/internal/cache/MediaCache.js +110 -0
  220. package/lib/module/internal/cache/MediaCache.js.map +1 -0
  221. package/lib/module/internal/cache/MediaCache.web.js +45 -0
  222. package/lib/module/internal/cache/MediaCache.web.js.map +1 -0
  223. package/lib/module/internal/cache/NativeCachingTaskAdapter.js +52 -0
  224. package/lib/module/internal/cache/NativeCachingTaskAdapter.js.map +1 -0
  225. package/lib/module/internal/cache/NativeCachingTaskParametersAdapter.js +20 -0
  226. package/lib/module/internal/cache/NativeCachingTaskParametersAdapter.js.map +1 -0
  227. package/lib/module/internal/cache/WebCachingTaskAdapter.js +64 -0
  228. package/lib/module/internal/cache/WebCachingTaskAdapter.js.map +1 -0
  229. package/lib/module/internal/drm/ContentProtectionRegistry.js.map +1 -1
  230. package/lib/module/internal/drm/ContentProtectionRegistry.web.js.map +1 -1
  231. package/lib/module/internal/drm/NativeCertificateResponse.js.map +1 -1
  232. package/lib/module/internal/drm/NativeLicenseResponse.js.map +1 -1
  233. package/lib/typescript/api/abr/ABRConfiguration.d.ts +1 -1
  234. package/lib/typescript/api/ads/Ad.d.ts +2 -2
  235. package/lib/typescript/api/ads/AdsConfiguration.d.ts +2 -2
  236. package/lib/typescript/api/ads/GoogleImaConfiguration.d.ts +1 -0
  237. package/lib/typescript/api/barrel.d.ts +1 -0
  238. package/lib/typescript/api/cache/CachingPreferredTrackSelection.d.ts +23 -0
  239. package/lib/typescript/api/cache/CachingTask.d.ts +93 -0
  240. package/lib/typescript/api/cache/CachingTaskLicense.d.ts +14 -0
  241. package/lib/typescript/api/cache/CachingTaskList.d.ts +7 -0
  242. package/lib/typescript/api/cache/CachingTaskParameters.d.ts +57 -0
  243. package/lib/typescript/api/cache/MediaCacheAPI.d.ts +39 -0
  244. package/lib/typescript/api/cache/barrel.d.ts +7 -0
  245. package/lib/typescript/api/cache/events/CacheEvent.d.ts +55 -0
  246. package/lib/typescript/api/cache/events/CachingTaskEvent.d.ts +22 -0
  247. package/lib/typescript/api/cache/events/barrel.d.ts +2 -0
  248. package/lib/typescript/api/cache/hooks/barrel.d.ts +3 -0
  249. package/lib/typescript/api/cache/hooks/useCachingTaskList.d.ts +1 -0
  250. package/lib/typescript/api/cache/hooks/useCachingTaskProgress.d.ts +2 -0
  251. package/lib/typescript/api/cache/hooks/useCachingTaskStatus.d.ts +2 -0
  252. package/lib/typescript/api/cast/CastConfiguration.d.ts +1 -1
  253. package/lib/typescript/api/config/PlayerConfiguration.d.ts +4 -1
  254. package/lib/typescript/api/drm/ContentProtectionIntegration.d.ts +2 -2
  255. package/lib/typescript/api/drm/ContentProtectionRequest.d.ts +1 -1
  256. package/lib/typescript/api/error/ChromecastError.d.ts +1 -1
  257. package/lib/typescript/api/event/CastEvent.d.ts +1 -1
  258. package/lib/typescript/api/event/EventDispatcher.d.ts +2 -2
  259. package/lib/typescript/api/event/EventListener.d.ts +1 -1
  260. package/lib/typescript/api/player/THEOplayer.d.ts +2 -2
  261. package/lib/typescript/api/source/SourceDescription.d.ts +3 -3
  262. package/lib/typescript/api/source/ads/Ads.d.ts +1 -1
  263. package/lib/typescript/api/source/ads/FreeWheelAdDescription.d.ts +1 -1
  264. package/lib/typescript/api/source/ads/ssai/GoogleDAIConfiguration.d.ts +2 -2
  265. package/lib/typescript/api/source/ads/ssai/ImagineServerSideAdInsertionConfiguration.d.ts +1 -1
  266. package/lib/typescript/api/source/ads/ssai/ServerSideAdInsertionConfiguration.d.ts +1 -1
  267. package/lib/typescript/api/source/ads/ssai/YospaceServerSideAdInsertionConfiguration.d.ts +2 -2
  268. package/lib/typescript/api/source/dash/DashPlaybackConfiguration.d.ts +1 -1
  269. package/lib/typescript/api/source/drm/DRMConfiguration.d.ts +3 -3
  270. package/lib/typescript/api/source/hls/HlsPlaybackConfiguration.d.ts +1 -1
  271. package/lib/typescript/api/track/MediaTrack.d.ts +1 -1
  272. package/lib/typescript/index.d.ts +1 -0
  273. package/lib/typescript/internal/THEOplayerView.web.d.ts +1 -1
  274. package/lib/typescript/internal/adapter/THEOplayerWebAdapter.d.ts +2 -2
  275. package/lib/typescript/internal/adapter/WebEventForwarder.d.ts +2 -2
  276. package/lib/typescript/internal/adapter/ads/THEOplayerWebAdsAdapter.d.ts +2 -2
  277. package/lib/typescript/internal/adapter/cast/THEOplayerWebCastAdapter.d.ts +2 -2
  278. package/lib/typescript/internal/adapter/event/native/NativeCastEvent.d.ts +1 -1
  279. package/lib/typescript/internal/adapter/web/WebPresentationModeManager.d.ts +2 -2
  280. package/lib/typescript/internal/cache/MediaCache.d.ts +25 -0
  281. package/lib/typescript/internal/cache/MediaCache.web.d.ts +16 -0
  282. package/lib/typescript/internal/cache/NativeCachingTaskAdapter.d.ts +33 -0
  283. package/lib/typescript/internal/cache/NativeCachingTaskParametersAdapter.d.ts +11 -0
  284. package/lib/typescript/internal/cache/WebCachingTaskAdapter.d.ts +25 -0
  285. package/package.json +16 -15
  286. package/react-native-theoplayer.podspec +5 -5
  287. package/src/api/ads/GoogleImaConfiguration.ts +1 -0
  288. package/src/api/barrel.ts +1 -0
  289. package/src/api/cache/CachingPreferredTrackSelection.ts +24 -0
  290. package/src/api/cache/CachingTask.ts +107 -0
  291. package/src/api/cache/CachingTaskLicense.ts +15 -0
  292. package/src/api/cache/CachingTaskList.ts +8 -0
  293. package/src/api/cache/CachingTaskParameters.ts +62 -0
  294. package/src/api/cache/MediaCacheAPI.ts +43 -0
  295. package/src/api/cache/barrel.ts +7 -0
  296. package/src/api/cache/events/CacheEvent.ts +62 -0
  297. package/src/api/cache/events/CachingTaskEvent.ts +27 -0
  298. package/src/api/cache/events/barrel.ts +2 -0
  299. package/src/api/cache/hooks/barrel.ts +3 -0
  300. package/src/api/cache/hooks/useCachingTaskList.ts +23 -0
  301. package/src/api/cache/hooks/useCachingTaskProgress.ts +20 -0
  302. package/src/api/cache/hooks/useCachingTaskStatus.ts +20 -0
  303. package/src/api/config/PlayerConfiguration.ts +3 -0
  304. package/src/index.tsx +1 -0
  305. package/src/internal/THEOplayerView.web.tsx +5 -5
  306. package/src/internal/adapter/THEOplayerWebAdapter.ts +6 -6
  307. package/src/internal/adapter/WebEventForwarder.ts +3 -3
  308. package/src/internal/adapter/ads/THEOplayerWebAdsAdapter.ts +3 -3
  309. package/src/internal/adapter/cast/THEOplayerWebCastAdapter.ts +3 -3
  310. package/src/internal/adapter/web/WebPresentationModeManager.ts +3 -3
  311. package/src/internal/cache/MediaCache.ts +151 -0
  312. package/src/internal/cache/MediaCache.web.ts +54 -0
  313. package/src/internal/cache/NativeCachingTaskAdapter.ts +81 -0
  314. package/src/internal/cache/NativeCachingTaskParametersAdapter.ts +32 -0
  315. package/src/internal/cache/WebCachingTaskAdapter.ts +95 -0
  316. package/android/src/main/java/com/theoplayer/track/QualityListFilter.kt +0 -28
package/CHANGELOG.md CHANGED
@@ -5,6 +5,21 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.1.0/)
6
6
  and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [3.0.0] - 23-10-06
9
+
10
+ ### Fixed
11
+
12
+ - Fixed sourceDescription processing on iOS for offline playback.
13
+
14
+ ### Changed
15
+
16
+ - Added support for THEOplayer 6.0. See [THEOplayer's changelog](https://docs.theoplayer.com/changelog.md) for details.
17
+ - Bumped minimal version for SideloadedTextTracks connection on iOS to v6.1.1 which contains fix for iOS 17.0.
18
+
19
+ ### Added
20
+
21
+ - Added `MediaCache` API, enabling download of media assets for offline playback.
22
+
8
23
  ## [2.16.1] - 23-09-27
9
24
 
10
25
  ### Added
package/README.md CHANGED
@@ -101,6 +101,7 @@ and discussed in the next section. Finally, an overview of features, limitations
101
101
  - [Casting with Chromecast and Airplay](./doc/cast.md)
102
102
  - [Custom iOS framework](./doc/custom-ios-framework.md)
103
103
  - [Digital Rights Management (DRM)](./doc/drm.md)
104
+ - [Media Caching](./doc/media_caching.md)
104
105
  - [Migrating to `react-native-theoplayer` v2.x](./doc/migrating_v2.md)
105
106
  - [Picture-in-Picture (PiP)](./doc/pip.md)
106
107
  - [Styling subtitles and closed captions](./doc/texttrackstyles.md)
@@ -29,11 +29,11 @@ def enabledCast = safeExtGet("THEOplayer_extensionCast", 'false').toBoolean()
29
29
  def enabledMediaSession = safeExtGet("THEOplayer_extensionMediaSession", 'true').toBoolean()
30
30
 
31
31
  android {
32
- compileSdkVersion safeExtGet('THEOplayer_compileSdkVersion', 31)
32
+ compileSdk safeExtGet('THEOplayer_compileSdkVersion', 33)
33
33
 
34
34
  defaultConfig {
35
35
  minSdkVersion safeExtGet('THEOplayer_minSdkVersion', 21)
36
- targetSdkVersion safeExtGet('THEOplayer_targetSdkVersion', 31)
36
+ targetSdkVersion safeExtGet('THEOplayer_targetSdkVersion', 33)
37
37
  versionCode 1
38
38
  versionName "1.0"
39
39
 
@@ -67,7 +67,7 @@ android {
67
67
  minifyEnabled false
68
68
  }
69
69
  }
70
- lintOptions {
70
+ lint {
71
71
  disable 'GradleCompatible'
72
72
  }
73
73
  compileOptions {
@@ -102,20 +102,18 @@ dependencies {
102
102
  //noinspection GradleDynamicVersion
103
103
  implementation "com.facebook.react:react-native:+" // From node_modules
104
104
  implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.4"
105
- implementation "com.theoplayer.theoplayer-sdk-android:ads-wrapper:4.8.0"
106
- implementation "androidx.appcompat:appcompat:1.4.+"
105
+ implementation "androidx.appcompat:appcompat:1.6.1"
107
106
 
108
- // The minimum supported version is 5.10.0
109
- def theoplayer_sdk_version = safeExtGet('THEOplayer_sdk', '[5.10,6.0)')
107
+ // The minimum supported THEOplayer version is 6.0.0
108
+ def theoplayer_sdk_version = safeExtGet('THEOplayer_sdk', '[6.0.0,7.0)')
110
109
 
111
110
  // def theoplayer_mediasession_version = safeExtGet('THEOplayer_mediasession', theoplayer_sdk_version)
112
111
  def theoplayer_mediasession_version = "5.11.0-local"
113
- def enabledV4 = theoplayer_sdk_version.toString().startsWith("4.")
114
- def core_prefix = enabledV4 ? 'unified' : 'core'
115
- def integration_prefix = enabledV4 ? 'unified' : 'integration'
116
112
 
117
113
  println("Using THEOplayer (${versionString(theoplayer_sdk_version)})")
118
- implementation "com.theoplayer.theoplayer-sdk-android:${core_prefix}:${theoplayer_sdk_version}"
114
+ implementation "com.theoplayer.theoplayer-sdk-android:core:${theoplayer_sdk_version}"
115
+
116
+ implementation "com.theoplayer.theoplayer-sdk-android:ads-wrapper:4.8.0"
119
117
 
120
118
  if (enabledMediaSession) {
121
119
  println("Enable THEOplayer MediaSession extension (${versionString(theoplayer_mediasession_version)})")
@@ -127,30 +125,29 @@ dependencies {
127
125
 
128
126
  if (enabledGoogleIMA) {
129
127
  println('Enable THEOplayer IMA extension.')
130
- implementation "com.theoplayer.theoplayer-sdk-android:${integration_prefix}-ads:${theoplayer_sdk_version}"
131
- implementation "com.theoplayer.theoplayer-sdk-android:${integration_prefix}-ads-ima:${theoplayer_sdk_version}"
128
+ implementation "com.theoplayer.theoplayer-sdk-android:integration-ads:${theoplayer_sdk_version}"
129
+ implementation "com.theoplayer.theoplayer-sdk-android:integration-ads-ima:${theoplayer_sdk_version}"
132
130
  } else {
133
131
  println('Disable THEOplayer IMA extension.')
134
- compileOnly "com.theoplayer.theoplayer-sdk-android:${integration_prefix}-ads:${theoplayer_sdk_version}"
135
- compileOnly "com.theoplayer.theoplayer-sdk-android:${integration_prefix}-ads-ima:${theoplayer_sdk_version}"
132
+ compileOnly "com.theoplayer.theoplayer-sdk-android:integration-ads:${theoplayer_sdk_version}"
133
+ compileOnly "com.theoplayer.theoplayer-sdk-android:integration-ads-ima:${theoplayer_sdk_version}"
136
134
  }
137
135
 
138
- // NOTE: The DAI extension module is available on Maven as of SDK v4.3.0
139
136
  if (enabledGoogleDAI) {
140
137
  println('Enable THEOplayer DAI extension.')
141
- implementation "com.theoplayer.theoplayer-sdk-android:${integration_prefix}-ads:${theoplayer_sdk_version}"
142
- implementation "com.theoplayer.theoplayer-sdk-android:${integration_prefix}-ads-dai:${theoplayer_sdk_version}"
138
+ implementation "com.theoplayer.theoplayer-sdk-android:integration-ads:${theoplayer_sdk_version}"
139
+ implementation "com.theoplayer.theoplayer-sdk-android:integration-ads-dai:${theoplayer_sdk_version}"
143
140
  } else {
144
141
  println('Disable THEOplayer DAI extension.')
145
- compileOnly "com.theoplayer.theoplayer-sdk-android:${integration_prefix}-ads:${theoplayer_sdk_version}"
146
- compileOnly "com.theoplayer.theoplayer-sdk-android:${integration_prefix}-ads-dai:${theoplayer_sdk_version}"
142
+ compileOnly "com.theoplayer.theoplayer-sdk-android:integration-ads:${theoplayer_sdk_version}"
143
+ compileOnly "com.theoplayer.theoplayer-sdk-android:integration-ads-dai:${theoplayer_sdk_version}"
147
144
  }
148
145
 
149
146
  if (enabledCast) {
150
147
  println('Enable THEOplayer cast extension.')
151
- implementation "com.theoplayer.theoplayer-sdk-android:${integration_prefix}-cast:${theoplayer_sdk_version}"
148
+ implementation "com.theoplayer.theoplayer-sdk-android:integration-cast:${theoplayer_sdk_version}"
152
149
  } else {
153
150
  println('Disable THEOplayer cast extension.')
154
- compileOnly "com.theoplayer.theoplayer-sdk-android:${integration_prefix}-cast:${theoplayer_sdk_version}"
151
+ compileOnly "com.theoplayer.theoplayer-sdk-android:integration-cast:${theoplayer_sdk_version}"
155
152
  }
156
153
  }
@@ -1,127 +1,123 @@
1
1
  package com.theoplayer
2
2
 
3
3
  import android.text.TextUtils
4
- import android.util.Log
5
4
  import com.facebook.react.bridge.ReadableMap
5
+ import com.google.ads.interactivemedia.v3.api.AdsRenderingSettings
6
+ import com.google.ads.interactivemedia.v3.api.ImaSdkFactory
6
7
  import com.theoplayer.android.api.THEOplayerConfig
7
8
  import com.theoplayer.android.api.ads.AdsConfiguration
8
9
  import com.theoplayer.android.api.ads.AdPreloadType
9
- import com.theoplayer.android.api.ads.GoogleImaConfiguration
10
10
  import com.theoplayer.android.api.cast.CastStrategy
11
- import com.google.android.gms.cast.framework.CastContext
11
+ import com.theoplayer.android.api.cast.CastConfiguration
12
12
  import com.theoplayer.android.api.pip.PipConfiguration
13
13
  import com.theoplayer.android.api.player.NetworkConfiguration
14
14
 
15
- private const val TAG = "PlayerConfigAdapter"
16
- private const val PROP_ADS_CONFIGURATION = "ads"
17
15
  private const val PROP_LICENSE = "license"
18
16
  private const val PROP_LICENSE_URL = "licenseUrl"
19
- private const val PROP_CHROMELESS = "chromeless"
20
17
  private const val PROP_PRELOAD = "preload"
21
18
  private const val PROP_UI_ENABLED = "uiEnabled"
22
- private const val PROP_GOOGLE_IMA_CONFIGURATION = "googleImaConfiguration"
23
- private const val PROP_USE_NATIVE_IMA = "useNativeIma"
24
- private const val PROP_CAST_CONFIGURATION = "cast"
25
19
  private const val PROP_CAST_STRATEGY = "strategy"
26
- private const val PROP_CHROMECAST_CONFIG = "chromecast"
27
- private const val PROP_CHROMECAST_APPID = "appID"
28
20
  private const val PROP_RETRY_CONFIG = "retryConfiguration"
29
21
  private const val PROP_RETRY_MAX_RETRIES = "maxRetries"
30
22
  private const val PROP_RETRY_MIN_BACKOFF = "minimumBackoff"
31
23
  private const val PROP_RETRY_MAX_BACKOFF = "maximumBackoff"
24
+ private const val PROP_CAST_CONFIGURATION = "cast"
25
+ private const val PROP_ADS_CONFIGURATION = "ads"
32
26
 
33
- object PlayerConfigAdapter {
27
+ class PlayerConfigAdapter(private val configProps: ReadableMap?) {
34
28
 
35
- fun theoConfigFromProps(configProps: ReadableMap?): THEOplayerConfig {
36
- val configBuilder = THEOplayerConfig.Builder()
37
- if (configProps != null) {
38
- val adsConfig = adsConfigurationFromProps(configProps.getMap(PROP_ADS_CONFIGURATION))
39
- if (adsConfig != null) {
40
- configBuilder.ads(adsConfig)
41
- }
42
- val license = configProps.getString(PROP_LICENSE)
43
- if (license != null) {
44
- configBuilder.license(license)
45
- }
46
- val licenseUrl = configProps.getString(PROP_LICENSE_URL)
47
- if (licenseUrl != null) {
48
- configBuilder.licenseUrl(licenseUrl)
49
- }
50
- if (configProps.hasKey(PROP_CHROMELESS)) {
51
- configBuilder.chromeless(configProps.getBoolean(PROP_CHROMELESS))
29
+ /**
30
+ * Get general THEOplayerConfig object; these properties apply:
31
+ * - license: The license for the player.
32
+ * - licenseUrl: The url to fetch the license for the player.
33
+ * - retryConfiguration: The retry configuration for the player.
34
+ */
35
+ fun playerConfig(): THEOplayerConfig {
36
+ return THEOplayerConfig.Builder().apply {
37
+ configProps?.run {
38
+ getString(PROP_LICENSE)?.let { license ->
39
+ license(license)
40
+ }
41
+ getString(PROP_LICENSE_URL)?.let { licenseUrl ->
42
+ licenseUrl(licenseUrl)
43
+ }
44
+ if (hasKey(PROP_RETRY_CONFIG)) {
45
+ networkConfiguration(networkConfig())
46
+ }
47
+ pipConfiguration(PipConfiguration.Builder().build())
52
48
  }
53
- if (configProps.hasKey(PROP_RETRY_CONFIG)) {
54
- val networkConfig = networkConfigurationFromProps(configProps.getMap(PROP_RETRY_CONFIG))
55
- if (networkConfig != null) {
56
- configBuilder.networkConfiguration(networkConfig)
49
+ }.build()
50
+ }
51
+
52
+ /**
53
+ * Get NetworkConfiguration object; there properties apply:
54
+ * - maxRetries: The maximum amount of retries before the player throws a fatal error.
55
+ * - minimumBackoff: The initial delay in milliseconds before a retry request occurs.
56
+ * - maximumBackoff: The maximum amount of delay in milliseconds between retry requests.
57
+ */
58
+ private fun networkConfig(): NetworkConfiguration {
59
+ return NetworkConfiguration.Builder().apply {
60
+ configProps?.getMap(PROP_RETRY_CONFIG)?.run {
61
+ if (hasKey(PROP_RETRY_MAX_RETRIES)) {
62
+ maxRetries(getInt(PROP_RETRY_MAX_RETRIES))
63
+ }
64
+ if (hasKey(PROP_RETRY_MIN_BACKOFF)) {
65
+ minimumBackOff(getDouble(PROP_RETRY_MIN_BACKOFF).toLong())
66
+ }
67
+ if (hasKey(PROP_RETRY_MAX_BACKOFF)) {
68
+ maximumBackOff(getDouble(PROP_RETRY_MAX_BACKOFF).toLong())
57
69
  }
58
70
  }
59
- applyCastConfigurationFromProps(configBuilder, configProps.getMap(PROP_CAST_CONFIGURATION))
60
- configBuilder.pipConfiguration(PipConfiguration.Builder().build())
61
- }
62
- return configBuilder.build()
71
+ }.build()
63
72
  }
64
73
 
65
- private fun adsConfigurationFromProps(configProps: ReadableMap?): AdsConfiguration? {
66
- if (configProps == null) {
67
- return null
68
- }
69
- val builder = AdsConfiguration.Builder()
70
- val preloadTypeString = configProps.getString(PROP_PRELOAD)
71
- if (!TextUtils.isEmpty(preloadTypeString)) {
72
- builder.preload(AdPreloadType.from(preloadTypeString))
73
- }
74
- builder.showCountdown(
75
- !configProps.hasKey(PROP_UI_ENABLED) || configProps.getBoolean(PROP_UI_ENABLED)
76
- )
77
- val googleImaConfiguration = googleImaConfigurationFromProps(
78
- configProps.getMap(PROP_GOOGLE_IMA_CONFIGURATION)
79
- )
80
- if (googleImaConfiguration != null) {
81
- builder.googleIma(googleImaConfiguration)
82
- }
83
- return builder.build()
74
+ /**
75
+ * Get AdsConfiguration object; these properties apply:
76
+ * - preload: Whether media files of mid- and postrolls are preloaded.
77
+ * - uiEnabled: Whether an advertisement UI is shown.
78
+ */
79
+ fun adsConfig(): AdsConfiguration {
80
+ return AdsConfiguration.Builder().apply {
81
+ configProps?.getMap(PROP_ADS_CONFIGURATION)?.run {
82
+ if (hasKey(PROP_PRELOAD)) {
83
+ val preloadTypeString = getString(PROP_PRELOAD)
84
+ if (!TextUtils.isEmpty(preloadTypeString)) {
85
+ preload(AdPreloadType.from(preloadTypeString))
86
+ }
87
+ }
88
+ if (hasKey(PROP_UI_ENABLED)) {
89
+ showCountdown(getBoolean(PROP_UI_ENABLED))
90
+ }
91
+ }
92
+ }.build()
84
93
  }
85
94
 
86
- private fun networkConfigurationFromProps(configProps: ReadableMap?): NetworkConfiguration? {
87
- if (configProps == null) {
88
- return null
89
- }
90
- val builder = NetworkConfiguration.Builder()
91
- if (configProps.hasKey(PROP_RETRY_MAX_RETRIES)) {
92
- builder.maxRetries(configProps.getInt(PROP_RETRY_MAX_RETRIES))
93
- }
94
- if (configProps.hasKey(PROP_RETRY_MIN_BACKOFF)) {
95
- builder.minimumBackOff(configProps.getDouble(PROP_RETRY_MIN_BACKOFF).toLong())
96
- }
97
- if (configProps.hasKey(PROP_RETRY_MAX_BACKOFF)) {
98
- builder.maximumBackOff(configProps.getDouble(PROP_RETRY_MAX_BACKOFF).toLong())
95
+ /**
96
+ * Create a AdsRenderingSettings object.
97
+ */
98
+ fun adsRenderSettings(): AdsRenderingSettings {
99
+ return ImaSdkFactory.getInstance().createAdsRenderingSettings().apply {
100
+ configProps?.getMap(PROP_ADS_CONFIGURATION)?.run {
101
+ if (hasKey(PROP_UI_ENABLED) && !getBoolean(PROP_UI_ENABLED)) {
102
+ setUiElements(emptySet())
103
+ disableUi = true
104
+ }
105
+ }
99
106
  }
100
- return builder.build()
101
107
  }
102
108
 
103
- private fun applyCastConfigurationFromProps(
104
- configBuilder: THEOplayerConfig.Builder,
105
- castConfig: ReadableMap?
106
- ) {
107
- if (castConfig == null) {
108
- return
109
- }
110
- val strStrategy = castConfig.getString(PROP_CAST_STRATEGY)
111
- val castStrategy = castStrategyFromString(strStrategy)
112
- if (castStrategy != null) {
113
- configBuilder.castStrategy(castStrategy)
114
- } else {
115
- Log.e(TAG, "Unknown cast strategy: $strStrategy")
116
- }
117
- val chromecastConfig = castConfig.getMap(PROP_CHROMECAST_CONFIG)
118
- if (chromecastConfig != null) {
119
- val appID = chromecastConfig.getString(PROP_CHROMECAST_APPID)
120
- val castContext = CastContext.getSharedInstance()
121
- if (appID != null && castContext != null) {
122
- castContext.setReceiverApplicationId(appID)
109
+ /**
110
+ * Get CastConfiguration object; these properties apply:
111
+ * - strategy: The join strategy of the player.
112
+ */
113
+ fun castConfig(): CastConfiguration {
114
+ return CastConfiguration.Builder().apply {
115
+ configProps?.getMap(PROP_CAST_CONFIGURATION)?.run {
116
+ castStrategyFromString(getString(PROP_CAST_STRATEGY))?.let { strategy ->
117
+ castStrategy(strategy)
118
+ }
123
119
  }
124
- }
120
+ }.build()
125
121
  }
126
122
 
127
123
  private fun castStrategyFromString(strStrategy: String?): CastStrategy? {
@@ -132,14 +128,4 @@ object PlayerConfigAdapter {
132
128
  else -> null
133
129
  }
134
130
  }
135
-
136
- private fun googleImaConfigurationFromProps(configProps: ReadableMap?): GoogleImaConfiguration? {
137
- return if (configProps == null) {
138
- null
139
- } else GoogleImaConfiguration.Builder()
140
- .useNativeIma(
141
- configProps.hasKey(PROP_USE_NATIVE_IMA) && configProps.getBoolean(PROP_USE_NATIVE_IMA)
142
- )
143
- .build()
144
- }
145
131
  }
@@ -12,10 +12,8 @@ import android.os.IBinder
12
12
  import android.os.Looper
13
13
  import android.support.v4.media.session.MediaSessionCompat
14
14
  import android.support.v4.media.session.PlaybackStateCompat
15
+ import android.util.Log
15
16
  import com.facebook.react.uimanager.ThemedReactContext
16
- import com.google.ads.interactivemedia.v3.api.AdsRenderingSettings
17
- import com.google.ads.interactivemedia.v3.api.ImaSdkFactory
18
- import com.theoplayer.android.api.THEOplayerConfig
19
17
  import com.theoplayer.android.api.THEOplayerView
20
18
  import com.theoplayer.android.api.ads.dai.GoogleDaiIntegration
21
19
  import com.theoplayer.android.api.ads.dai.GoogleDaiIntegrationFactory
@@ -86,10 +84,10 @@ class ReactTHEOplayerContext private constructor(
86
84
  companion object {
87
85
  fun create(
88
86
  reactContext: ThemedReactContext,
89
- playerConfig: THEOplayerConfig
87
+ configAdapter: PlayerConfigAdapter
90
88
  ): ReactTHEOplayerContext {
91
89
  return ReactTHEOplayerContext(reactContext).apply {
92
- initializePlayerView(playerConfig)
90
+ initializePlayerView(configAdapter)
93
91
  }
94
92
  }
95
93
  }
@@ -213,8 +211,8 @@ class ReactTHEOplayerContext private constructor(
213
211
  binder = null
214
212
  }
215
213
 
216
- private fun initializePlayerView(playerConfig: THEOplayerConfig) {
217
- playerView = object : THEOplayerView(reactContext.currentActivity!!, playerConfig) {
214
+ private fun initializePlayerView(configAdapter: PlayerConfigAdapter) {
215
+ playerView = object : THEOplayerView(reactContext.currentActivity!!, configAdapter.playerConfig()) {
218
216
  private fun measureAndLayout() {
219
217
  measure(
220
218
  MeasureSpec.makeMeasureSpec(measuredWidth, MeasureSpec.EXACTLY),
@@ -234,7 +232,7 @@ class ReactTHEOplayerContext private constructor(
234
232
  // By default, the screen should remain on.
235
233
  playerView.keepScreenOn = true
236
234
 
237
- addIntegrations(playerConfig)
235
+ addIntegrations(configAdapter)
238
236
  addListeners()
239
237
 
240
238
  audioFocusManager = AudioFocusManager(reactContext, player)
@@ -268,34 +266,45 @@ class ReactTHEOplayerContext private constructor(
268
266
  }
269
267
  }
270
268
 
271
- private fun addIntegrations(playerConfig: THEOplayerConfig) {
269
+ private fun addIntegrations(configAdapter: PlayerConfigAdapter) {
272
270
  try {
273
271
  if (BuildConfig.EXTENSION_GOOGLE_IMA) {
274
- imaIntegration = GoogleImaIntegrationFactory.createGoogleImaIntegration(playerView).apply {
275
- setAdsRenderingSettings(createRenderSettings(playerConfig))
276
- playerView.player.addIntegration(this)
272
+ imaIntegration = GoogleImaIntegrationFactory.createGoogleImaIntegration(
273
+ playerView, configAdapter.adsConfig()
274
+ ).apply {
275
+ setAdsRenderingSettings(configAdapter.adsRenderSettings())
276
+ }.also {
277
+ playerView.player.addIntegration(it)
277
278
  }
278
279
  }
279
- } catch (ignore: Exception) {
280
+ } catch (e: Exception) {
281
+ Log.w(TAG, "Failed to configure Google IMA integration ${e.message}")
280
282
  }
281
283
  try {
282
284
  if (BuildConfig.EXTENSION_GOOGLE_DAI) {
283
- daiIntegration = GoogleDaiIntegrationFactory.createGoogleDaiIntegration(playerView).apply {
284
- setAdsRenderingSettings(createRenderSettings(playerConfig))
285
- playerView.player.addIntegration(this)
285
+ daiIntegration = GoogleDaiIntegrationFactory.createGoogleDaiIntegration(
286
+ playerView, configAdapter.adsConfig()
287
+ ).apply {
288
+ setAdsRenderingSettings(configAdapter.adsRenderSettings())
289
+ }.also {
290
+ playerView.player.addIntegration(it)
286
291
  }
287
292
  }
288
- } catch (ignore: Exception) {
293
+ } catch (e: Exception) {
294
+ Log.w(TAG, "Failed to configure Google DAI integration ${e.message}")
289
295
  }
290
296
  try {
291
297
  if (BuildConfig.EXTENSION_CAST) {
292
- castIntegration = CastIntegrationFactory.createCastIntegration(playerView).apply {
293
- playerView.player.addIntegration(this)
298
+ castIntegration = CastIntegrationFactory.createCastIntegration(
299
+ playerView, configAdapter.castConfig()
300
+ ).also {
301
+ playerView.player.addIntegration(it)
294
302
  }
295
303
  }
296
- // Add other future integrations here.
297
- } catch (ignore: Exception) {
304
+ } catch (e: Exception) {
305
+ Log.w(TAG, "Failed to configure Cast integration ${e.message}")
298
306
  }
307
+ // Add other future integrations here.
299
308
  }
300
309
 
301
310
  private val onSourceChange = EventListener<SourceChangeEvent> {
@@ -343,15 +352,6 @@ class ReactTHEOplayerContext private constructor(
343
352
  }
344
353
  }
345
354
 
346
- private fun createRenderSettings(playerConfig: THEOplayerConfig): AdsRenderingSettings {
347
- val renderingSettings = ImaSdkFactory.getInstance().createAdsRenderingSettings()
348
- if (playerConfig.ads != null && !playerConfig.ads!!.isShowCountdown) {
349
- renderingSettings.setUiElements(emptySet())
350
- renderingSettings.disableUi = true
351
- }
352
- return renderingSettings
353
- }
354
-
355
355
  /**
356
356
  * The host activity is paused.
357
357
  */
@@ -5,6 +5,7 @@ import com.facebook.react.bridge.ReactApplicationContext
5
5
  import com.facebook.react.bridge.NativeModule
6
6
  import com.facebook.react.uimanager.ViewManager
7
7
  import com.theoplayer.ads.AdsModule
8
+ import com.theoplayer.cache.CacheModule
8
9
  import com.theoplayer.drm.ContentProtectionModule
9
10
  import com.theoplayer.cast.CastModule
10
11
  import com.theoplayer.player.PlayerModule
@@ -15,7 +16,8 @@ class ReactTHEOplayerPackage : ReactPackage {
15
16
  PlayerModule(reactContext),
16
17
  AdsModule(reactContext),
17
18
  ContentProtectionModule(reactContext),
18
- CastModule(reactContext)
19
+ CastModule(reactContext),
20
+ CacheModule(reactContext)
19
21
  )
20
22
  }
21
23
 
@@ -51,7 +51,7 @@ class ReactTHEOplayerView(private val reactContext: ThemedReactContext) :
51
51
  isInitialized = true
52
52
  playerContext = ReactTHEOplayerContext.create(
53
53
  reactContext,
54
- PlayerConfigAdapter.theoConfigFromProps(configProps)
54
+ PlayerConfigAdapter(configProps)
55
55
  )
56
56
  playerContext?.let {
57
57
  if (BuildConfig.EXTENSION_ADS) {
@@ -0,0 +1,127 @@
1
+ package com.theoplayer.cache
2
+
3
+ import com.facebook.react.bridge.Arguments
4
+ import com.facebook.react.bridge.ReadableArray
5
+ import com.facebook.react.bridge.ReadableMap
6
+ import com.facebook.react.bridge.WritableArray
7
+ import com.facebook.react.bridge.WritableMap
8
+ import com.theoplayer.android.api.cache.CacheStatus
9
+ import com.theoplayer.android.api.cache.CachingParameters
10
+ import com.theoplayer.android.api.cache.CachingPreferredTrackSelection
11
+ import com.theoplayer.android.api.cache.CachingTask
12
+ import com.theoplayer.android.api.cache.CachingTaskList
13
+ import com.theoplayer.android.api.cache.CachingTaskProgress
14
+ import com.theoplayer.android.api.cache.CachingTaskStatus
15
+ import com.theoplayer.source.SourceAdapter
16
+ import com.theoplayer.util.fromTimeRanges
17
+ import java.util.Date
18
+
19
+ private const val PROP_ID = "id"
20
+ private const val PROP_STATUS = "status"
21
+ private const val PROP_SOURCE = "source"
22
+ private const val PROP_PARAMETERS = "parameters"
23
+ private const val PROP_PARAMETERS_AMOUNT = "amount"
24
+ private const val PROP_PARAMETERS_EXPIRATION_DATE = "expirationDate"
25
+ private const val PROP_PARAMETERS_BANDWIDTH = "bandwidth"
26
+ private const val PROP_PARAMETERS_PREFERRED_TRACK_SELECTION = "preferredTrackSelection"
27
+ private const val PROP_PARAMETERS_AUDIO_TRACK_SELECTION = "audioTrackSelection"
28
+ private const val PROP_PARAMETERS_TEXT_TRACK_SELECTION = "textTrackSelection"
29
+ private const val PROP_DURATION = "duration"
30
+ private const val PROP_CACHED = "cached"
31
+ private const val PROP_SECONDS_CACHED = "secondsCached"
32
+ private const val PROP_PERCENTAGE_CACHED = "percentageCached"
33
+ private const val PROP_BYTES = "bytes"
34
+ private const val PROP_BYTES_CACHED = "bytesCached"
35
+
36
+ object CacheAdapter {
37
+
38
+ fun fromCachingTask(task: CachingTask?): WritableMap {
39
+ if (task == null) {
40
+ return Arguments.createMap()
41
+ }
42
+ return Arguments.createMap().apply {
43
+ putString(PROP_ID, task.id)
44
+ putString(PROP_STATUS, fromCacheTaskStatus(task.status))
45
+ putMap(PROP_SOURCE, SourceAdapter().fromSourceDescription(task.source))
46
+ putMap(PROP_PARAMETERS, fromCachingParameters(task.parameters))
47
+ putDouble(PROP_DURATION, task.duration)
48
+ putArray(PROP_CACHED, fromTimeRanges(task.cached))
49
+ putDouble(PROP_SECONDS_CACHED, task.secondsCached)
50
+ putDouble(PROP_PERCENTAGE_CACHED, task.percentageCached)
51
+ putDouble(PROP_BYTES, task.bytes.toDouble())
52
+ putDouble(PROP_BYTES_CACHED, task.bytesCached.toDouble())
53
+ }
54
+ }
55
+
56
+ fun fromCachingTaskList(taskList: CachingTaskList?): WritableArray {
57
+ return Arguments.createArray().apply {
58
+ taskList?.forEach { task ->
59
+ pushMap(fromCachingTask(task))
60
+ }
61
+ }
62
+ }
63
+
64
+ fun fromCacheStatus(status: CacheStatus): String {
65
+ return when (status) {
66
+ CacheStatus.INITIALISED -> "initialised"
67
+ else -> "uninitialised"
68
+ }
69
+ }
70
+
71
+ fun fromCachingTaskProgress(progress: CachingTaskProgress): WritableMap {
72
+ return Arguments.createMap().apply {
73
+ putDouble(PROP_DURATION, progress.duration)
74
+ putArray(PROP_CACHED, fromTimeRanges(progress.cached))
75
+ putDouble(PROP_SECONDS_CACHED, progress.secondsCached)
76
+ putDouble(PROP_PERCENTAGE_CACHED, progress.percentageCached)
77
+ putDouble(PROP_BYTES, progress.bytes.toDouble())
78
+ putDouble(PROP_BYTES_CACHED, progress.bytesCached.toDouble())
79
+ }
80
+ }
81
+
82
+ fun fromCacheTaskStatus(status: CachingTaskStatus): String {
83
+ return when (status) {
84
+ CachingTaskStatus.ERROR -> "error"
85
+ CachingTaskStatus.DONE -> "done"
86
+ CachingTaskStatus.EVICTED -> "evicted"
87
+ CachingTaskStatus.LOADING -> "loading"
88
+ else -> "idle"
89
+ }
90
+ }
91
+
92
+ fun parseCachingParameters(parameters: ReadableMap): CachingParameters {
93
+ return CachingParameters.Builder().apply {
94
+ amount(parameters.getString(PROP_PARAMETERS_AMOUNT))
95
+ if (parameters.hasKey(PROP_PARAMETERS_BANDWIDTH)) {
96
+ bandwidth(parameters.getDouble(PROP_PARAMETERS_BANDWIDTH).toLong())
97
+ }
98
+ if (parameters.hasKey(PROP_PARAMETERS_EXPIRATION_DATE)) {
99
+ expirationDate(Date(parameters.getDouble(PROP_PARAMETERS_EXPIRATION_DATE).toLong()))
100
+ }
101
+ if (parameters.hasKey(PROP_PARAMETERS_PREFERRED_TRACK_SELECTION)) {
102
+ preferredTrackSelection(parsePreferredTrackSelection(parameters.getMap(PROP_PARAMETERS_PREFERRED_TRACK_SELECTION)))
103
+ }
104
+ }.build()
105
+ }
106
+
107
+ private fun parsePreferredTrackSelection(parameters: ReadableMap?): CachingPreferredTrackSelection {
108
+ return CachingPreferredTrackSelection.Builder().apply {
109
+ audioTrackSelection(fromReadableStringArray(parameters?.getArray(PROP_PARAMETERS_AUDIO_TRACK_SELECTION)))
110
+ textTrackSelection(fromReadableStringArray(parameters?.getArray(PROP_PARAMETERS_TEXT_TRACK_SELECTION)))
111
+ }.build()
112
+ }
113
+
114
+ private fun fromReadableStringArray(array: ReadableArray?): Array<String>? {
115
+ return array?.toArrayList()?.map { it.toString() }?.toTypedArray()
116
+ }
117
+
118
+ private fun fromCachingParameters(parameters: CachingParameters?): WritableMap {
119
+ return Arguments.createMap().apply {
120
+ if (parameters != null) {
121
+ putString(PROP_PARAMETERS_AMOUNT, parameters.amount)
122
+ putDouble(PROP_PARAMETERS_BANDWIDTH, parameters.bandwidth.toDouble())
123
+ putDouble(PROP_PARAMETERS_EXPIRATION_DATE, parameters.expirationDate.time.toDouble())
124
+ }
125
+ }
126
+ }
127
+ }