bitmovin-player-react-native 0.44.1-alpha.0 → 1.0.0-alpha.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 (497) hide show
  1. package/.eslintignore +11 -0
  2. package/.eslintrc.js +7 -0
  3. package/.gitattributes +3 -0
  4. package/.prettierignore +11 -0
  5. package/.ruby-version +1 -0
  6. package/.swiftlint.yml +171 -0
  7. package/Brewfile +2 -0
  8. package/CHANGELOG.md +627 -0
  9. package/CONTRIBUTING.md +255 -0
  10. package/TODO.md +0 -0
  11. package/android/.editorconfig +8 -0
  12. package/android/build.gradle +78 -75
  13. package/android/gradle/wrapper/gradle-wrapper.jar +0 -0
  14. package/android/gradle/wrapper/gradle-wrapper.properties +7 -0
  15. package/android/gradle.properties +1 -0
  16. package/android/gradlew +248 -0
  17. package/android/gradlew.bat +92 -0
  18. package/android/ktlint.gradle +31 -0
  19. package/android/src/main/java/com/bitmovin/player/reactnative/ActivityLifecycleListener.kt +51 -0
  20. package/android/src/main/java/com/bitmovin/player/reactnative/BitmovinCastManagerModule.kt +32 -55
  21. package/android/src/main/java/com/bitmovin/player/reactnative/BufferModule.kt +33 -45
  22. package/android/src/main/java/com/bitmovin/player/reactnative/CustomMessageHandlerModule.kt +84 -0
  23. package/android/src/main/java/com/bitmovin/player/reactnative/DebugModule.kt +6 -14
  24. package/android/src/main/java/com/bitmovin/player/reactnative/DecoderConfigModule.kt +89 -44
  25. package/android/src/main/java/com/bitmovin/player/reactnative/DrmModule.kt +80 -99
  26. package/android/src/main/java/com/bitmovin/player/reactnative/EventSubscription.kt +22 -0
  27. package/android/src/main/java/com/bitmovin/player/reactnative/FullscreenHandlerModule.kt +100 -0
  28. package/android/src/main/java/com/bitmovin/player/reactnative/MediaSessionPlaybackManager.kt +5 -5
  29. package/android/src/main/java/com/bitmovin/player/reactnative/NetworkModule.kt +98 -56
  30. package/android/src/main/java/com/bitmovin/player/reactnative/OfflineModule.kt +132 -186
  31. package/android/src/main/java/com/bitmovin/player/reactnative/PlayerAnalyticsModule.kt +37 -36
  32. package/android/src/main/java/com/bitmovin/player/reactnative/PlayerModule.kt +252 -528
  33. package/android/src/main/java/com/bitmovin/player/reactnative/RNPlayerPackage.kt +11 -0
  34. package/android/src/main/java/com/bitmovin/player/reactnative/RNPlayerView.kt +558 -213
  35. package/android/src/main/java/com/bitmovin/player/reactnative/RNPlayerViewManager.kt +99 -286
  36. package/android/src/main/java/com/bitmovin/player/reactnative/ResultWaiter.kt +58 -0
  37. package/android/src/main/java/com/bitmovin/player/reactnative/SourceModule.kt +77 -151
  38. package/android/src/main/java/com/bitmovin/player/reactnative/Types.kt +44 -0
  39. package/android/src/main/java/com/bitmovin/player/reactnative/UuidModule.kt +12 -15
  40. package/android/src/main/java/com/bitmovin/player/reactnative/converter/JsonConverter.kt +296 -456
  41. package/android/src/main/java/com/bitmovin/player/reactnative/extensions/ListExtension.kt +89 -0
  42. package/android/src/main/java/com/bitmovin/player/reactnative/extensions/MapExtension.kt +95 -0
  43. package/android/src/main/java/com/bitmovin/player/reactnative/offline/OfflineContentManagerBridge.kt +20 -52
  44. package/android/src/main/java/com/bitmovin/player/reactnative/ui/CustomMessageHandlerBridge.kt +10 -20
  45. package/android/src/main/java/com/bitmovin/player/reactnative/ui/FullscreenHandlerBridge.kt +4 -9
  46. package/app.plugin.js +21 -0
  47. package/build/BitmovinPlayerReactNative.types.d.ts +18 -0
  48. package/build/BitmovinPlayerReactNative.types.d.ts.map +1 -0
  49. package/build/BitmovinPlayerReactNative.types.js +2 -0
  50. package/build/BitmovinPlayerReactNative.types.js.map +1 -0
  51. package/build/adaptationConfig.d.ts +18 -0
  52. package/build/adaptationConfig.d.ts.map +1 -0
  53. package/build/adaptationConfig.js +2 -0
  54. package/build/adaptationConfig.js.map +1 -0
  55. package/build/advertising.d.ts +175 -0
  56. package/build/advertising.d.ts.map +1 -0
  57. package/build/advertising.js +37 -0
  58. package/build/advertising.js.map +1 -0
  59. package/build/analytics/config.d.ts +194 -0
  60. package/build/analytics/config.d.ts.map +1 -0
  61. package/build/analytics/config.js +2 -0
  62. package/build/analytics/config.js.map +1 -0
  63. package/build/analytics/index.d.ts +3 -0
  64. package/build/analytics/index.d.ts.map +1 -0
  65. package/build/analytics/index.js +3 -0
  66. package/build/analytics/index.js.map +1 -0
  67. package/build/analytics/player.d.ts +24 -0
  68. package/build/analytics/player.d.ts.map +1 -0
  69. package/build/analytics/player.js +30 -0
  70. package/build/analytics/player.js.map +1 -0
  71. package/build/analytics/playerAnalyticsModule.d.ts +13 -0
  72. package/build/analytics/playerAnalyticsModule.d.ts.map +1 -0
  73. package/build/analytics/playerAnalyticsModule.js +3 -0
  74. package/build/analytics/playerAnalyticsModule.js.map +1 -0
  75. package/build/audioSession.d.ts +33 -0
  76. package/build/audioSession.d.ts.map +1 -0
  77. package/build/audioSession.js +21 -0
  78. package/build/audioSession.js.map +1 -0
  79. package/build/audioTrack.d.ts +39 -0
  80. package/build/audioTrack.d.ts.map +1 -0
  81. package/build/audioTrack.js +2 -0
  82. package/build/audioTrack.js.map +1 -0
  83. package/build/bitmovinCastManager.d.ts +58 -0
  84. package/build/bitmovinCastManager.d.ts.map +1 -0
  85. package/build/bitmovinCastManager.js +64 -0
  86. package/build/bitmovinCastManager.js.map +1 -0
  87. package/build/bufferApi.d.ts +85 -0
  88. package/build/bufferApi.d.ts.map +1 -0
  89. package/build/bufferApi.js +60 -0
  90. package/build/bufferApi.js.map +1 -0
  91. package/build/bufferConfig.d.ts +42 -0
  92. package/build/bufferConfig.d.ts.map +1 -0
  93. package/build/bufferConfig.js +2 -0
  94. package/build/bufferConfig.js.map +1 -0
  95. package/build/components/PlayerView/events.d.ts +310 -0
  96. package/build/components/PlayerView/events.d.ts.map +1 -0
  97. package/build/components/PlayerView/events.js +2 -0
  98. package/build/components/PlayerView/events.js.map +1 -0
  99. package/build/components/PlayerView/index.d.ts +10 -0
  100. package/build/components/PlayerView/index.d.ts.map +1 -0
  101. package/build/components/PlayerView/index.js +72 -0
  102. package/build/components/PlayerView/index.js.map +1 -0
  103. package/build/components/PlayerView/native.d.ts +30 -0
  104. package/build/components/PlayerView/native.d.ts.map +1 -0
  105. package/build/components/PlayerView/native.js +6 -0
  106. package/build/components/PlayerView/native.js.map +1 -0
  107. package/build/components/PlayerView/nativeEvents.d.ts +437 -0
  108. package/build/components/PlayerView/nativeEvents.d.ts.map +1 -0
  109. package/build/components/PlayerView/nativeEvents.js +2 -0
  110. package/build/components/PlayerView/nativeEvents.js.map +1 -0
  111. package/build/components/PlayerView/pictureInPictureConfig.d.ts +22 -0
  112. package/build/components/PlayerView/pictureInPictureConfig.d.ts.map +1 -0
  113. package/build/components/PlayerView/pictureInPictureConfig.js +2 -0
  114. package/build/components/PlayerView/pictureInPictureConfig.js.map +1 -0
  115. package/build/components/PlayerView/playerViewConfig.d.ts +111 -0
  116. package/build/components/PlayerView/playerViewConfig.d.ts.map +1 -0
  117. package/build/components/PlayerView/playerViewConfig.js +51 -0
  118. package/build/components/PlayerView/playerViewConfig.js.map +1 -0
  119. package/build/components/PlayerView/properties.d.ts +61 -0
  120. package/build/components/PlayerView/properties.d.ts.map +1 -0
  121. package/build/components/PlayerView/properties.js +2 -0
  122. package/build/components/PlayerView/properties.js.map +1 -0
  123. package/build/components/index.d.ts +5 -0
  124. package/build/components/index.d.ts.map +1 -0
  125. package/build/components/index.js +5 -0
  126. package/build/components/index.js.map +1 -0
  127. package/build/debug.d.ts +46 -0
  128. package/build/debug.d.ts.map +1 -0
  129. package/build/debug.js +52 -0
  130. package/build/debug.js.map +1 -0
  131. package/build/decoder/decoderConfig.d.ts +96 -0
  132. package/build/decoder/decoderConfig.d.ts.map +1 -0
  133. package/build/decoder/decoderConfig.js +6 -0
  134. package/build/decoder/decoderConfig.js.map +1 -0
  135. package/build/decoder/decoderConfigModule.d.ts +14 -0
  136. package/build/decoder/decoderConfigModule.d.ts.map +1 -0
  137. package/build/decoder/decoderConfigModule.js +31 -0
  138. package/build/decoder/decoderConfigModule.js.map +1 -0
  139. package/build/decoder/index.d.ts +26 -0
  140. package/build/decoder/index.d.ts.map +1 -0
  141. package/build/decoder/index.js +50 -0
  142. package/build/decoder/index.js.map +1 -0
  143. package/build/drm/drmModule.d.ts +55 -0
  144. package/build/drm/drmModule.d.ts.map +1 -0
  145. package/build/drm/drmModule.js +3 -0
  146. package/build/drm/drmModule.js.map +1 -0
  147. package/build/drm/fairplayConfig.d.ts +91 -0
  148. package/build/drm/fairplayConfig.d.ts.map +1 -0
  149. package/build/drm/fairplayConfig.js +2 -0
  150. package/build/drm/fairplayConfig.js.map +1 -0
  151. package/build/drm/index.d.ts +112 -0
  152. package/build/drm/index.d.ts.map +1 -0
  153. package/build/drm/index.js +191 -0
  154. package/build/drm/index.js.map +1 -0
  155. package/build/drm/widevineConfig.d.ts +58 -0
  156. package/build/drm/widevineConfig.d.ts.map +1 -0
  157. package/build/drm/widevineConfig.js +2 -0
  158. package/build/drm/widevineConfig.js.map +1 -0
  159. package/build/events.d.ts +692 -0
  160. package/build/events.d.ts.map +1 -0
  161. package/build/events.js +2 -0
  162. package/build/events.js.map +1 -0
  163. package/build/hooks/index.d.ts +2 -0
  164. package/build/hooks/index.d.ts.map +1 -0
  165. package/build/hooks/index.js +2 -0
  166. package/build/hooks/index.js.map +1 -0
  167. package/build/hooks/usePlayer.d.ts +8 -0
  168. package/build/hooks/usePlayer.d.ts.map +1 -0
  169. package/build/hooks/usePlayer.js +10 -0
  170. package/build/hooks/usePlayer.js.map +1 -0
  171. package/build/hooks/useProxy.d.ts +18 -0
  172. package/build/hooks/useProxy.d.ts.map +1 -0
  173. package/build/hooks/useProxy.js +16 -0
  174. package/build/hooks/useProxy.js.map +1 -0
  175. package/build/index.d.ts +32 -0
  176. package/build/index.d.ts.map +1 -0
  177. package/build/index.js +32 -0
  178. package/build/index.js.map +1 -0
  179. package/build/liveConfig.d.ts +13 -0
  180. package/build/liveConfig.d.ts.map +1 -0
  181. package/build/liveConfig.js +2 -0
  182. package/build/liveConfig.js.map +1 -0
  183. package/build/media.d.ts +85 -0
  184. package/build/media.d.ts.map +1 -0
  185. package/build/media.js +2 -0
  186. package/build/media.js.map +1 -0
  187. package/build/mediaControlConfig.d.ts +62 -0
  188. package/build/mediaControlConfig.d.ts.map +1 -0
  189. package/build/mediaControlConfig.js +2 -0
  190. package/build/mediaControlConfig.js.map +1 -0
  191. package/build/mediaTrackRole.d.ts +28 -0
  192. package/build/mediaTrackRole.d.ts.map +1 -0
  193. package/build/mediaTrackRole.js +2 -0
  194. package/build/mediaTrackRole.js.map +1 -0
  195. package/build/modules/AudioSessionModule.d.ts +8 -0
  196. package/build/modules/AudioSessionModule.d.ts.map +1 -0
  197. package/build/modules/AudioSessionModule.js +7 -0
  198. package/build/modules/AudioSessionModule.js.map +1 -0
  199. package/build/modules/BitmovinCastManagerModule.d.ts +11 -0
  200. package/build/modules/BitmovinCastManagerModule.d.ts.map +1 -0
  201. package/build/modules/BitmovinCastManagerModule.js +3 -0
  202. package/build/modules/BitmovinCastManagerModule.js.map +1 -0
  203. package/build/modules/BufferModule.d.ts +16 -0
  204. package/build/modules/BufferModule.d.ts.map +1 -0
  205. package/build/modules/BufferModule.js +3 -0
  206. package/build/modules/BufferModule.js.map +1 -0
  207. package/build/modules/DebugModule.d.ts +8 -0
  208. package/build/modules/DebugModule.d.ts.map +1 -0
  209. package/build/modules/DebugModule.js +3 -0
  210. package/build/modules/DebugModule.js.map +1 -0
  211. package/build/modules/PlayerModule.d.ts +188 -0
  212. package/build/modules/PlayerModule.d.ts.map +1 -0
  213. package/build/modules/PlayerModule.js +3 -0
  214. package/build/modules/PlayerModule.js.map +1 -0
  215. package/build/modules/SourceModule.d.ts +51 -0
  216. package/build/modules/SourceModule.d.ts.map +1 -0
  217. package/build/modules/SourceModule.js +3 -0
  218. package/build/modules/SourceModule.js.map +1 -0
  219. package/build/modules/UuidModule.d.ts +8 -0
  220. package/build/modules/UuidModule.d.ts.map +1 -0
  221. package/build/modules/UuidModule.js +3 -0
  222. package/build/modules/UuidModule.js.map +1 -0
  223. package/build/nativeInstance.d.ts +49 -0
  224. package/build/nativeInstance.d.ts.map +1 -0
  225. package/build/nativeInstance.js +20 -0
  226. package/build/nativeInstance.js.map +1 -0
  227. package/build/network/index.d.ts +50 -0
  228. package/build/network/index.d.ts.map +1 -0
  229. package/build/network/index.js +102 -0
  230. package/build/network/index.js.map +1 -0
  231. package/build/network/networkConfig.d.ts +151 -0
  232. package/build/network/networkConfig.d.ts.map +1 -0
  233. package/build/network/networkConfig.js +21 -0
  234. package/build/network/networkConfig.js.map +1 -0
  235. package/build/network/networkModule.d.ts +29 -0
  236. package/build/network/networkModule.d.ts.map +1 -0
  237. package/build/network/networkModule.js +3 -0
  238. package/build/network/networkModule.js.map +1 -0
  239. package/build/offline/index.d.ts +8 -0
  240. package/build/offline/index.d.ts.map +1 -0
  241. package/build/offline/index.js +8 -0
  242. package/build/offline/index.js.map +1 -0
  243. package/build/offline/offlineContentConfig.d.ts +18 -0
  244. package/build/offline/offlineContentConfig.d.ts.map +1 -0
  245. package/build/offline/offlineContentConfig.js +2 -0
  246. package/build/offline/offlineContentConfig.js.map +1 -0
  247. package/build/offline/offlineContentManager.d.ts +90 -0
  248. package/build/offline/offlineContentManager.d.ts.map +1 -0
  249. package/build/offline/offlineContentManager.js +177 -0
  250. package/build/offline/offlineContentManager.js.map +1 -0
  251. package/build/offline/offlineContentManagerListener.d.ts +174 -0
  252. package/build/offline/offlineContentManagerListener.d.ts.map +1 -0
  253. package/build/offline/offlineContentManagerListener.js +17 -0
  254. package/build/offline/offlineContentManagerListener.js.map +1 -0
  255. package/build/offline/offlineContentOptions.d.ts +29 -0
  256. package/build/offline/offlineContentOptions.d.ts.map +1 -0
  257. package/build/offline/offlineContentOptions.js +2 -0
  258. package/build/offline/offlineContentOptions.js.map +1 -0
  259. package/build/offline/offlineDownloadRequest.d.ts +19 -0
  260. package/build/offline/offlineDownloadRequest.d.ts.map +1 -0
  261. package/build/offline/offlineDownloadRequest.js +2 -0
  262. package/build/offline/offlineDownloadRequest.js.map +1 -0
  263. package/build/offline/offlineModule.d.ts +32 -0
  264. package/build/offline/offlineModule.d.ts.map +1 -0
  265. package/build/offline/offlineModule.js +3 -0
  266. package/build/offline/offlineModule.js.map +1 -0
  267. package/build/offline/offlineSourceOptions.d.ts +12 -0
  268. package/build/offline/offlineSourceOptions.d.ts.map +1 -0
  269. package/build/offline/offlineSourceOptions.js +2 -0
  270. package/build/offline/offlineSourceOptions.js.map +1 -0
  271. package/build/offline/offlineState.d.ts +23 -0
  272. package/build/offline/offlineState.d.ts.map +1 -0
  273. package/build/offline/offlineState.js +24 -0
  274. package/build/offline/offlineState.js.map +1 -0
  275. package/build/playbackConfig.d.ts +88 -0
  276. package/build/playbackConfig.d.ts.map +1 -0
  277. package/build/playbackConfig.js +2 -0
  278. package/build/playbackConfig.js.map +1 -0
  279. package/build/player.d.ts +308 -0
  280. package/build/player.d.ts.map +1 -0
  281. package/build/player.js +445 -0
  282. package/build/player.js.map +1 -0
  283. package/build/playerConfig.d.ts +83 -0
  284. package/build/playerConfig.d.ts.map +1 -0
  285. package/build/playerConfig.js +2 -0
  286. package/build/playerConfig.js.map +1 -0
  287. package/build/remoteControlConfig.d.ts +38 -0
  288. package/build/remoteControlConfig.d.ts.map +1 -0
  289. package/build/remoteControlConfig.js +2 -0
  290. package/build/remoteControlConfig.js.map +1 -0
  291. package/build/source.d.ts +216 -0
  292. package/build/source.d.ts.map +1 -0
  293. package/build/source.js +167 -0
  294. package/build/source.js.map +1 -0
  295. package/build/styleConfig.d.ts +120 -0
  296. package/build/styleConfig.d.ts.map +1 -0
  297. package/build/styleConfig.js +38 -0
  298. package/build/styleConfig.js.map +1 -0
  299. package/build/subtitleFormat.d.ts +27 -0
  300. package/build/subtitleFormat.d.ts.map +1 -0
  301. package/build/subtitleFormat.js +28 -0
  302. package/build/subtitleFormat.js.map +1 -0
  303. package/build/subtitleTrack.d.ts +55 -0
  304. package/build/subtitleTrack.d.ts.map +1 -0
  305. package/build/subtitleTrack.js +2 -0
  306. package/build/subtitleTrack.js.map +1 -0
  307. package/build/thumbnail.d.ts +38 -0
  308. package/build/thumbnail.d.ts.map +1 -0
  309. package/build/thumbnail.js +2 -0
  310. package/build/thumbnail.js.map +1 -0
  311. package/build/tweaksConfig.d.ts +197 -0
  312. package/build/tweaksConfig.d.ts.map +1 -0
  313. package/build/tweaksConfig.js +25 -0
  314. package/build/tweaksConfig.js.map +1 -0
  315. package/build/ui/customMessageHandlerModule.d.ts +27 -0
  316. package/build/ui/customMessageHandlerModule.d.ts.map +1 -0
  317. package/build/ui/customMessageHandlerModule.js +3 -0
  318. package/build/ui/customMessageHandlerModule.js.map +1 -0
  319. package/build/ui/custommessagehandler.d.ts +56 -0
  320. package/build/ui/custommessagehandler.d.ts.map +1 -0
  321. package/build/ui/custommessagehandler.js +54 -0
  322. package/build/ui/custommessagehandler.js.map +1 -0
  323. package/build/ui/custommessagehandlerbridge.d.ts +33 -0
  324. package/build/ui/custommessagehandlerbridge.d.ts.map +1 -0
  325. package/build/ui/custommessagehandlerbridge.js +72 -0
  326. package/build/ui/custommessagehandlerbridge.js.map +1 -0
  327. package/build/ui/custommessagesender.d.ts +5 -0
  328. package/build/ui/custommessagesender.d.ts.map +1 -0
  329. package/build/ui/custommessagesender.js +2 -0
  330. package/build/ui/custommessagesender.js.map +1 -0
  331. package/build/ui/fullscreenHandlerModule.d.ts +20 -0
  332. package/build/ui/fullscreenHandlerModule.d.ts.map +1 -0
  333. package/build/ui/fullscreenHandlerModule.js +3 -0
  334. package/build/ui/fullscreenHandlerModule.js.map +1 -0
  335. package/build/ui/fullscreenhandler.d.ts +18 -0
  336. package/build/ui/fullscreenhandler.d.ts.map +1 -0
  337. package/build/ui/fullscreenhandler.js +2 -0
  338. package/build/ui/fullscreenhandler.js.map +1 -0
  339. package/build/ui/fullscreenhandlerbridge.d.ts +26 -0
  340. package/build/ui/fullscreenhandlerbridge.d.ts.map +1 -0
  341. package/build/ui/fullscreenhandlerbridge.js +67 -0
  342. package/build/ui/fullscreenhandlerbridge.js.map +1 -0
  343. package/build/ui/index.d.ts +3 -0
  344. package/build/ui/index.d.ts.map +1 -0
  345. package/build/ui/index.js +3 -0
  346. package/build/ui/index.js.map +1 -0
  347. package/expo-module.config.json +40 -0
  348. package/ios/AppLifecycleDelegate.swift +25 -0
  349. package/ios/AudioSessionModule.swift +14 -40
  350. package/ios/BitmovinCastManagerModule.swift +30 -69
  351. package/ios/BufferModule.swift +26 -62
  352. package/ios/CustomMessageHandlerBridge.swift +11 -18
  353. package/ios/CustomMessageHandlerModule.swift +61 -63
  354. package/ios/DebugModule.swift +6 -27
  355. package/ios/DrmModule.swift +105 -379
  356. package/ios/Event+JSON.swift +1 -0
  357. package/ios/FullscreenHandlerBridge.swift +12 -5
  358. package/ios/FullscreenHandlerModule.swift +73 -57
  359. package/ios/LockedBox.swift +21 -0
  360. package/ios/ModuleRegistry+Generics.swift +11 -0
  361. package/ios/NetworkModule.swift +78 -82
  362. package/ios/OfflineContentManagerBridge.swift +11 -38
  363. package/ios/OfflineModule.swift +136 -454
  364. package/ios/PlayerAnalyticsModule.swift +24 -52
  365. package/ios/PlayerModule.swift +192 -770
  366. package/ios/RCTConvert+BitmovinPlayer.swift +38 -312
  367. package/ios/RNBitmovinPlayer.h +1 -8
  368. package/ios/RNBitmovinPlayer.podspec +47 -0
  369. package/ios/RNPlayerView.swift +600 -77
  370. package/ios/RNPlayerViewManager.swift +96 -210
  371. package/ios/Registry.swift +2 -2
  372. package/ios/ResultWaiter.swift +66 -0
  373. package/ios/SourceModule.swift +104 -223
  374. package/ios/UuidModule.swift +9 -18
  375. package/package.json +67 -71
  376. package/plugin/build/FeatureFlags.d.ts +24 -0
  377. package/plugin/build/FeatureFlags.js +2 -0
  378. package/plugin/build/index.d.ts +7 -0
  379. package/plugin/build/index.js +10 -0
  380. package/plugin/build/withAppGradleDependencies.d.ts +7 -0
  381. package/plugin/build/withAppGradleDependencies.js +49 -0
  382. package/plugin/build/withBitmovinAndroidConfig.d.ts +7 -0
  383. package/plugin/build/withBitmovinAndroidConfig.js +159 -0
  384. package/plugin/build/withBitmovinConfig.d.ts +7 -0
  385. package/plugin/build/withBitmovinConfig.js +21 -0
  386. package/plugin/build/withBitmovinIosConfig.d.ts +7 -0
  387. package/plugin/build/withBitmovinIosConfig.js +53 -0
  388. package/plugin/src/FeatureFlags.ts +21 -0
  389. package/plugin/src/index.ts +9 -0
  390. package/plugin/src/withAppGradleDependencies.ts +80 -0
  391. package/plugin/src/withBitmovinAndroidConfig.ts +224 -0
  392. package/plugin/src/withBitmovinConfig.ts +24 -0
  393. package/plugin/src/withBitmovinIosConfig.ts +71 -0
  394. package/plugin/tsconfig.json +9 -0
  395. package/plugin/tsconfig.tsbuildinfo +1 -0
  396. package/prettier.config.js +7 -0
  397. package/scripts/format-android.sh +2 -0
  398. package/scripts/format-swift.sh +3 -0
  399. package/scripts/lint-android.sh +2 -0
  400. package/scripts/lint-swift.sh +3 -0
  401. package/scripts/pre-commit.sh +14 -0
  402. package/scripts/setup-hooks.sh +58 -0
  403. package/src/BitmovinPlayerReactNative.types.ts +19 -0
  404. package/src/adaptationConfig.ts +1 -1
  405. package/src/advertising.ts +1 -1
  406. package/src/analytics/config.ts +4 -4
  407. package/src/analytics/player.ts +4 -6
  408. package/src/analytics/playerAnalyticsModule.ts +19 -0
  409. package/src/audioSession.ts +4 -6
  410. package/src/audioTrack.ts +1 -1
  411. package/src/bitmovinCastManager.ts +14 -10
  412. package/src/bufferApi.ts +1 -3
  413. package/src/bufferConfig.ts +2 -2
  414. package/src/components/PlayerView/events.ts +92 -94
  415. package/src/components/PlayerView/index.tsx +109 -159
  416. package/src/components/PlayerView/native.ts +24 -11
  417. package/src/components/PlayerView/nativeEvents.ts +113 -94
  418. package/src/components/PlayerView/pictureInPictureConfig.ts +1 -1
  419. package/src/components/PlayerView/playerViewConfig.ts +4 -8
  420. package/src/components/PlayerView/properties.ts +23 -22
  421. package/src/debug.ts +1 -3
  422. package/src/decoder/decoderConfig.ts +3 -3
  423. package/src/decoder/decoderConfigModule.ts +62 -0
  424. package/src/decoder/index.ts +32 -16
  425. package/src/drm/drmModule.ts +84 -0
  426. package/src/drm/fairplayConfig.ts +1 -1
  427. package/src/drm/index.ts +130 -40
  428. package/src/drm/widevineConfig.ts +5 -5
  429. package/src/events.ts +47 -41
  430. package/src/hooks/useProxy.ts +13 -20
  431. package/src/mediaControlConfig.ts +1 -1
  432. package/src/modules/AudioSessionModule.ts +13 -0
  433. package/src/modules/BitmovinCastManagerModule.ts +14 -0
  434. package/src/modules/BufferModule.ts +18 -0
  435. package/src/modules/DebugModule.ts +9 -0
  436. package/src/modules/PlayerModule.ts +251 -0
  437. package/src/modules/SourceModule.ts +74 -0
  438. package/src/modules/UuidModule.ts +9 -0
  439. package/src/nativeInstance.ts +3 -3
  440. package/src/network/index.ts +42 -15
  441. package/src/network/networkConfig.ts +3 -3
  442. package/src/network/networkModule.ts +51 -0
  443. package/src/offline/offlineContentConfig.ts +1 -1
  444. package/src/offline/offlineContentManager.ts +15 -50
  445. package/src/offline/offlineContentManagerListener.ts +20 -23
  446. package/src/offline/offlineContentOptions.ts +2 -2
  447. package/src/offline/offlineDownloadRequest.ts +1 -1
  448. package/src/offline/offlineModule.ts +46 -0
  449. package/src/offline/offlineSourceOptions.ts +2 -2
  450. package/src/offline/offlineState.ts +1 -1
  451. package/src/playbackConfig.ts +5 -6
  452. package/src/player.ts +53 -48
  453. package/src/source.ts +15 -14
  454. package/src/styleConfig.ts +5 -5
  455. package/src/subtitleFormat.ts +5 -5
  456. package/src/subtitleTrack.ts +1 -1
  457. package/src/tweaksConfig.ts +16 -16
  458. package/src/ui/customMessageHandlerModule.ts +46 -0
  459. package/src/ui/custommessagehandlerbridge.ts +45 -18
  460. package/src/ui/fullscreenHandlerModule.ts +35 -0
  461. package/src/ui/fullscreenhandlerbridge.ts +35 -15
  462. package/tsconfig.json +9 -0
  463. package/typedoc.json +23 -0
  464. package/RNBitmovinPlayer.podspec +0 -26
  465. package/android/src/main/java/com/bitmovin/player/reactnative/BitmovinBaseModule.kt +0 -114
  466. package/android/src/main/java/com/bitmovin/player/reactnative/EventRelay.kt +0 -47
  467. package/android/src/main/java/com/bitmovin/player/reactnative/RNPlayerViewPackage.kt +0 -48
  468. package/android/src/main/java/com/bitmovin/player/reactnative/extensions/ReactContextExtension.kt +0 -24
  469. package/android/src/main/java/com/bitmovin/player/reactnative/extensions/ReadableArray.kt +0 -20
  470. package/android/src/main/java/com/bitmovin/player/reactnative/extensions/ReadableMap.kt +0 -15
  471. package/android/src/main/java/com/bitmovin/player/reactnative/extensions/ReadableMapExtension.kt +0 -57
  472. package/android/src/main/java/com/bitmovin/player/reactnative/extensions/WritableMap.kt +0 -27
  473. package/android/src/main/java/com/bitmovin/player/reactnative/ui/CustomMessageHandlerModule.kt +0 -86
  474. package/android/src/main/java/com/bitmovin/player/reactnative/ui/FullscreenHandlerModule.kt +0 -78
  475. package/ios/AudioSessionModule.m +0 -10
  476. package/ios/BitmovinCastManagerModule.m +0 -14
  477. package/ios/BufferModule.m +0 -8
  478. package/ios/CustomMessageHandlerModule.m +0 -10
  479. package/ios/DebugModule.m +0 -7
  480. package/ios/DrmModule.m +0 -16
  481. package/ios/FullscreenHandlerModule.m +0 -10
  482. package/ios/NetworkModule.m +0 -10
  483. package/ios/OfflineModule.m +0 -19
  484. package/ios/PlayerAnalyticsModule.m +0 -8
  485. package/ios/PlayerModule.m +0 -130
  486. package/ios/PreprocessHttpRequestDelegateBridge.swift +0 -30
  487. package/ios/RCTBridge+Generics.swift +0 -6
  488. package/ios/RNBitmovinPlayer.xcodeproj/project.pbxproj +0 -303
  489. package/ios/RNPlayerView+PlayerListener.swift +0 -229
  490. package/ios/RNPlayerView+UserInterfaceListener.swift +0 -35
  491. package/ios/RNPlayerViewManager.m +0 -79
  492. package/ios/SourceModule.m +0 -42
  493. package/ios/UuidModule.m +0 -9
  494. package/lib/index.d.mts +0 -4303
  495. package/lib/index.d.ts +0 -4303
  496. package/lib/index.js +0 -1895
  497. package/lib/index.mjs +0 -1836
