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
@@ -1,628 +1,352 @@
1
1
  package com.bitmovin.player.reactnative
2
2
 
3
- import android.util.Log
4
3
  import com.bitmovin.analytics.api.DefaultMetadata
5
4
  import com.bitmovin.player.api.Player
6
5
  import com.bitmovin.player.api.PlayerConfig
7
6
  import com.bitmovin.player.api.analytics.create
8
- import com.bitmovin.player.api.event.PlayerEvent
9
7
  import com.bitmovin.player.reactnative.converter.toAdItem
10
8
  import com.bitmovin.player.reactnative.converter.toAnalyticsConfig
11
9
  import com.bitmovin.player.reactnative.converter.toAnalyticsDefaultMetadata
12
10
  import com.bitmovin.player.reactnative.converter.toJson
13
11
  import com.bitmovin.player.reactnative.converter.toMediaControlConfig
14
12
  import com.bitmovin.player.reactnative.converter.toPlayerConfig
15
- import com.bitmovin.player.reactnative.extensions.mapToReactArray
16
- import com.facebook.react.bridge.*
17
- import com.facebook.react.module.annotations.ReactModule
18
- import java.security.InvalidParameterException
13
+ import com.bitmovin.player.reactnative.extensions.getMap
14
+ import expo.modules.kotlin.functions.Queues
15
+ import expo.modules.kotlin.modules.Module
16
+ import expo.modules.kotlin.modules.ModuleDefinition
19
17
 