@@ -5,6 +5,8 @@ import com.bitmovin.analytics.api.AnalyticsConfig
5
5
  import com.bitmovin.analytics.api.CustomData
6
6
  import com.bitmovin.analytics.api.DefaultMetadata
7
7
  import com.bitmovin.analytics.api.SourceMetadata
8
+ import com.bitmovin.player.reactnative.extensions.get
9
+ import com.bitmovin.player.reactnative.extensions.set
8
10
  import com.bitmovin.player.api.BandwidthMeterType
9
11
  import com.bitmovin.player.api.DeviceDescription.DeviceName
10
12
  import com.bitmovin.player.api.ForceReuseVideoCodecReason
@@ -37,7 +39,6 @@ import com.bitmovin.player.api.media.AdaptationConfig
37
39
  import com.bitmovin.player.api.media.MediaTrackRole
38
40
  import com.bitmovin.player.api.media.MediaType
39
41
  import com.bitmovin.player.api.media.audio.AudioTrack
40
- import com.bitmovin.player.api.media.audio.quality.AudioQuality
41
42
  import com.bitmovin.player.api.media.subtitle.SubtitleTrack
42
43
  import com.bitmovin.player.api.media.thumbnail.Thumbnail
43
44
  import com.bitmovin.player.api.media.thumbnail.ThumbnailTrack
@@ -58,25 +59,21 @@ import com.bitmovin.player.api.ui.ScalingMode
58
59
  import com.bitmovin.player.api.ui.StyleConfig
59
60
  import com.bitmovin.player.api.ui.SurfaceType
60
61
  import com.bitmovin.player.api.ui.UiConfig
61
- import com.bitmovin.player.reactnative.BitmovinCastManagerOptions
62
62
  import com.bitmovin.player.reactnative.PictureInPictureConfig
63
63
  import com.bitmovin.player.reactnative.RNBufferLevels
64
64
  import com.bitmovin.player.reactnative.RNPlayerViewConfigWrapper
65
65
  import com.bitmovin.player.reactnative.RNStyleConfigWrapper
66
66
  import com.bitmovin.player.reactnative.UserInterfaceType
67
- import com.bitmovin.player.reactnative.extensions.get
67
+ import com.bitmovin.player.reactnative.extensions.getArray
68
68
  import com.bitmovin.player.reactnative.extensions.getBooleanOrNull
69
69
  import com.bitmovin.player.reactnative.extensions.getDoubleOrNull
70
+ import com.bitmovin.player.reactnative.extensions.getInt
71
+ import com.bitmovin.player.reactnative.extensions.getMap
70
72
  import com.bitmovin.player.reactnative.extensions.getName