20
- private const val MODULE_NAME = "PlayerModule"
21
-
22
- @ReactModule(name = MODULE_NAME)
23
- class PlayerModule(context: ReactApplicationContext) : BitmovinBaseModule(context) {
18
+ class PlayerModule : Module() {
24
19
  /**
25
20
  * In-memory mapping from [NativeId]s to [Player] instances.
21
+ * This must match the Registry pattern from legacy PlayerModule
26
22
  */
27
23
  private val players: Registry<Player> = mutableMapOf()
28
24
 
29
- val mediaSessionPlaybackManager = MediaSessionPlaybackManager(context)
30
-
31
- /**
32
- * JS exported module name.
33
- */
34
- override fun getName() = MODULE_NAME
25
+ val mediaSessionPlaybackManager by lazy { MediaSessionPlaybackManager(appContext) }
35
26
 
36
- /**
37
- * Fetches the `Player` instance associated with [nativeId] from the internal players.
38
- */
39
- fun getPlayerOrNull(nativeId: NativeId): Player? = players[nativeId]
27
+ override fun definition() = ModuleDefinition {
28
+ Name("PlayerModule")
40
29
 
41
- /**
42
- * Creates a new `Player` instance inside the internal players using the provided `config` object.
43
- * @param config `PlayerConfig` object received from JS.
44
- */
45
- @ReactMethod
46
- fun initWithConfig(
47
- nativeId: NativeId,
48
- config: ReadableMap?,
49
- networkNativeId: NativeId?,
50
- decoderNativeId: NativeId?,
51
- promise: Promise,
52
- ) {
53
- init(
54
- nativeId,
55
- config,
56
- networkNativeId = networkNativeId,
57
- decoderNativeId = decoderNativeId,
58
- analyticsConfigJson = null,
59
- promise,
60
- )
61
- }
30
+ OnCreate {
31
+ // Module initialization
32
+ }
62
33
 
63
- /**
64
- * Creates a new `Player` instance inside the internal players using the provided `playerConfig` and `analyticsConfig`.
65
- * @param playerConfigJson `PlayerConfig` object received from JS.
66
- * @param analyticsConfigJson `AnalyticsConfig` object received from JS.
67
- */
68
- @ReactMethod
69
- fun initWithAnalyticsConfig(
70
- nativeId: NativeId,
71
- playerConfigJson: ReadableMap?,
72
- networkNativeId: NativeId?,
73
- decoderNativeId: NativeId?,
74
- analyticsConfigJson: ReadableMap,
75
- promise: Promise,
76
- ) = init(
77
- nativeId,
78
- playerConfigJson,
79
- networkNativeId,
80
- decoderNativeId,
81
- analyticsConfigJson,
82
- promise,
83
- )
84
-
85
- private fun init(
86
- nativeId: NativeId,
87
- playerConfigJson: ReadableMap?,
88
- networkNativeId: NativeId?,
89
- decoderNativeId: NativeId?,
90
- analyticsConfigJson: ReadableMap?,
91
- promise: Promise,
92
- ) = promise.unit.resolveOnUiThread {
93
- if (players.containsKey(nativeId)) {
94
- if (playerConfigJson != null || analyticsConfigJson != null) {
95
- Log.w("BitmovinPlayerModule", "Cannot reconfigure an existing player")
34
+ OnDestroy {
35
+ // Clean up all players when module is destroyed
36
+ players.values.forEach { player ->
37
+ try {
38
+ player.destroy()
39
+ } catch (e: Exception) {
40
+ // Log but don't crash on cleanup
41
+ }
96
42
  }
97
- return@resolveOnUiThread // key can be reused to access the same native instance (see NativeInstanceConfig)
98
- }
99
- val playerConfig = playerConfigJson?.toPlayerConfig() ?: PlayerConfig()
100
- val analyticsConfig = analyticsConfigJson?.toAnalyticsConfig()
101
- val defaultMetadata = analyticsConfigJson?.getMap("defaultMetadata")?.toAnalyticsDefaultMetadata()
102
- val enableMediaSession = playerConfigJson?.getMap("mediaControlConfig")
103
- ?.toMediaControlConfig()?.isEnabled ?: true
43
+ players.clear()
44
+ }
45
+
46
+ AsyncFunction("play") { nativeId: NativeId ->
47
+ val player = players[nativeId]
48
+ player?.play()
49
+ }.runOnQueue(Queues.MAIN)
50
+
51
+ AsyncFunction("pause") { nativeId: NativeId ->
52
+ val player = players[nativeId]
53
+ player?.pause()
54
+ }.runOnQueue(Queues.MAIN)
55
+
56
+ AsyncFunction("mute") { nativeId: NativeId ->
57
+ val player = players[nativeId]
58
+ player?.mute()
59
+ }.runOnQueue(Queues.MAIN)
60
+
61
+ AsyncFunction("unmute") { nativeId: NativeId ->
62
+ val player = players[nativeId]
63
+ player?.unmute()
64
+ }.runOnQueue(Queues.MAIN)
65
+
66
+ AsyncFunction("seek") { nativeId: NativeId, time: Double ->
67
+ val player = players[nativeId]
68
+ player?.seek(time)
69
+ }.runOnQueue(Queues.MAIN)
70
+
71
+ AsyncFunction("timeShift") { nativeId: NativeId, offset: Double ->
72
+ val player = players[nativeId]
73
+ player?.timeShift(offset)
74
+ }.runOnQueue(Queues.MAIN)
75
+
76
+ AsyncFunction("destroy") { nativeId: NativeId ->
77
+ val player = players[nativeId]
78
+ if (player != null) {
79
+ // Note: MediaSession cleanup would need to be handled here
80
+ // For now, just destroy the player and remove from registry
81
+ player.destroy()
82
+ players.remove(nativeId)
83
+ }
84
+ }.runOnQueue(Queues.MAIN)
104
85
 
105
- val networkConfig = networkNativeId?.let { networkModule.getConfig(it) }
106
- if (networkConfig != null) {
107
- playerConfig.networkConfig = networkConfig
108
- }
86
+ AsyncFunction("setVolume") { nativeId: NativeId, volume: Double ->
87
+ val player = players[nativeId]
88
+ player?.volume = volume.toInt()
89
+ }.runOnQueue(Queues.MAIN)
109
90
 
110
- val decoderConfig = decoderNativeId?.let { decoderConfigModule.getConfig(it) }
111
- if (decoderConfig != null) {
112
- playerConfig.playbackConfig = playerConfig.playbackConfig.copy(decoderConfig = decoderConfig)
91
+ AsyncFunction("getVolume") { nativeId: NativeId ->
92
+ val player = players[nativeId]
93
+ return@AsyncFunction player?.volume?.toDouble()
113
94
  }
114
95
 
115
- players[nativeId] = if (analyticsConfig == null) {
116
- Player.create(context, playerConfig)
117
- } else {
118
- Player.create(
119
- context = context,
120
- playerConfig = playerConfig,
121
- analyticsConfig = analyticsConfig,
122
- defaultMetadata = defaultMetadata ?: DefaultMetadata(),
123
- )
96
+ AsyncFunction("currentTime") { nativeId: NativeId, mode: String? ->
97
+ val player = players[nativeId]
98
+ return@AsyncFunction when {
99
+ player == null -> null
100
+ mode == "relative" -> player.currentTime + player.playbackTimeOffsetToRelativeTime
101
+ mode == "absolute" -> player.currentTime + player.playbackTimeOffsetToAbsoluteTime
102
+ else -> player.currentTime
103
+ }
124
104
  }
125
105
 
126
- if (enableMediaSession) {
127
- mediaSessionPlaybackManager.setupMediaSessionPlayback(nativeId)
106
+ AsyncFunction("isPlaying") { nativeId: NativeId ->
107
+ val player = players[nativeId]
108
+ return@AsyncFunction player?.isPlaying
128
109
  }
129
- }
130
110
 
131
- /**
132
- * Load the source of the given [nativeId] with `config` options from JS.
133
- * @param nativeId Target player.
134
- * @param sourceNativeId Target source.
135
- */
136
- @ReactMethod
137
- fun loadSource(nativeId: NativeId, sourceNativeId: String, promise: Promise) {
138
- promise.unit.resolveOnUiThread {
139
- getPlayer(nativeId, this@PlayerModule).load(getSource(sourceNativeId))
111
+ AsyncFunction("isPaused") { nativeId: NativeId ->
112
+ val player = players[nativeId]
113
+ return@AsyncFunction player?.isPaused
140
114
  }
141
- }
142
115
 
143
- /**
144
- * Load the `offlineSourceConfig` for the player with [nativeId] and offline source module with `offlineModuleNativeId`.
145
- * @param nativeId Target player.
146
- * @param offlineContentManagerBridgeId Target offline module.
147
- * @param options Source configuration options from JS.
148
- */
149
- @ReactMethod
150
- fun loadOfflineContent(
151
- nativeId: NativeId,
152
- offlineContentManagerBridgeId: String,
153
- options: ReadableMap?,
154
- promise: Promise,
155
- ) {
156
- promise.unit.resolveOnUiThread {
157
- offlineModule
158
- .getOfflineContentManagerBridgeOrNull(offlineContentManagerBridgeId)
159
- ?.offlineContentManager
160
- ?.offlineSourceConfig
161
- ?.let { getPlayer(nativeId).load(it) }
116
+ AsyncFunction("duration") { nativeId: NativeId ->
117
+ val player = players[nativeId]
118
+ return@AsyncFunction player?.duration
162
119
  }
163
- }
164
120
 
165
- /**
166
- * Call `.unload()` on [nativeId]'s player.
167
- * @param nativeId Target player Id.
168
- */
169
- @ReactMethod
170
- fun unload(nativeId: NativeId, promise: Promise) {
171
- promise.unit.resolveOnUiThreadWithPlayer(nativeId) {
172
- unload()
121
+ AsyncFunction("isMuted") { nativeId: NativeId ->
122
+ val player = players[nativeId]
123
+ return@AsyncFunction player?.isMuted
173
124
  }
174
- }
175
125
 
176
- /**
177
- * Call `.play()` on [nativeId]'s player.
178
- * @param nativeId Target player Id.
179
- */
180
- @ReactMethod
181
- fun play(nativeId: NativeId, promise: Promise) {
182
- promise.unit.resolveOnUiThreadWithPlayer(nativeId) {
183
- play()
184
- }
185
- }
126
+ AsyncFunction("unload") { nativeId: NativeId ->
127
+ val player = players[nativeId]
128
+ player?.unload()
129
+ }.runOnQueue(Queues.MAIN)
186
130
 
187
- /**
188
- * Call `.pause()` on [nativeId]'s player.
189
- * @param nativeId Target player Id.
190
- */
191
- @ReactMethod
192
- fun pause(nativeId: NativeId, promise: Promise) {
193
- promise.unit.resolveOnUiThreadWithPlayer(nativeId) {
194
- pause()
131
+ AsyncFunction("getTimeShift") { nativeId: NativeId ->
132
+ val player = players[nativeId]
133
+ return@AsyncFunction player?.timeShift
195
134
  }
196
- }
197
135
 
198
- /**
199
- * Call `.seek(time:)` on [nativeId]'s player.
200
- * @param nativeId Target player Id.
201
- * @param time Seek time in seconds.
202
- */
203
- @ReactMethod
204
- fun seek(nativeId: NativeId, time: Double, promise: Promise) {
205
- promise.unit.resolveOnUiThreadWithPlayer(nativeId) {
206
- seek(time)
136
+ AsyncFunction("isLive") { nativeId: NativeId ->
137
+ val player = players[nativeId]
138
+ return@AsyncFunction player?.isLive
207
139
  }
208
- }
209
140
 
210
- /**
211
- * Call `.timeShift(offset:)` on [nativeId]'s player.
212
- * @param nativeId Target player Id.
213
- * @param offset Offset time in seconds.
214
- */
215
- @ReactMethod
216
- fun timeShift(nativeId: NativeId, offset: Double, promise: Promise) {
217
- promise.unit.resolveOnUiThreadWithPlayer(nativeId) {
218
- timeShift(offset)
141
+ AsyncFunction("getMaxTimeShift") { nativeId: NativeId ->
142
+ val player = players[nativeId]
143
+ return@AsyncFunction player?.maxTimeShift
219
144
  }
220
- }
221
145
 
222
- /**
223
- * Call `.mute()` on [nativeId]'s player.
224
- * @param nativeId Target player Id.
225
- */
226
- @ReactMethod
227
- fun mute(nativeId: NativeId, promise: Promise) {
228
- promise.unit.resolveOnUiThreadWithPlayer(nativeId) {
229
- mute()
146
+ AsyncFunction("getPlaybackSpeed") { nativeId: NativeId ->
147
+ val player = players[nativeId]
148
+ return@AsyncFunction player?.playbackSpeed?.toDouble()
230
149
  }
231
- }
232
150
 
233
- /**
234
- * Call `.unmute()` on [nativeId]'s player.
235
- * @param nativeId Target player Id.
236
- */
237
- @ReactMethod
238
- fun unmute(nativeId: NativeId, promise: Promise) {
239
- promise.unit.resolveOnUiThreadWithPlayer(nativeId) {
240
- unmute()
241
- }
242
- }
151
+ AsyncFunction("setPlaybackSpeed") { nativeId: NativeId, playbackSpeed: Double ->
152
+ val player = players[nativeId]
153
+ player?.playbackSpeed = playbackSpeed.toFloat()
154
+ }.runOnQueue(Queues.MAIN)
243
155
 
244
- /**
245
- * Call `.destroy()` on [nativeId]'s player.
246
- * @param nativeId Target player Id.
247
- */
248
- @ReactMethod
249
- fun destroy(nativeId: NativeId, promise: Promise) {
250
- mediaSessionPlaybackManager.destroy(nativeId)
251
- promise.unit.resolveOnUiThreadWithPlayer(nativeId) {
252
- destroy()
253
- players.remove(nativeId)
156
+ AsyncFunction("isAd") { nativeId: NativeId ->
157
+ val player = players[nativeId]
158
+ return@AsyncFunction player?.isAd
254
159
  }
255
- }
256
160
 
257
- /**
258
- * Call `.setVolume(volume:)` on [nativeId]'s player.
259
- * @param nativeId Target player Id.
260
- * @param volume Volume level integer between 0 to 100.
261
- */
262
- @ReactMethod
263
- fun setVolume(nativeId: NativeId, volume: Int, promise: Promise) {
264
- promise.unit.resolveOnUiThreadWithPlayer(nativeId) {
265
- this.volume = volume
266
- }
267
- }
161
+ AsyncFunction("setMaxSelectableBitrate") { nativeId: NativeId, maxBitrate: Double ->
162
+ val player = players[nativeId]
163
+ player?.setMaxSelectableVideoBitrate(maxBitrate.toInt())
164
+ }.runOnQueue(Queues.MAIN)
268
165
 
269
- /**
270
- * Resolve [nativeId]'s current volume.
271
- * @param nativeId Target player Id.
272
- * @param promise JS promise object.
273
- */
274
- @ReactMethod
275
- fun getVolume(nativeId: NativeId, promise: Promise) {
276
- promise.int.resolveOnUiThreadWithPlayer(nativeId) {
277
- volume
166
+ AsyncFunction("isAirPlayActive") { _: String ->
167
+ // AirPlay is iOS-only, return null on Android
168
+ false
278
169
  }
279
- }
280
170
 
281
- /**
282
- * Resolve the source of [nativeId]'s player.
283
- * @param nativeId Target player Id.
284
- * @param promise JS promise object.
285
- */
286
- @ReactMethod
287
- fun source(nativeId: NativeId, promise: Promise) {
288
- promise.map.nullable.resolveOnUiThreadWithPlayer(nativeId) {
289
- source?.toJson()
171
+ AsyncFunction("isAirPlayAvailable") { _: String ->
172
+ // AirPlay is iOS-only, return null on Android
173
+ false
290
174
  }
291
- }
292
175
 
293
- /**
294
- * Resolve [nativeId]'s current playback time.
295
- * @param nativeId Target player Id.
296
- * @param promise JS promise object.
297
- */
298
- @ReactMethod
299
- fun currentTime(nativeId: NativeId, mode: String?, promise: Promise) {
300
- promise.double.resolveOnUiThreadWithPlayer(nativeId) {
301
- currentTime + when (mode) {
302
- "relative" -> playbackTimeOffsetToRelativeTime
303
- "absolute" -> playbackTimeOffsetToAbsoluteTime
304
- else -> throw InvalidParameterException("Unknown mode $mode")
305
- }
176
+ AsyncFunction("isCastAvailable") { nativeId: NativeId ->
177
+ val player = players[nativeId]
178
+ return@AsyncFunction player?.isCastAvailable
306
179
  }
307
- }
308
180
 
309
- /**
310
- * Resolve [nativeId]'s current source duration.
311
- * @param nativeId Target player Id.
312
- * @param promise JS promise object.
313
- */
314
- @ReactMethod
315
- fun duration(nativeId: NativeId, promise: Promise) {
316
- promise.double.resolveOnUiThreadWithPlayer(nativeId) {
317
- duration
181
+ AsyncFunction("isCasting") { nativeId: NativeId ->
182
+ val player = players[nativeId]
183
+ return@AsyncFunction player?.isCasting
318
184
  }
319
- }
320
185
 
321
- /**
322
- * Resolve [nativeId]'s current muted state.
323
- * @param nativeId Target player Id.
324
- * @param promise JS promise object.
325
- */
326
- @ReactMethod
327
- fun isMuted(nativeId: NativeId, promise: Promise) {
328
- promise.bool.resolveOnUiThreadWithPlayer(nativeId) {
329
- isMuted
330
- }
331
- }
186
+ AsyncFunction("castVideo") { nativeId: NativeId ->
187
+ val player = players[nativeId]
188
+ player?.castVideo()
189
+ }.runOnQueue(Queues.MAIN)
332
190
 
333
- /**
334
- * Resolve [nativeId]'s current playing state.
335
- * @param nativeId Target player Id.
336
- * @param promise JS promise object.
337
- */
338
- @ReactMethod
339
- fun isPlaying(nativeId: NativeId, promise: Promise) {
340
- promise.bool.resolveOnUiThreadWithPlayer(nativeId) {
341
- isPlaying
342
- }
343
- }
191
+ AsyncFunction("castStop") { nativeId: NativeId ->
192
+ val player = players[nativeId]
193
+ player?.castStop()
194
+ }.runOnQueue(Queues.MAIN)
344
195
 
345
- /**
346
- * Resolve [nativeId]'s current paused state.
347
- * @param nativeId Target player Id.
348
- * @param promise JS promise object.
349
- */
350
- @ReactMethod
351
- fun isPaused(nativeId: NativeId, promise: Promise) {
352
- promise.bool.resolveOnUiThreadWithPlayer(nativeId) {
353
- isPaused
354
- }
355
- }
196
+ AsyncFunction("skipAd") { nativeId: NativeId ->
197
+ val player = players[nativeId]
198
+ player?.skipAd()
199
+ }.runOnQueue(Queues.MAIN)
356
200
 
357
- /**
358
- * Resolve [nativeId]'s current live state.
359
- * @param nativeId Target player Id.
360
- * @param promise JS promise object.
361
- */
362
- @ReactMethod
363
- fun isLive(nativeId: NativeId, promise: Promise) {
364
- promise.bool.resolveOnUiThreadWithPlayer(nativeId) {
365
- isLive
201
+ AsyncFunction("canPlayAtPlaybackSpeed") { _: String, _: Double ->
202
+ // This method is iOS-only, return false on Android
203
+ false
366
204
  }
367
- }
368
205
 
369
- /**
370
- * Resolve [nativeId]'s currently selected audio track.
371
- * @param nativeId Target player Id.
372
- * @param promise JS promise object.
373
- */
374
- @ReactMethod
375
- fun getAudioTrack(nativeId: NativeId, promise: Promise) {
376
- promise.map.nullable.resolveOnUiThreadWithPlayer(nativeId) {
377
- source?.selectedAudioTrack?.toJson()
206
+ AsyncFunction("getAudioTrack") { nativeId: NativeId ->
207
+ val player = players[nativeId]
208
+ return@AsyncFunction player?.source?.selectedAudioTrack?.toJson()
378
209
  }
379
- }
380
210
 
381
- /**
382
- * Resolve [nativeId]'s player available audio tracks.
383
- * @param nativeId Target player Id.
384
- * @param promise JS promise object.
385
- */
386
- @ReactMethod
387
- fun getAvailableAudioTracks(nativeId: NativeId, promise: Promise) {
388
- promise.array.resolveOnUiThreadWithPlayer(nativeId) {
389
- source?.availableAudioTracks?.mapToReactArray { it.toJson() } ?: Arguments.createArray()
211
+ AsyncFunction("getAvailableAudioTracks") { nativeId: NativeId ->
212
+ val player = players[nativeId]
213
+ return@AsyncFunction player?.source?.availableAudioTracks?.map { it.toJson() } ?: emptyList()
390
214
  }
391
- }
392
215
 
393
- /**
394
- * Set [nativeId]'s player audio track.
395
- * @param nativeId Target player Id.
396
- * @param trackIdentifier The audio track identifier.
397
- * @param promise JS promise object.
398
- */
399
- @ReactMethod
400
- fun setAudioTrack(nativeId: NativeId, trackIdentifier: String, promise: Promise) {
401
- promise.unit.resolveOnUiThreadWithPlayer(nativeId) {
402
- source?.setAudioTrack(trackIdentifier)
403
- }
404
- }
216
+ AsyncFunction("setAudioTrack") { nativeId: NativeId, trackIdentifier: String ->
217
+ val player = players[nativeId]
218
+ player?.source?.setAudioTrack(trackIdentifier)
219
+ }.runOnQueue(Queues.MAIN)
405
220
 
406
- /**
407
- * Resolve [nativeId]'s currently selected subtitle track.
408
- * @param nativeId Target player Id.
409
- * @param promise JS promise object.
410
- */
411
- @ReactMethod
412
- fun getSubtitleTrack(nativeId: NativeId, promise: Promise) {
413
- promise.map.nullable.resolveOnUiThreadWithPlayer(nativeId) {
414
- source?.selectedSubtitleTrack?.toJson()
221
+ AsyncFunction("getSubtitleTrack") { nativeId: NativeId ->
222
+ val player = players[nativeId]
223
+ return@AsyncFunction player?.source?.selectedSubtitleTrack?.toJson()
415
224
  }
416
- }
417
225
 
418
- /**
419
- * Resolve [nativeId]'s player available subtitle tracks.
420
- * @param nativeId Target player Id.
421
- * @param promise JS promise object.
422
- */
423
- @ReactMethod
424
- fun getAvailableSubtitles(nativeId: NativeId, promise: Promise) {
425
- promise.array.resolveOnUiThreadWithPlayer(nativeId) {
426
- source?.availableSubtitleTracks?.mapToReactArray { it.toJson() } ?: Arguments.createArray()
226
+ AsyncFunction("getAvailableSubtitles") { nativeId: NativeId ->
227
+ val player = players[nativeId]
228
+ return@AsyncFunction player?.source?.availableSubtitleTracks?.map { it.toJson() } ?: emptyList()
427
229
  }
428
- }
429
230
 
430
- /**
431
- * Set [nativeId]'s player subtitle track.
432
- * @param nativeId Target player Id.
433
- * @param trackIdentifier The subtitle track identifier.
434
- * @param promise JS promise object.
435
- */
436
- @ReactMethod
437
- fun setSubtitleTrack(nativeId: NativeId, trackIdentifier: String?, promise: Promise) {
438
- promise.unit.resolveOnUiThreadWithPlayer(nativeId) {
439
- source?.setSubtitleTrack(trackIdentifier)
440
- }
441
- }
231
+ AsyncFunction("setSubtitleTrack") { nativeId: NativeId, trackIdentifier: String? ->
232
+ val player = players[nativeId]
233
+ player?.source?.setSubtitleTrack(trackIdentifier)
234
+ }.runOnQueue(Queues.MAIN)
442
235
 
443
- /**
444
- * Schedules an `AdItem` in the [nativeId]'s associated player.
445
- * @param nativeId Target player id.
446
- * @param adItemJson Json representation of the `AdItem` to be scheduled.
447
- */
448
- @ReactMethod
449
- fun scheduleAd(nativeId: NativeId, adItemJson: ReadableMap, promise: Promise) {
450
- promise.unit.resolveOnUiThreadWithPlayer(nativeId) {
451
- scheduleAd(adItemJson.toAdItem() ?: throw IllegalArgumentException("invalid adItem"))
236
+ AsyncFunction("getVideoQuality") { nativeId: NativeId ->
237
+ val player = players[nativeId]
238
+ return@AsyncFunction player?.videoQuality?.toJson()
452
239
  }
453
- }
454
240
 
455
- /**
456
- * Skips the current ad in [nativeId]'s associated player.
457
- * Has no effect if the current ad is not skippable or if no ad is being played back.
458
- * @param nativeId Target player id.
459
- */
460
- @ReactMethod
461
- fun skipAd(nativeId: NativeId, promise: Promise) {
462
- promise.unit.resolveOnUiThreadWithPlayer(nativeId) {
463
- skipAd()
241
+ AsyncFunction("getAvailableVideoQualities") { nativeId: NativeId ->
242
+ val player = players[nativeId]
243
+ return@AsyncFunction player?.availableVideoQualities?.map { it.toJson() } ?: emptyList()
464
244
  }
465
- }
466
245
 
467
- /**
468
- * Returns `true` while an ad is being played back or when main content playback has been paused for ad playback.
469
- * @param nativeId Target player id.
470
- */
471
- @ReactMethod
472
- fun isAd(nativeId: NativeId, promise: Promise) {
473
- promise.unit.resolveOnUiThreadWithPlayer(nativeId) {
474
- isAd
475
- }
476
- }
246
+ AsyncFunction("setVideoQuality") { nativeId: NativeId, qualityId: String ->
247
+ val player = players[nativeId]
248
+ player?.source?.setVideoQuality(qualityId)
249
+ }.runOnQueue(Queues.MAIN)
477
250
 
478
- /**
479
- * The current time shift of the live stream in seconds. This value is always 0 if the active [source] is not a
480
- * live stream or there is no active playback session.
481
- * @param nativeId Target player id.
482
- */
483
- @ReactMethod
484
- fun getTimeShift(nativeId: NativeId, promise: Promise) {
485
- promise.double.resolveOnUiThreadWithPlayer(nativeId) {
486
- timeShift
251
+ AsyncFunction("getThumbnail") { nativeId: NativeId, time: Double ->
252
+ val player = players[nativeId]
253
+ return@AsyncFunction player?.getThumbnail(time)?.toJson()
487
254
  }
488
- }
255
+ AsyncFunction("loadOfflineContent") { nativeId: NativeId, offlineContentManagerBridgeId: String,
256
+ options: Map<String, Any>?, ->
257
+ val player = players[nativeId] ?: return@AsyncFunction
258
+ val offlineContentManagerBridge = appContext.registry.getModule<OfflineModule>()
259
+ ?.getOfflineContentManagerBridge(offlineContentManagerBridgeId)
489
260
 
490
- /**
491
- * The limit in seconds for time shifting. This value is either negative or 0 and it is always 0 if the active
492
- * [source] is not a live stream or there is no active playback session.
493
- * @param nativeId Target player id.
494
- */
495
- @ReactMethod
496
- fun getMaxTimeShift(nativeId: NativeId, promise: Promise) {
497
- promise.double.resolveOnUiThreadWithPlayer(nativeId) {
498
- maxTimeShift
499
- }
500
- }
261
+ offlineContentManagerBridge?.offlineContentManager?.offlineSourceConfig?.let {
262
+ player.load(it)
263
+ }
264
+ }.runOnQueue(Queues.MAIN)
501
265
 
502
- /**
503
- * Sets the max selectable bitrate for the player.
504
- * @param nativeId Target player id.
505
- * @param maxSelectableBitrate The desired max bitrate limit.
506
- */
507
- @ReactMethod
508
- fun setMaxSelectableBitrate(nativeId: NativeId, maxSelectableBitrate: Int, promise: Promise) {
509
- promise.unit.resolveOnUiThreadWithPlayer(nativeId) {
510
- setMaxSelectableVideoBitrate(
511
- maxSelectableBitrate.takeUnless { it == -1 } ?: Integer.MAX_VALUE,
512
- )
513
- }
514
- }
266
+ AsyncFunction("scheduleAd") { nativeId: NativeId, adItemJson: Map<String, Any> ->
267
+ val player = players[nativeId]
268
+ val adItem = adItemJson.toAdItem()
269
+ if (player != null && adItem != null) {
270
+ player.scheduleAd(adItem)
271
+ }
272
+ }.runOnQueue(Queues.MAIN)
273
+
274
+ AsyncFunction("initializeWithConfig") { nativeId: NativeId, config: Map<String, Any>?,
275
+ networkNativeId: NativeId?, decoderNativeId: NativeId?, ->
276
+ initializePlayer(nativeId, config, networkNativeId, decoderNativeId, null)
277
+ }.runOnQueue(Queues.MAIN)
278
+
279
+ AsyncFunction("initializeWithAnalyticsConfig") { nativeId: NativeId, analyticsConfigJson: Map<String, Any>,
280
+ config: Map<String, Any>?, networkNativeId: NativeId?, decoderNativeId: NativeId?, ->
281
+ initializePlayer(nativeId, config, networkNativeId, decoderNativeId, analyticsConfigJson)
282
+ }.runOnQueue(Queues.MAIN)
283
+
284
+ AsyncFunction("loadSource") { nativeId: NativeId, sourceNativeId: NativeId ->
285
+ val player = players[nativeId]
286
+ val source = appContext.registry.getModule<SourceModule>()?.getSourceOrNull(sourceNativeId)
287
+ if (player != null && source != null) {
288
+ player.load(source)
289
+ }
290
+ }.runOnQueue(Queues.MAIN)
515
291
 
516
- /**
517
- * Returns the thumbnail image for the active `Source` at a certain time.
518
- * @param nativeId Target player id.
519
- * @param time Playback time for the thumbnail.
520
- */
521
- @ReactMethod
522
- fun getThumbnail(nativeId: NativeId, time: Double, promise: Promise) {
523
- promise.map.nullable.resolveOnUiThreadWithPlayer(nativeId) {
524
- source?.getThumbnail(time)?.toJson()
292
+ AsyncFunction("source") { nativeId: NativeId ->
293
+ val player = players[nativeId]
294
+ return@AsyncFunction player?.source?.toJson()
525
295
  }
526
296
  }
527
297
 
528
- /**
529
- * Initiates casting the current video to a cast-compatible remote device. The user has to choose to which device it
530
- * should be sent.
531
- */
532
- @ReactMethod
533
- fun castVideo(nativeId: NativeId, promise: Promise) {
534
- promise.unit.resolveOnUiThreadWithPlayer(nativeId) {
535
- castVideo()
298
+ private fun initializePlayer(
299
+ nativeId: NativeId,
300
+ config: Map<String, Any>?,
301
+ networkNativeId: NativeId?,
302
+ decoderNativeId: NativeId?,
303
+ analyticsConfigJson: Map<String, Any>?,
304
+ ) {
305
+ if (players.containsKey(nativeId)) {
306
+ // Player already exists for this nativeId
307
+ return
536
308
  }
537
- }
538
309
 
539
- /**
540
- * Stops casting the current video. Has no effect if [isCasting] is false.
541
- */
542
- @ReactMethod
543
- fun castStop(nativeId: NativeId, promise: Promise) {
544
- promise.unit.resolveOnUiThreadWithPlayer(nativeId) {
545
- castStop()
546
- }
547
- }
310
+ val playerConfig = config?.toPlayerConfig() ?: PlayerConfig()
311
+ val enableMediaSession = config?.getMap("mediaControlConfig")
312
+ ?.toMediaControlConfig()?.isEnabled ?: true
548
313
 
549
- /**
550
- * Whether casting to a cast-compatible remote device is available. [PlayerEvent.CastAvailable] signals when
551
- * casting becomes available.
552
- */
553
- @ReactMethod
554
- fun isCastAvailable(nativeId: NativeId, promise: Promise) {
555
- promise.bool.resolveOnUiThreadWithPlayer(nativeId) {
556
- isCastAvailable
314
+ val networkConfig = networkNativeId?.let { id ->
315
+ appContext.registry.getModule<NetworkModule>()?.getConfig(id)
557
316
  }
558
- }
559
-
560
- /**
561
- * Whether video is currently being casted to a remote device and not played locally.
562
- */
563
- @ReactMethod
564
- fun isCasting(nativeId: NativeId, promise: Promise) {
565
- promise.bool.resolveOnUiThreadWithPlayer(nativeId) {
566
- isCasting
317
+ networkConfig?.let {
318
+ playerConfig.networkConfig = it
567
319
  }
568
- }
569
320
 
570
- /**
571
- * Resolve [nativeId]'s current video quality.
572
- */
573
- @ReactMethod
574
- fun getVideoQuality(nativeId: NativeId, promise: Promise) {
575
- promise.map.nullable.resolveOnUiThreadWithPlayer(nativeId) {
576
- source?.selectedVideoQuality?.toJson()
321
+ val decoderConfig = decoderNativeId?.let {
322
+ appContext.registry.getModule<DecoderConfigModule>()?.getDecoderConfig(it)
577
323
  }
578
- }
579
-
580
- /**
581
- * Resolve [nativeId]'s current available video qualities.
582
- */
583
- @ReactMethod
584
- fun getAvailableVideoQualities(nativeId: NativeId, promise: Promise) {
585
- promise.array.resolveOnUiThreadWithPlayer(nativeId) {
586
- source?.availableVideoQualities?.mapToReactArray { it.toJson() } ?: Arguments.createArray()
324
+ if (decoderConfig != null) {
325
+ playerConfig.playbackConfig = playerConfig.playbackConfig.copy(decoderConfig = decoderConfig)
587
326
  }
588
- }
589
327
 
590
- /**
591
- * Set [nativeId]'s player video quality.
592
- * NOTE: ONLY available on Android. No effect on iOS and tvOS devices.
593
- * @param nativeId Target player Id.
594
- * @param qualityId The videoQualityId identifier. A list of currently available VideoQualitys can be retrieved via availableVideoQualities. To use automatic quality selection, Quality.AUTO_ID can be passed as qualityId.
595
- * @param promise JS promise object.
596
- */
597
- @ReactMethod
598
- fun setVideoQuality(nativeId: NativeId, qualityId: String, promise: Promise) {
599
- promise.unit.resolveOnUiThreadWithPlayer(nativeId) {
600
- source?.setVideoQuality(qualityId)
601
- }
602
- }
328
+ val applicationContext = appContext.reactContext?.applicationContext
329
+ ?: throw IllegalStateException("Application context is not available")
330
+ val analyticsConfig = analyticsConfigJson?.toAnalyticsConfig()
331
+ val defaultMetadata = analyticsConfigJson?.getMap("defaultMetadata")?.toAnalyticsDefaultMetadata()
603
332
 
604
- /**
605
- * Resolve [nativeId]'s current playback speed.
606
- */
607
- @ReactMethod
608
- fun getPlaybackSpeed(nativeId: NativeId, promise: Promise) {
609
- promise.float.resolveOnUiThreadWithPlayer(nativeId) {
610
- playbackSpeed
333
+ val player = if (analyticsConfig != null) {
334
+ Player.create(
335
+ context = applicationContext,
336
+ playerConfig = playerConfig,
337
+ analyticsConfig = analyticsConfig,
338
+ defaultMetadata = defaultMetadata ?: DefaultMetadata(),
339
+ )
340
+ } else {
341
+ Player.create(applicationContext, playerConfig)
611
342
  }
612
- }
343
+ players[nativeId] = player
613
344
 
614
- /**
615
- * Sets playback speed for the player.
616
- */
617
- @ReactMethod
618
- fun setPlaybackSpeed(nativeId: NativeId, playbackSpeed: Float, promise: Promise) {
619
- promise.unit.resolveOnUiThreadWithPlayer(nativeId) {
620
- this.playbackSpeed = playbackSpeed
345
+ if (enableMediaSession) {
346
+ mediaSessionPlaybackManager.setupMediaSessionPlayback(nativeId)
621
347
  }
622
348
  }
623
349
 
624
- private inline fun <T> TPromise<T>.resolveOnUiThreadWithPlayer(
625
- nativeId: NativeId,
626
- crossinline block: Player.() -> T,
627
- ) = resolveOnUiThread { getPlayer(nativeId, this@PlayerModule).block() }
350
+ // CRITICAL: This method must remain available for cross-module access
351
+ fun getPlayerOrNull(nativeId: NativeId): Player? = players[nativeId]
628
352
  }