71
- import com.bitmovin.player.reactnative.extensions.mapToReactArray
72
- import com.bitmovin.player.reactnative.extensions.putBoolean
73
- import com.bitmovin.player.reactnative.extensions.putDouble
74
- import com.bitmovin.player.reactnative.extensions.putInt
75
- import com.bitmovin.player.reactnative.extensions.set
73
+ import com.bitmovin.player.reactnative.extensions.getString
76
74
  import com.bitmovin.player.reactnative.extensions.toBase64DataUri
77
75
  import com.bitmovin.player.reactnative.extensions.toMap
78
76
  import com.bitmovin.player.reactnative.extensions.toMapList
79
- import com.bitmovin.player.reactnative.extensions.toReadableMap
80
77
  import com.bitmovin.player.reactnative.extensions.withArray
81
78
  import com.bitmovin.player.reactnative.extensions.withBoolean
82
79
  import com.bitmovin.player.reactnative.extensions.withDouble
@@ -84,13 +81,15 @@ import com.bitmovin.player.reactnative.extensions.withInt
84
81
  import com.bitmovin.player.reactnative.extensions.withMap
85
82
  import com.bitmovin.player.reactnative.extensions.withString
86
83
  import com.bitmovin.player.reactnative.extensions.withStringArray
87
- import com.facebook.react.bridge.*
88
84
  import java.util.UUID
89
85
 
90
86
  /**
91
- * Converts an arbitrary `json` to `PlayerConfig`.
87
+ * Filters out null values from a map to ensure compatibility with Expo modules
92
88
  */
93
- fun ReadableMap.toPlayerConfig(): PlayerConfig = PlayerConfig(key = getString("licenseKey")).apply {
89
+ private fun Map<String, Any?>.filterNotNullValues(): Map<String, Any> =
90
+ this.filterValues { it != null }.mapValues { it.value!! }
91
+
92
+ fun Map<String, Any?>.toPlayerConfig(): PlayerConfig = PlayerConfig(key = getString("licenseKey")).apply {
94
93
  withMap("playbackConfig") { playbackConfig = it.toPlaybackConfig() }
95
94
  withMap("styleConfig") { styleConfig = it.toStyleConfig() }
96
95
  withMap("tweaksConfig") { tweaksConfig = it.toTweaksConfig() }
@@ -102,72 +101,48 @@ fun ReadableMap.toPlayerConfig(): PlayerConfig = PlayerConfig(key = getString("l
102
101
  withMap("networkConfig") { networkConfig = it.toNetworkConfig() }
103
102
  }
104
103
 
105
- /**
106
- * Converts any JS object into a `BufferMediaTypeConfig` object.
107
- */
108
- fun ReadableMap.toBufferMediaTypeConfig(): BufferMediaTypeConfig = BufferMediaTypeConfig().apply {
104
+ fun Map<String, Any?>.toBufferMediaTypeConfig(): BufferMediaTypeConfig = BufferMediaTypeConfig().apply {
109
105
  withDouble("forwardDuration") { forwardDuration = it }
110
106
  }
111
107
 
112
- /**
113
- * Converts any JS object into a `BufferConfig` object.
114
- */
115
- fun ReadableMap.toBufferConfig(): BufferConfig = BufferConfig().apply {
108
+ fun Map<String, Any?>.toBufferConfig(): BufferConfig = BufferConfig().apply {
116
109
  withMap("audioAndVideo") { audioAndVideo = it.toBufferMediaTypeConfig() }
117
110
  withDouble("restartThreshold") { restartThreshold = it }
118
111
  withDouble("startupThreshold") { startupThreshold = it }
119
112
  }
120
113
 
121
- /**
122
- * Converts an arbitrary [ReadableMap] to a [RemoteControlConfig].
123
- */
124
- private fun ReadableMap.toRemoteControlConfig(): RemoteControlConfig = RemoteControlConfig().apply {
114
+ private fun Map<String, Any?>.toRemoteControlConfig(): RemoteControlConfig = RemoteControlConfig().apply {
125
115
  withString("receiverStylesheetUrl") { receiverStylesheetUrl = it }
126
- withMap("customReceiverConfig") { customReceiverConfig = it.toMap() }
116
+ withMap("customReceiverConfig") { customReceiverConfig = it.mapValues { entry -> entry.value as? String } }
127
117
  withBoolean("isCastEnabled") { isCastEnabled = it }
128
118
  withBoolean("sendManifestRequestsWithCredentials") { sendManifestRequestsWithCredentials = it }
129
119
  withBoolean("sendSegmentRequestsWithCredentials") { sendSegmentRequestsWithCredentials = it }
130
120
  withBoolean("sendDrmLicenseRequestsWithCredentials") { sendDrmLicenseRequestsWithCredentials = it }
131
121
  }
132
122
 
133
- /**
134
- * Converts an arbitrary `json` to `SourceOptions`.
135
- */
136
- fun ReadableMap.toSourceOptions(): SourceOptions = SourceOptions(
123
+ fun Map<String, Any?>.toSourceOptions(): SourceOptions = SourceOptions(
137
124
  startOffset = getDoubleOrNull("startOffset"),
138
125
  startOffsetTimelineReference = getString("startOffsetTimelineReference")?.toTimelineReferencePoint(),
139
126
  )
140
127
 
141
- /**
142
- * Converts an arbitrary `json` to `TimelineReferencePoint`.
143
- */
144
128
  private fun String.toTimelineReferencePoint(): TimelineReferencePoint? = when (this) {
145
129
  "start" -> TimelineReferencePoint.Start
146
130
  "end" -> TimelineReferencePoint.End
147
131
  else -> null
148
132
  }
149
133
 
150
- /**
151
- * Converts an arbitrary `json` to `AdaptationConfig`.
152
- */
153
- private fun ReadableMap.toAdaptationConfig(): AdaptationConfig = AdaptationConfig().apply {
134
+ private fun Map<String, Any?>.toAdaptationConfig(): AdaptationConfig = AdaptationConfig().apply {
154
135
  withInt("maxSelectableBitrate") { maxSelectableVideoBitrate = it }
155
136
  withInt("initialBandwidthEstimateOverride") { initialBandwidthEstimateOverride = it.toLong(); }
156
137
  }
157
138
 
158
- /**
159
- * Converts any JS object into a `PlaybackConfig` object.
160
- */
161
- fun ReadableMap.toPlaybackConfig(): PlaybackConfig = PlaybackConfig().apply {
139
+ fun Map<String, Any?>.toPlaybackConfig(): PlaybackConfig = PlaybackConfig().apply {
162
140
  withBoolean("isAutoplayEnabled") { isAutoplayEnabled = it }
163
141
  withBoolean("isMuted") { isMuted = it }
164
142
  withBoolean("isTimeShiftEnabled") { isTimeShiftEnabled = it }
165
143
  }
166
144
 
167
- /**
168
- * Converts any JS object into a `StyleConfig` object.
169
- */
170
- fun ReadableMap.toStyleConfig(): StyleConfig = StyleConfig().apply {
145
+ fun Map<String, Any?>.toStyleConfig(): StyleConfig = StyleConfig().apply {
171
146
  withBoolean("isUiEnabled") { isUiEnabled = it }
172
147
  getString("playerUiCss")?.takeIf { it.isNotEmpty() }?.let { playerUiCss = it }
173
148
  getString("supplementalPlayerUiCss")?.takeIf { it.isNotEmpty() }?.let { supplementalPlayerUiCss = it }
@@ -175,9 +150,6 @@ fun ReadableMap.toStyleConfig(): StyleConfig = StyleConfig().apply {
175
150
  withString("scalingMode") { scalingMode = ScalingMode.valueOf(it) }
176
151
  }
177
152
 
178
- /**
179
- * Converts any JS string into an `ForceReuseVideoCodecReason` enum value.
180
- */
181
153
  private fun String.toForceReuseVideoCodecReason(): ForceReuseVideoCodecReason? = when (this) {
182
154
  "ColorInfoMismatch" -> ForceReuseVideoCodecReason.ColorInfoMismatch
183
155
  "MaxInputSizeExceeded" -> ForceReuseVideoCodecReason.MaxInputSizeExceeded
@@ -185,10 +157,7 @@ private fun String.toForceReuseVideoCodecReason(): ForceReuseVideoCodecReason? =
185
157
  else -> null
186
158
  }
187
159
 
188
- /**
189
- * Converts any JS object into a `TweaksConfig` object.
190
- */
191
- fun ReadableMap.toTweaksConfig(): TweaksConfig = TweaksConfig().apply {
160
+ fun Map<String, Any?>.toTweaksConfig(): TweaksConfig = TweaksConfig().apply {
192
161
  withDouble("timeChangedInterval") { timeChangedInterval = it }
193
162
  withInt("bandwidthEstimateWeightLimit") {
194
163
  bandwidthMeterType = BandwidthMeterType.Default(
@@ -217,39 +186,27 @@ fun ReadableMap.toTweaksConfig(): TweaksConfig = TweaksConfig().apply {
217
186
  }
218
187
  }
219
188
 
220
- /**
221
- * Converts any JS object into an `AdvertisingConfig` object.
222
- */
223
- fun ReadableMap.toAdvertisingConfig(): AdvertisingConfig? {
189
+ fun Map<String, Any?>.toAdvertisingConfig(): AdvertisingConfig? {
224
190
  return AdvertisingConfig(
225
191
  getArray("schedule")?.toMapList()?.mapNotNull { it?.toAdItem() } ?: return null,
226
192
  )
227
193
  }
228
194
 
229
- /**
230
- * Converts any JS object into an `AdItem` object.
231
- */
232
- fun ReadableMap.toAdItem(): AdItem? {
195
+ fun Map<String, Any?>.toAdItem(): AdItem? {
233
196
  return AdItem(
234
- sources = getArray("sources") ?.toMapList()?.mapNotNull { it?.toAdSource() }?.toTypedArray() ?: return null,
197
+ sources = getArray("sources")?.toMapList()?.mapNotNull { it?.toAdSource() }?.toTypedArray() ?: return null,
235
198
  position = getString("position") ?: "pre",
236
199
  preloadOffset = getDoubleOrNull("preloadOffset") ?: 0.0,
237
200
  )
238
201
  }
239
202
 
240
- /**
241
- * Converts any JS object into an `AdSource` object.
242
- */
243
- fun ReadableMap.toAdSource(): AdSource? {
203
+ fun Map<String, Any?>.toAdSource(): AdSource? {
244
204
  return AdSource(
245
205
  type = getString("type")?.toAdSourceType() ?: return null,
246
206
  tag = getString("tag") ?: return null,
247
207
  )
248
208
  }
249
209
 
250
- /**
251
- * Converts any JS string into an `AdSourceType` enum value.
252
- */
253
210
  private fun String.toAdSourceType(): AdSourceType? = when (this) {
254
211
  "bitmovin" -> AdSourceType.Bitmovin
255
212
  "ima" -> AdSourceType.Ima
@@ -258,10 +215,7 @@ private fun String.toAdSourceType(): AdSourceType? = when (this) {
258
215
  else -> null
259
216
  }
260
217
 
261
- /**
262
- * Converts an arbitrary `json` to `SourceConfig`.
263
- */
264
- fun ReadableMap.toSourceConfig(): SourceConfig? {
218
+ fun Map<String, Any?>.toSourceConfig(): SourceConfig? {
265
219
  val url = getString("url") ?: return null
266
220
  val type = getString("type")?.toSourceType() ?: return null
267
221
  return SourceConfig(url, type).apply {
@@ -270,8 +224,8 @@ fun ReadableMap.toSourceConfig(): SourceConfig? {
270
224
  withString("poster") { posterSource = it }
271
225
  withBoolean("isPosterPersistent") { isPosterPersistent = it }
272
226
  withArray("subtitleTracks") { subtitleTracks ->
273
- for (i in 0 until subtitleTracks.size()) {
274
- subtitleTracks.getMap(i)?.toSubtitleTrack()?.let {
227
+ subtitleTracks.indices.forEach { subtitleTrack ->
228
+ subtitleTracks.getMap(subtitleTrack)?.toSubtitleTrack()?.let {
275
229
  addSubtitleTrack(it)
276
230
  }
277
231
  }
@@ -282,9 +236,6 @@ fun ReadableMap.toSourceConfig(): SourceConfig? {
282
236
  }
283
237
  }
284
238
 
285
- /**
286
- * Converts an arbitrary `json` to `SourceType`.
287
- */
288
239
  fun String.toSourceType(): SourceType? = when (this) {
289
240
  "dash" -> SourceType.Dash
290
241
  "hls" -> SourceType.Hls
@@ -293,293 +244,252 @@ fun String.toSourceType(): SourceType? = when (this) {
293
244
  else -> null
294
245
  }
295
246
 
296
- /**
297
- * Converts any given `Source` object into its `json` representation.
298
- */
299
- fun Source.toJson(): WritableMap = Arguments.createMap().apply {
300
- putDouble("duration", duration)
301
- putBoolean("isActive", isActive)
302
- putBoolean("isAttachedToPlayer", isAttachedToPlayer)
303
- putInt("loadingState", loadingState.ordinal)
304
- putMap("metadata", config.metadata?.toReadableMap())
305
- }
247
+ fun Source.toJson(): Map<String, Any> = mapOf(
248
+ "duration" to duration,
249
+ "isActive" to isActive,
250
+ "isAttachedToPlayer" to isAttachedToPlayer,
251
+ "loadingState" to loadingState.ordinal,
252
+ "metadata" to (config.metadata ?: emptyMap<String, Any>()),
253
+ ).filterNotNullValues()
306
254
 
307
- /**
308
- * Converts any given `SeekPosition` object into its `json` representation.
309
- */
310
- fun SeekPosition.toJson(): WritableMap = Arguments.createMap().apply {
311
- putDouble("time", time)
312
- putMap("source", source.toJson())
313
- }
255
+ fun SeekPosition.toJson(): Map<String, Any> = mapOf(
256
+ "time" to time,
257
+ "source" to source.toJson(),
258
+ ).filterNotNullValues()
259
+
260
+ fun SourceEvent.toJson(): Map<String, Any> {
261
+ val baseMap = mutableMapOf<String, Any?>(
262
+ "name" to getName(),
263
+ "timestamp" to timestamp.toDouble(),
264
+ )
314
265
 
315
- /**
316
- * Converts any given `SourceEvent` object into its `json` representation.
317
- */
318
- fun SourceEvent.toJson(): WritableMap {
319
- val json = Arguments.createMap()
320
- json.putString("name", getName())
321
- json.putDouble("timestamp", timestamp.toDouble())
322
266
  when (this) {
323
267
  is SourceEvent.Load -> {
324
- json.putMap("source", source.toJson())
268
+ baseMap["source"] = source.toJson()
325
269
  }
326
270
 
327
271
  is SourceEvent.Loaded -> {
328
- json.putMap("source", source.toJson())
272
+ baseMap["source"] = source.toJson()
329
273
  }
330
274
 
331
275
  is SourceEvent.Error -> {
332
- json.putInt("code", code.value)
333
- json.putString("message", message)
276
+ baseMap["code"] = code.value
277
+ baseMap["message"] = message
334
278
  }
335
279
 
336
280
  is SourceEvent.Warning -> {
337
- json.putInt("code", code.value)
338
- json.putString("message", message)
281
+ baseMap["code"] = code.value
282
+ baseMap["message"] = message
339
283
  }
340
284
 
341
285
  is SourceEvent.AudioTrackAdded -> {
342
- json.putMap("audioTrack", audioTrack.toJson())
286
+ baseMap["audioTrack"] = audioTrack.toJson()
343
287
  }
344
288
 
345
289
  is SourceEvent.AudioTrackChanged -> {
346
- json.putMap("oldAudioTrack", oldAudioTrack?.toJson())
347
- json.putMap("newAudioTrack", newAudioTrack?.toJson())
290
+ baseMap["oldAudioTrack"] = oldAudioTrack?.toJson()
291
+ baseMap["newAudioTrack"] = newAudioTrack?.toJson()
348
292
  }
349
293
 
350
294
  is SourceEvent.AudioTrackRemoved -> {
351
- json.putMap("audioTrack", audioTrack.toJson())
295
+ baseMap["audioTrack"] = audioTrack.toJson()
352
296
  }
353
297
 
354
298
  is SourceEvent.SubtitleTrackAdded -> {
355
- json.putMap("subtitleTrack", subtitleTrack.toJson())
299
+ baseMap["subtitleTrack"] = subtitleTrack.toJson()
356
300
  }
357
301
 
358
302
  is SourceEvent.SubtitleTrackRemoved -> {
359
- json.putMap("subtitleTrack", subtitleTrack.toJson())
303
+ baseMap["subtitleTrack"] = subtitleTrack.toJson()
360
304
  }
361
305
 
362
306
  is SourceEvent.SubtitleTrackChanged -> {
363
- json.putMap("oldSubtitleTrack", oldSubtitleTrack?.toJson())
364
- json.putMap("newSubtitleTrack", newSubtitleTrack?.toJson())
307
+ baseMap["oldSubtitleTrack"] = oldSubtitleTrack?.toJson()
308
+ baseMap["newSubtitleTrack"] = newSubtitleTrack?.toJson()
365
309
  }
366
310
 
367
311
  is SourceEvent.DownloadFinished -> {
368
- json.putDouble("downloadTime", downloadTime)
369
- json.putString("requestType", downloadType.toString())
370
- json.putInt("httpStatus", httpStatus)
371
- json.putBoolean("isSuccess", isSuccess)
312
+ baseMap["downloadTime"] = downloadTime
313
+ baseMap["requestType"] = downloadType.toString()
314
+ baseMap["httpStatus"] = httpStatus
315
+ baseMap["isSuccess"] = isSuccess
372
316
  lastRedirectLocation?.let {
373
- json.putString("lastRedirectLocation", it)
317
+ baseMap["lastRedirectLocation"] = it
374
318
  }
375
- json.putDouble("size", size.toDouble())
376
- json.putString("url", url)
319
+ baseMap["size"] = size.toDouble()
320
+ baseMap["url"] = url
377
321
  }
378
322
 
379
323
  is SourceEvent.VideoDownloadQualityChanged -> {
380
- json.putMap("newVideoQuality", newVideoQuality?.toJson())
381
- json.putMap("oldVideoQuality", oldVideoQuality?.toJson())
324
+ baseMap["newVideoQuality"] = newVideoQuality?.toJson()
325
+ baseMap["oldVideoQuality"] = oldVideoQuality?.toJson()
382
326
  }
383
327
 
384
328
  else -> {
385
329
  // Event is not supported yet or does not have any additional data
386
330
  }
387
331
  }
388
- return json
332
+ return baseMap.filterNotNullValues()
389
333
  }
390
334
 
391
- /**
392
- * Converts any given `PlayerEvent` object into its `json` representation.
393
- */
394
- fun PlayerEvent.toJson(): WritableMap {
395
- val json = Arguments.createMap()
396
- json.putString("name", getName())
397
- json.putDouble("timestamp", timestamp.toDouble())
335
+ fun PlayerEvent.toJson(): Map<String, Any> {
336
+ val baseMap = mutableMapOf<String, Any?>(
337
+ "name" to getName(),
338
+ "timestamp" to timestamp.toDouble(),
339
+ )
340
+
398
341
  when (this) {
399
342
  is PlayerEvent.Error -> {
400
- json.putInt("code", code.value)
401
- json.putString("message", message)
343
+ baseMap["code"] = code.value
344
+ baseMap["message"] = message
402
345
  }
403
346
 
404
347
  is PlayerEvent.Warning -> {
405
- json.putInt("code", code.value)
406
- json.putString("message", message)
348
+ baseMap["code"] = code.value
349
+ baseMap["message"] = message
407
350
  }
408
351
 
409
352
  is PlayerEvent.Play -> {
410
- json.putDouble("time", time)
353
+ baseMap["time"] = time
411
354
  }
412
355
 
413
356
  is PlayerEvent.Playing -> {
414
- json.putDouble("time", time)
357
+ baseMap["time"] = time
415
358
  }
416
359
 
417
360
  is PlayerEvent.Paused -> {
418
- json.putDouble("time", time)
361
+ baseMap["time"] = time
419
362
  }
420
363
 
421
364
  is PlayerEvent.TimeChanged -> {
422
- json.putDouble("currentTime", time)
365
+ baseMap["currentTime"] = time
423
366
  }
424
367
 
425
368
  is PlayerEvent.Seek -> {
426
- json.putMap("from", from.toJson())
427
- json.putMap("to", to.toJson())
369
+ baseMap["from"] = from.toJson()
370
+ baseMap["to"] = to.toJson()
428
371
  }
429
372
 
430
373
  is PlayerEvent.TimeShift -> {
431
- json.putDouble("position", position)
432
- json.putDouble("targetPosition", target)
374
+ baseMap["position"] = position
375
+ baseMap["targetPosition"] = target
433
376
  }
434
377
 
435
378
  is PlayerEvent.PictureInPictureAvailabilityChanged -> {
436
- json.putBoolean("isPictureInPictureAvailable", isPictureInPictureAvailable)
379
+ baseMap["isPictureInPictureAvailable"] = isPictureInPictureAvailable
437
380
  }
438
381
 
439
382
  is PlayerEvent.AdBreakFinished -> {
440
- json.putMap("adBreak", adBreak?.toJson())
383
+ baseMap["adBreak"] = adBreak?.toJson()
441
384
  }
442
385
 
443
386
  is PlayerEvent.AdBreakStarted -> {
444
- json.putMap("adBreak", adBreak?.toJson())
387
+ baseMap["adBreak"] = adBreak?.toJson()
445
388
  }
446
389
 
447
390
  is PlayerEvent.AdClicked -> {
448
- json.putString("clickThroughUrl", clickThroughUrl)
391
+ baseMap["clickThroughUrl"] = clickThroughUrl
449
392
  }
450
393
 
451
394
  is PlayerEvent.AdError -> {
452
- json.putInt("code", code)
453
- json.putString("message", message)
454
- json.putMap("adConfig", adConfig?.toJson())
455
- json.putMap("adItem", adItem?.toJson())
395
+ baseMap["code"] = code
396
+ baseMap["message"] = message
397
+ baseMap["adConfig"] = adConfig?.toJson()
398
+ baseMap["adItem"] = adItem?.toJson()
456
399
  }
457
400
 
458
401
  is PlayerEvent.AdFinished -> {
459
- json.putMap("ad", ad?.toJson())
402
+ baseMap["ad"] = ad?.toJson()
460
403
  }
461
404
 
462
405
  is PlayerEvent.AdManifestLoad -> {
463
- json.putMap("adBreak", adBreak?.toJson())
464
- json.putMap("adConfig", adConfig.toJson())
406
+ baseMap["adBreak"] = adBreak?.toJson()
407
+ baseMap["adConfig"] = adConfig.toJson()
465
408
  }
466
409
 
467
410
  is PlayerEvent.AdManifestLoaded -> {
468
- json.putMap("adBreak", adBreak?.toJson())
469
- json.putMap("adConfig", adConfig.toJson())
470
- json.putDouble("downloadTime", downloadTime.toDouble())
411
+ baseMap["adBreak"] = adBreak?.toJson()
412
+ baseMap["adConfig"] = adConfig.toJson()
413
+ baseMap["downloadTime"] = downloadTime.toDouble()
471
414
  }
472
415
 
473
416
  is PlayerEvent.AdQuartile -> {
474
- json.putString("quartile", quartile.toJson())
417
+ baseMap["quartile"] = quartile.toJson()
475
418
  }
476
419
 
477
420
  is PlayerEvent.AdScheduled -> {
478
- json.putInt("numberOfAds", numberOfAds)
421
+ baseMap["numberOfAds"] = numberOfAds
479
422
  }
480
423
 
481
424
  is PlayerEvent.AdSkipped -> {
482
- json.putMap("ad", ad?.toJson())
425
+ baseMap["ad"] = ad?.toJson()
483
426
  }
484
427
 
485
428
  is PlayerEvent.AdStarted -> {
486
- json.putMap("ad", ad?.toJson())
487
- json.putString("clickThroughUrl", clickThroughUrl)
488
- json.putString("clientType", clientType?.toJson())
489
- json.putDouble("duration", duration)
490
- json.putInt("indexInQueue", indexInQueue)
491
- json.putString("position", position)
492
- json.putDouble("skipOffset", skipOffset)
493
- json.putDouble("timeOffset", timeOffset)
429
+ baseMap["ad"] = ad?.toJson()
430
+ baseMap["clickThroughUrl"] = clickThroughUrl
431
+ baseMap["clientType"] = clientType?.toJson()
432
+ baseMap["duration"] = duration
433
+ baseMap["indexInQueue"] = indexInQueue
434
+ baseMap["position"] = position
435
+ baseMap["skipOffset"] = skipOffset
436
+ baseMap["timeOffset"] = timeOffset
494
437
  }
495
438
 
496
439
  is PlayerEvent.VideoPlaybackQualityChanged -> {
497
- json.putMap("newVideoQuality", newVideoQuality?.toJson())
498
- json.putMap("oldVideoQuality", oldVideoQuality?.toJson())
440
+ baseMap["newVideoQuality"] = newVideoQuality?.toJson()
441
+ baseMap["oldVideoQuality"] = oldVideoQuality?.toJson()
499
442
  }
500
443
 
501
444
  is PlayerEvent.CastWaitingForDevice -> {
502
- json.putMap("castPayload", castPayload.toJson())
445
+ baseMap["castPayload"] = castPayload.toJson()
503
446
  }
504
447
 
505
448
  is PlayerEvent.CastStarted -> {
506
- json.putString("deviceName", deviceName)
449
+ baseMap["deviceName"] = deviceName
507
450
  }
508
451
 
509
452
  is PlayerEvent.CueEnter -> {
510
- json.putDouble("start", start)
511
- json.putDouble("end", end)
512
- json.putString("text", text)
513
- json.putString("image", image?.toBase64DataUri())
453
+ baseMap["start"] = start
454
+ baseMap["end"] = end
455
+ baseMap["text"] = text
456
+ baseMap["image"] = image?.toBase64DataUri()
514
457
  }
515
458
 
516
459
  is PlayerEvent.CueExit -> {
517
- json.putDouble("start", start)
518
- json.putDouble("end", end)
519
- json.putString("text", text)
520
- json.putString("image", image?.toBase64DataUri())
460
+ baseMap["start"] = start
461
+ baseMap["end"] = end
462
+ baseMap["text"] = text
463
+ baseMap["image"] = image?.toBase64DataUri()
521
464
  }
522
465
 
523
466
  else -> {
524
467
  // Event is not supported yet or does not have any additional data
525
468
  }
526
469
  }
527
- return json
470
+ return baseMap.filterNotNullValues()
528
471
  }
529
472
 
530
- /**
531
- * Converts an arbitrary `json` into [BitmovinCastManagerOptions].
532
- */
533
- fun ReadableMap.toCastOptions(): BitmovinCastManagerOptions = BitmovinCastManagerOptions(
534
- applicationId = getString("applicationId"),
535
- messageNamespace = getString("messageNamespace"),
536
- )
537
-
538
- /**
539
- * Converts an arbitrary `json` to `WidevineConfig`.
540
- */
541
- fun ReadableMap.toWidevineConfig(): WidevineConfig? = getMap("widevine")?.run {
473
+ fun Map<String, Any?>.toWidevineConfig(): WidevineConfig? = getMap("widevine")?.run {
542
474
  WidevineConfig(getString("licenseUrl")).apply {
543
475
  withString("preferredSecurityLevel") { preferredSecurityLevel = it }
544
476
  withBoolean("shouldKeepDrmSessionsAlive") { shouldKeepDrmSessionsAlive = it }
545
- withMap("httpHeaders") { httpHeaders = it.toMap<String>().toMutableMap() }
477
+ withMap("httpHeaders") { httpHeaders = it.mapValues { entry -> entry.value as String }.toMutableMap() }
546
478
  }
547
479
  }
548
480
 
549
- /**
550
- * Converts an `url` string into a `ThumbnailsTrack`.
551
- */
552
481
  fun String.toThumbnailTrack(): ThumbnailTrack = ThumbnailTrack(this)
553
482
 
554
- /**
555
- * Converts any `AudioTrack` into its json representation.
556
- */
557
- fun AudioTrack.toJson(): WritableMap = Arguments.createMap().apply {
558
- putString("url", url)
559
- putString("label", label)
560
- putBoolean("isDefault", isDefault)
561
- putString("identifier", id)
562
- putString("language", language)
563
- putArray("roles", roles.mapToReactArray { it.toJson() })
564
- putArray("qualities", qualities.mapToReactArray { it.toJson() })
565
- }
566
-
567
- /**
568
- * Converts any `AudioQuality` into its json representation.
569
- */
570
- fun AudioQuality.toJson(): WritableMap = Arguments.createMap().apply {
571
- putString("id", id)
572
- putString("label", label)
573
- putInt("bitrate", bitrate)
574
- putInt("averageBitrate", averageBitrate)
575
- putInt("peakBitrate", peakBitrate)
576
- putString("codec", codec)
577
- }
483
+ fun AudioTrack.toJson(): Map<String, Any> = mapOf(
484
+ "url" to url,
485
+ "label" to label,
486
+ "isDefault" to isDefault,
487
+ "identifier" to id,
488
+ "language" to language,
489
+ "roles" to roles.map { it.toJson() },
490
+ ).filterNotNullValues()
578
491
 
579
- /**
580
- * Converts an arbitrary `json` into a `SubtitleTrack`.
581
- */
582
- fun ReadableMap.toSubtitleTrack(): SubtitleTrack? {
492
+ fun Map<String, Any?>.toSubtitleTrack(): SubtitleTrack? {
583
493
  return SubtitleTrack(
584
494
  url = getString("url") ?: return null,
585
495
  label = getString("label") ?: return null,
@@ -591,92 +501,62 @@ fun ReadableMap.toSubtitleTrack(): SubtitleTrack? {
591
501
  )
592
502
  }
593
503
 
594
- /**
595
- * Converts any subtitle format name in its mime type representation.
596
- */
597
504
  private fun String.toSubtitleMimeType(): String = when (this) {
598
505
  "srt" -> "application/x-subrip"
599
506
  "ttml" -> "application/ttml+xml"
600
507
  else -> "text/$this"
601
508
  }
602
509
 
603
- /**
604
- * Converts any `SubtitleTrack` into its json representation.
605
- */
606
- fun SubtitleTrack.toJson(): WritableMap = Arguments.createMap().apply {
607
- putString("url", url)
608
- putString("label", label)
609
- putBoolean("isDefault", isDefault)
610
- putString("identifier", id)
611
- putString("language", language)
612
- putBoolean("isForced", isForced)
613
- putString("format", mimeType?.textMimeTypeToJson())
614
- putArray("roles", roles.mapToReactArray { it.toJson() })
615
- }
510
+ fun SubtitleTrack.toJson(): Map<String, Any> = mapOf(
511
+ "url" to url,
512
+ "label" to label,
513
+ "isDefault" to isDefault,
514
+ "identifier" to id,
515
+ "language" to language,
516
+ "isForced" to isForced,
517
+ "format" to mimeType?.textMimeTypeToJson(),
518
+ "roles" to roles.map { it.toJson() },
519
+ ).filterNotNullValues()
616
520
 
617
- /**
618
- * Converts any subtitle track mime type into its json representation (file format value).
619
- */
620
521
  private fun String.textMimeTypeToJson(): String = split("/").last()
621
522
 
622
- /**
623
- * Converts any `AdBreak` object into its json representation.
624
- */
625
- fun AdBreak.toJson(): WritableMap = Arguments.createMap().apply {
626
- putArray("ads", ads.mapToReactArray { it.toJson() })
627
- putString("id", id)
628
- putDouble("scheduleTime", scheduleTime)
629
- }
630
-
631
- /**
632
- * Converts any `Ad` object into its json representation.
633
- */
634
- fun Ad.toJson(): WritableMap = Arguments.createMap().apply {
635
- putString("clickThroughUrl", clickThroughUrl)
636
- putMap("data", data?.toJson())
637
- putInt("height", height)
638
- putString("id", id)
639
- putBoolean("isLinear", isLinear)
640
- putString("mediaFileUrl", mediaFileUrl)
641
- putInt("width", width)
642
- }
643
-
644
- /**
645
- * Converts any `AdData` object into its json representation.
646
- */
647
- fun AdData.toJson(): WritableMap = Arguments.createMap().apply {
648
- putInt("bitrate", bitrate)
649
- putInt("maxBitrate", maxBitrate)
650
- putString("mimeType", mimeType)
651
- putInt("minBitrate", minBitrate)
652
- }
653
-
654
- /**
655
- * Converts any `AdConfig` object into its json representation.
656
- */
657
- fun AdConfig.toJson(): WritableMap = Arguments.createMap().apply {
658
- putDouble("replaceContentDuration", replaceContentDuration)
659
- }
523
+ fun AdBreak.toJson(): Map<String, Any> = mapOf(
524
+ "ads" to ads.map { it.toJson() },
525
+ "id" to id,
526
+ "scheduleTime" to scheduleTime,
527
+ )
660
528
 
661
- /**
662
- * Converts any `AdItem` object into its json representation.
663
- */
664
- fun AdItem.toJson(): WritableMap = Arguments.createMap().apply {
665
- putString("position", position)
666
- putArray("sources", sources.toList().mapToReactArray { it.toJson() })
667
- }
529
+ fun Ad.toJson(): Map<String, Any> = mapOf(
530
+ "clickThroughUrl" to clickThroughUrl,
531
+ "data" to data?.toJson(),
532
+ "height" to height,
533
+ "id" to id,
534
+ "isLinear" to isLinear,
535
+ "mediaFileUrl" to mediaFileUrl,
536
+ "width" to width,
537
+ ).filterNotNullValues()
538
+
539
+ fun AdData.toJson(): Map<String, Any> = mapOf<String, Any?>(
540
+ "bitrate" to bitrate,
541
+ "maxBitrate" to maxBitrate,
542
+ "mimeType" to mimeType,
543
+ "minBitrate" to minBitrate,
544
+ ).filterNotNullValues()
545
+
546
+ fun AdConfig.toJson(): Map<String, Any> = mapOf<String, Any?>(
547
+ "replaceContentDuration" to replaceContentDuration,
548
+ ).filterNotNullValues()
549
+
550
+ fun AdItem.toJson(): Map<String, Any> = mapOf(
551
+ "position" to position,
552
+ "sources" to sources.toList().map { it.toJson() },
553
+ )
668
554
 
669
- /**
670
- * Converts any `AdSource` object into its json representation.
671
- */
672
- fun AdSource.toJson(): WritableMap = Arguments.createMap().apply {
673
- putString("tag", tag)
674
- putString("type", type.toJson())
675
- }
555
+ fun AdSource.toJson(): Map<String, Any> = mapOf(
556
+ "tag" to tag,
557
+ "type" to type.toJson(),
558
+ )
676
559
 
677
- /**
678
- * Converts any `AdSourceType` value into its json representation.
679
- */
680
560
  fun AdSourceType.toJson(): String = when (this) {
681
561
  AdSourceType.Bitmovin -> "bitmovin"
682
562
  AdSourceType.Ima -> "ima"
@@ -684,38 +564,26 @@ fun AdSourceType.toJson(): String = when (this) {
684
564
  AdSourceType.Progressive -> "progressive"
685
565
  }
686
566
 
687
- /**
688
- * Converts any `AdQuartile` value into its json representation.
689
- */
690
567
  fun AdQuartile.toJson(): String = when (this) {
691
568
  AdQuartile.FirstQuartile -> "first"
692
569
  AdQuartile.MidPoint -> "mid_point"
693
570
  AdQuartile.ThirdQuartile -> "third"
694
571
  }
695
572
 
696
- /**
697
- * Converts an arbitrary json object into a `BitmovinAnalyticsConfig`.
698
- */
699
- fun ReadableMap.toAnalyticsConfig(): AnalyticsConfig? = getString("licenseKey")
573
+ fun Map<String, Any?>.toAnalyticsConfig(): AnalyticsConfig? = getString("licenseKey")
700
574
  ?.let { AnalyticsConfig.Builder(it) }
701
575
  ?.apply {
702
576
  withBoolean("adTrackingDisabled") { setAdTrackingDisabled(it) }
703
577
  withBoolean("randomizeUserId") { setRandomizeUserId(it) }
704
578
  }?.build()
705
579
 
706
- /**
707
- * Converts an arbitrary json object into an analytics `DefaultMetadata`.
708
- */
709
- fun ReadableMap.toAnalyticsDefaultMetadata(): DefaultMetadata = DefaultMetadata.Builder().apply {
580
+ fun Map<String, Any?>.toAnalyticsDefaultMetadata(): DefaultMetadata = DefaultMetadata.Builder().apply {
710
581
  setCustomData(toAnalyticsCustomData())
711
582
  withString("cdnProvider") { setCdnProvider(it) }
712
583
  withString("customUserId") { setCustomUserId(it) }
713
584
  }.build()
714
585
 
715
- /**
716
- * Converts an arbitrary json object into an analytics `CustomData`.
717
- */
718
- fun ReadableMap.toAnalyticsCustomData(): CustomData = CustomData.Builder().apply {
586
+ fun Map<String, Any?>.toAnalyticsCustomData(): CustomData = CustomData.Builder().apply {
719
587
  for (n in 1..30) {
720
588
  this[n] = getString("customData$n")
721
589
  }
@@ -724,17 +592,16 @@ fun ReadableMap.toAnalyticsCustomData(): CustomData = CustomData.Builder().apply
724
592
  }
725
593
  }.build()
726
594
 
727
- /**
728
- * Converts an arbitrary analytics `CustomData` object into a JS value.
729
- */
730
- fun CustomData.toJson(): WritableMap = Arguments.createMap().also { json ->
595
+ fun CustomData.toJson(): Map<String, Any> {
596
+ val map = mutableMapOf<String, Any?>()
731
597
  for (n in 1..30) {
732
- json.putStringIfNotNull("customData$n", this[n])
598
+ this[n]?.let { map["customData$n"] = it }
733
599
  }
734
- json.putStringIfNotNull("experimentName", experimentName)
600
+ experimentName?.let { map["experimentName"] = it }
601
+ return map.filterNotNullValues()
735
602
  }
736
603
 
737
- fun ReadableMap.toAnalyticsSourceMetadata(): SourceMetadata = SourceMetadata(
604
+ fun Map<String, Any?>.toAnalyticsSourceMetadata(): SourceMetadata = SourceMetadata(
738
605
  title = getString("title"),
739
606
  videoId = getString("videoId"),
740
607
  cdnProvider = getString("cdnProvider"),
@@ -743,59 +610,52 @@ fun ReadableMap.toAnalyticsSourceMetadata(): SourceMetadata = SourceMetadata(
743
610
  customData = toAnalyticsCustomData(),
744
611
  )
745
612
 
746
- fun SourceMetadata.toJson(): ReadableMap = customData.toJson().also {
747
- it.putString("title", title)
748
- it.putString("videoId", videoId)
749
- it.putString("cdnProvider", cdnProvider)
750
- it.putString("path", path)
751
- it.putBoolean("isLive", isLive)
752
- }
753
-
754
- /**
755
- * Converts any `VideoQuality` value into its json representation.
756
- */
757
- fun VideoQuality.toJson(): WritableMap = Arguments.createMap().apply {
758
- putString("id", id)
759
- putString("label", label)
760
- putInt("bitrate", bitrate)
761
- putString("codec", codec)
762
- putDouble("frameRate", frameRate.toDouble())
763
- putInt("height", height)
764
- putInt("width", width)
765
- }
766
-
767
- /**
768
- * Converts any `OfflineOptionEntry` into its json representation.
769
- */
770
- fun OfflineOptionEntry.toJson(): WritableMap = Arguments.createMap().apply {
771
- putString("id", id)
772
- putString("language", language)
773
- }
774
-
775
- /**
776
- * Converts any `OfflineContentOptions` into its json representation.
777
- */
778
- fun OfflineContentOptions.toJson(): WritableMap = Arguments.createMap().apply {
779
- putArray("audioOptions", audioOptions.mapToReactArray { it.toJson() })
780
- putArray("textOptions", textOptions.mapToReactArray { it.toJson() })
781
- }
613
+ fun SourceMetadata.toJson(): Map<String, Any> {
614
+ val map = customData.toJson().toMutableMap<String, Any?>()
615
+ map["title"] = title
616
+ map["videoId"] = videoId
617
+ map["cdnProvider"] = cdnProvider
618
+ map["path"] = path
619
+ map["isLive"] = isLive
620
+ return map.filterNotNullValues()
621
+ }
622
+
623
+ fun VideoQuality.toJson(): Map<String, Any> = mapOf<String, Any?>(
624
+ "id" to id,
625
+ "label" to label,
626
+ "bitrate" to bitrate,
627
+ "codec" to codec,
628
+ "frameRate" to frameRate.toDouble(),
629
+ "height" to height,
630
+ "width" to width,
631
+ ).filterNotNullValues()
632
+
633
+ fun OfflineOptionEntry.toJson(): Map<String, Any> = mapOf(
634
+ "id" to id,
635
+ "language" to language,
636
+ ).filterNotNullValues()
637
+
638
+ fun OfflineContentOptions.toJson(): Map<String, Any> = mapOf(
639
+ "audioOptions" to audioOptions.map { it.toJson() },
640
+ "textOptions" to textOptions.map { it.toJson() },
641
+ )
782
642
 
783
- fun Thumbnail.toJson(): WritableMap = Arguments.createMap().apply {
784
- putDouble("start", start)
785
- putDouble("end", end)
786
- putString("text", text)
787
- putString("url", uri.toString())
788
- putInt("x", x)
789
- putInt("y", y)
790
- putInt("width", width)
791
- putInt("height", height)
792
- }
643
+ fun Thumbnail.toJson(): Map<String, Any> = mapOf(
644
+ "start" to start,
645
+ "end" to end,
646
+ "text" to text,
647
+ "url" to uri.toString(),
648
+ "x" to x,
649
+ "y" to y,
650
+ "width" to width,
651
+ "height" to height,
652
+ )
793
653
 
794
- fun ReadableMap.toPictureInPictureConfig(): PictureInPictureConfig = PictureInPictureConfig(
654
+ fun Map<String, Any?>.toPictureInPictureConfig(): PictureInPictureConfig = PictureInPictureConfig(
795
655
  isEnabled = getBooleanOrNull("isEnabled") ?: false,
796
656
  )
797
657
 
798
- fun ReadableMap.toPlayerViewConfig(): PlayerViewConfig = PlayerViewConfig(
658
+ fun Map<String, Any?>.toPlayerViewConfig(): PlayerViewConfig = PlayerViewConfig(
799
659
  uiConfig = getMap("uiConfig")?.toUiConfig() ?: UiConfig.WebUi(),
800
660
  hideFirstFrame = getBooleanOrNull("hideFirstFrame") ?: false,
801
661
  surfaceType = getString("surfaceType")?.toSurfaceType() ?: SurfaceType.SurfaceView,
@@ -807,7 +667,7 @@ private fun String.toSurfaceType(): SurfaceType? = when (this) {
807
667
  else -> null
808
668
  }
809
669
 
810
- private fun ReadableMap.toUiConfig(): UiConfig {
670
+ private fun Map<String, Any?>.toUiConfig(): UiConfig {
811
671
  val variant = toVariant() ?: UiConfig.WebUi.Variant.SmallScreenUi
812
672
  val focusUiOnInitialization = getBooleanOrNull("focusUiOnInitialization")
813
673
  val defaultFocusUiOnInitialization = variant == UiConfig.WebUi.Variant.TvUi
@@ -819,7 +679,7 @@ private fun ReadableMap.toUiConfig(): UiConfig {
819
679
  )
820
680
  }
821
681
 
822
- private fun ReadableMap.toVariant(): UiConfig.WebUi.Variant? {
682
+ private fun Map<String, Any?>.toVariant(): UiConfig.WebUi.Variant? {
823
683
  val uiManagerFactoryFunction = getMap("variant")?.getString("uiManagerFactoryFunction") ?: return null
824
684
 
825
685
  return when (uiManagerFactoryFunction) {
@@ -829,36 +689,36 @@ private fun ReadableMap.toVariant(): UiConfig.WebUi.Variant? {
829
689
  }
830
690
  }
831
691
 
832
- private fun ReadableMap.toUserInterfaceTypeFromPlayerConfig(): UserInterfaceType? =
692
+ private fun Map<String, Any?>.toUserInterfaceTypeFromPlayerConfig(): UserInterfaceType? =
833
693
  when (getMap("styleConfig")?.getString("userInterfaceType")) {
834
694
  "Subtitle" -> UserInterfaceType.Subtitle
835
695
  "Bitmovin" -> UserInterfaceType.Bitmovin
836
696
  else -> null
837
697
  }
838
698
 
839
- /**
840
- * Converts the [this@toRNPlayerViewConfigWrapper] to a `RNPlayerViewConfig` object.
841
- */
842
- fun ReadableMap.toRNPlayerViewConfigWrapper() = RNPlayerViewConfigWrapper(
699
+ fun String.toUserInterfaceType(): UserInterfaceType? = when (this) {
700
+ "Subtitle" -> UserInterfaceType.Subtitle
701
+ "Bitmovin" -> UserInterfaceType.Bitmovin
702
+ else -> null
703
+ }
704
+
705
+ fun Map<String, Any?>.toRNPlayerViewConfigWrapper() = RNPlayerViewConfigWrapper(
843
706
  playerViewConfig = toPlayerViewConfig(),
844
707
  pictureInPictureConfig = getMap("pictureInPictureConfig")?.toPictureInPictureConfig(),
845
708
  )
846
709
 
847
- fun ReadableMap.toRNStyleConfigWrapperFromPlayerConfig(): RNStyleConfigWrapper? {
710
+ fun Map<String, Any?>.toRNStyleConfigWrapperFromPlayerConfig(): RNStyleConfigWrapper? {
848
711
  return RNStyleConfigWrapper(
849
712
  styleConfig = toStyleConfig(),
850
713
  userInterfaceType = toUserInterfaceTypeFromPlayerConfig() ?: return null,
851
714
  )
852
715
  }
853
716
 
854
- /**
855
- * Converts any JS object into a [LiveConfig] object.
856
- */
857
- fun ReadableMap.toLiveConfig(): LiveConfig = LiveConfig().apply {
717
+ fun Map<String, Any?>.toLiveConfig(): LiveConfig = LiveConfig().apply {
858
718
  withDouble("minTimeshiftBufferDepth") { minTimeShiftBufferDepth = it }
859
719
  }
860
720
 
861
- fun ReadableMap.toHttpRequest(): HttpRequest? {
721
+ fun Map<String, Any?>.toHttpRequest(): HttpRequest? {
862
722
  return HttpRequest(
863
723
  getString("url") ?: return null,
864
724
  getMap("headers")?.toMap(),
@@ -873,7 +733,7 @@ private fun ByteArray.toBase64String(): String {
873
733
 
874
734
  private fun String.toByteArrayFromBase64(): ByteArray = Base64.decode(this, Base64.NO_WRAP)
875
735
 
876
- fun ReadableMap.toHttpResponse(): HttpResponse? {
736
+ fun Map<String, Any?>.toHttpResponse(): HttpResponse? {
877
737
  return HttpResponse(
878
738
  httpRequest = getMap("request")?.toHttpRequest() ?: return null,
879
739
  url = getString("url") ?: return null,
@@ -883,65 +743,54 @@ fun ReadableMap.toHttpResponse(): HttpResponse? {
883
743
  )
884
744
  }
885
745
 
886
- fun ReadableMap.toNetworkConfig(): NetworkConfig = NetworkConfig()
746
+ fun Map<String, Any?>.toNetworkConfig(): NetworkConfig = NetworkConfig()
887
747
 
888
- fun HttpRequest.toJson(): WritableMap = Arguments.createMap().apply {
889
- putString("url", url)
890
- putMap("headers", headers?.toReadableMap())
891
- putString("body", body?.toBase64String())
892
- putString("method", method)
893
- }
748
+ fun HttpRequest.toJson(): Map<String, Any> = mapOf(
749
+ "url" to url,
750
+ "headers" to headers,
751
+ "body" to body?.toBase64String(),
752
+ "method" to method,
753
+ ).filterNotNullValues()
894
754
 
895
- fun HttpResponse.toJson(): WritableMap = Arguments.createMap().apply {
896
- putMap("request", httpRequest.toJson())
897
- putString("url", url)
898
- putInt("status", status)
899
- putMap("headers", headers.toReadableMap())
900
- putString("body", body.toBase64String())
901
- }
755
+ fun HttpResponse.toJson(): Map<String, Any> = mapOf(
756
+ "request" to httpRequest.toJson(),
757
+ "url" to url,
758
+ "status" to status,
759
+ "headers" to headers,
760
+ "body" to body.toBase64String(),
761
+ )
902
762
 
903
763
  fun HttpRequestType.toJson(): String = toString()
904
764
 
905
- /**
906
- * Converts any [MediaType] value into its json representation.
907
- */
908
765
  fun MediaType.toJson(): String = when (this) {
909
766
  MediaType.Audio -> "audio"
910
767
  MediaType.Video -> "video"
911
768
  }
912
769
 
913
- /**
914
- * Converts any [BufferType] value into its json representation.
915
- */
916
770
  fun BufferType.toJson(): String = when (this) {
917
771
  BufferType.ForwardDuration -> "forwardDuration"
918
772
  BufferType.BackwardDuration -> "backwardDuration"
919
773
  }
920
774
 
921
- fun BufferLevel.toJson(): WritableMap = Arguments.createMap().apply {
922
- putDouble("level", level)
923
- putDouble("targetLevel", targetLevel)
924
- putString("media", media.toJson())
925
- putString("type", type.toJson())
926
- }
775
+ fun BufferLevel.toJson(): Map<String, Any> = mapOf(
776
+ "level" to level,
777
+ "targetLevel" to targetLevel,
778
+ "media" to media.toJson(),
779
+ "type" to type.toJson(),
780
+ )
927
781
 
928
- fun RNBufferLevels.toJson(): WritableMap = Arguments.createMap().apply {
929
- putMap("audio", audio.toJson())
930
- putMap("video", video.toJson())
931
- }
782
+ fun RNBufferLevels.toJson(): Map<String, Any> = mapOf(
783
+ "audio" to audio.toJson(),
784
+ "video" to video.toJson(),
785
+ )
932
786
 
933
- /**
934
- * Maps a JS string into the corresponding [BufferType] value.
935
- */
936
- fun String.toBufferType(): BufferType? = when (this) {
937
- "forwardDuration" -> BufferType.ForwardDuration
938
- "backwardDuration" -> BufferType.BackwardDuration
939
- else -> null
787
+ // Extension function to convert string to BufferType
788
+ fun String.toBufferTypeOrThrow(): BufferType = when (this.lowercase()) {
789
+ "forwardduration" -> BufferType.ForwardDuration
790
+ "backwardduration" -> BufferType.BackwardDuration
791
+ else -> throw IllegalArgumentException("Unknown buffer type: $this")
940
792
  }
941
793
 
942
- /**
943
- * Maps a JS string into the corresponding [MediaType] value.
944
- */
945
794
  fun String.toMediaType(): MediaType? = when (this) {
946
795
  "audio" -> MediaType.Audio
947
796
  "video" -> MediaType.Video
@@ -952,57 +801,48 @@ data class MediaControlConfig(
952
801
  var isEnabled: Boolean = true,
953
802
  )
954
803
 
955
- fun ReadableMap.toMediaControlConfig(): MediaControlConfig = MediaControlConfig().apply {
804
+ fun Map<String, Any?>.toMediaControlConfig(): MediaControlConfig = MediaControlConfig().apply {
956
805
  withBoolean("isEnabled") { isEnabled = it }
957
806
  }
958
807
 
959
- /**
960
- * Converts a [CastPayload] object into its JS representation.
961
- */
962
- private fun CastPayload.toJson(): WritableMap = Arguments.createMap().apply {
963
- putDouble("currentTime", currentTime)
964
- putString("deviceName", deviceName)
965
- putString("type", type)
966
- }
967
-
968
- private fun WritableMap.putStringIfNotNull(name: String, value: String?) = value?.let { putString(name, value) }
808
+ private fun CastPayload.toJson(): Map<String, Any> = mapOf<String, Any?>(
809
+ "currentTime" to currentTime,
810
+ "deviceName" to deviceName,
811
+ "type" to type,
812
+ ).filterNotNullValues()
969
813
 
970
- fun DecoderContext.toJson(): ReadableMap = Arguments.createMap().apply {
971
- putString("mediaType", mediaType.name)
972
- putBoolean("isAd", isAd)
973
- }
814
+ fun DecoderContext.toJson(): Map<String, Any> = mapOf(
815
+ "mediaType" to mediaType.name,
816
+ "isAd" to isAd,
817
+ )
974
818
 
975
- fun List<MediaCodecInfo>.toJson(): ReadableArray = Arguments.createArray().apply {
976
- forEach {
977
- pushMap(it.toJson())
978
- }
979
- }
819
+ fun List<MediaCodecInfo>.toJson(): List<Map<String, Any>> = map { it.toJson() }
980
820
 
981
- fun MediaCodecInfo.toJson(): ReadableMap = Arguments.createMap().apply {
982
- putString("name", name)
983
- putBoolean("isSoftware", isSoftware)
984
- }
821
+ fun MediaCodecInfo.toJson(): Map<String, Any> = mapOf(
822
+ "name" to name,
823
+ "isSoftware" to isSoftware,
824
+ )
985
825
 
986
- fun ReadableArray.toMediaCodecInfoList(): List<MediaCodecInfo> {
987
- if (size() <= 0) {
826
+ fun List<Any?>.toMediaCodecInfoList(): List<MediaCodecInfo> {
827
+ if (isEmpty()) {
988
828
  return emptyList()
989
829
  }
990
830
  val mediaCodecInfoList = mutableListOf<MediaCodecInfo>()
991
- (0 until size()).forEach {
831
+ indices.forEach {
992
832
  val info = getMap(it)?.toMediaCodecInfo() ?: return@forEach
993
833
  mediaCodecInfoList.add(info)
994
834
  }
995
835
  return mediaCodecInfoList
996
836
  }
997
837
 
998
- fun ReadableMap.toMediaCodecInfo(): MediaCodecInfo? {
838
+ fun Map<String, Any?>.toMediaCodecInfo(): MediaCodecInfo? {
999
839
  val name = getString("name") ?: return null
1000
840
  val isSoftware = getBooleanOrNull("isSoftware") ?: return null
1001
841
  return MediaCodecInfo(name, isSoftware)
1002
842
  }
1003
843
 
1004
- fun MediaTrackRole.toJson(): WritableMap = Arguments.createMap().apply {
1005
- putString("id", id)
1006
- putString("schemeIdUri", schemeIdUri)
1007
- putString("value", value)
1008
- }
844
+ fun MediaTrackRole.toJson(): Map<String, Any> = mapOf(
845
+ "id" to id,
846
+ "schemeIdUri" to schemeIdUri,
847
+ "value" to value,
848
+ ).filterNotNullValues()