react-native-theoplayer 2.16.1 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +15 -0
- package/README.md +1 -0
- package/android/build.gradle +19 -22
- package/android/src/main/java/com/theoplayer/PlayerConfigAdapter.kt +87 -101
- package/android/src/main/java/com/theoplayer/ReactTHEOplayerContext.kt +30 -30
- package/android/src/main/java/com/theoplayer/ReactTHEOplayerPackage.kt +3 -1
- package/android/src/main/java/com/theoplayer/ReactTHEOplayerView.kt +1 -1
- package/android/src/main/java/com/theoplayer/cache/CacheAdapter.kt +127 -0
- package/android/src/main/java/com/theoplayer/cache/CacheModule.kt +238 -0
- package/android/src/main/java/com/theoplayer/player/PlayerModule.kt +27 -12
- package/android/src/main/java/com/theoplayer/source/SourceAdapter.kt +16 -37
- package/android/src/main/java/com/theoplayer/util/BridgeUtils.kt +60 -0
- package/android/src/main/java/com/theoplayer/util/PayloadBuilder.kt +10 -10
- package/ios/THEOplayerRCTBridge.m +22 -0
- package/ios/THEOplayerRCTDebug.swift +7 -1
- package/ios/THEOplayerRCTMainEventHandler.swift +25 -27
- package/ios/THEOplayerRCTSourceDescriptionAggregator.swift +41 -0
- package/ios/THEOplayerRCTSourceDescriptionBuilder.swift +3 -2
- package/ios/THEOplayerRCTTypeUtils.swift +37 -0
- package/ios/THEOplayerRCTView.swift +1 -2
- package/ios/ads/THEOplayerRCTAdsAPI+DAI.swift +3 -13
- package/ios/ads/THEOplayerRCTAdsAPI.swift +14 -48
- package/ios/ads/THEOplayerRCTView+AdsConfig.swift +0 -13
- package/ios/backgroundAudio/THEOplayerRCTNowPlayingManager.swift +24 -36
- package/ios/backgroundAudio/THEOplayerRCTRemoteCommandsManager.swift +2 -10
- package/ios/cache/THEOplayerRCTCacheAPI.swift +203 -0
- package/ios/cache/THEOplayerRCTCacheAggregator.swift +87 -0
- package/ios/cache/THEOplayerRCTCachingParametersBuilder.swift +27 -0
- package/ios/pip/THEOplayerRCTPipControlsManager.swift +2 -4
- package/lib/commonjs/api/abr/ABRConfiguration.js +21 -7
- package/lib/commonjs/api/abr/ABRConfiguration.js.map +1 -1
- package/lib/commonjs/api/ads/GoogleImaConfiguration.js.map +1 -1
- package/lib/commonjs/api/barrel.js +30 -19
- package/lib/commonjs/api/barrel.js.map +1 -1
- package/lib/commonjs/api/cache/CachingPreferredTrackSelection.js +2 -0
- package/lib/commonjs/api/cache/CachingPreferredTrackSelection.js.map +1 -0
- package/lib/commonjs/api/cache/CachingTask.js +30 -0
- package/lib/commonjs/api/cache/CachingTask.js.map +1 -0
- package/lib/commonjs/api/cache/CachingTaskLicense.js +6 -0
- package/lib/commonjs/api/cache/CachingTaskLicense.js.map +1 -0
- package/lib/commonjs/api/cache/CachingTaskList.js +6 -0
- package/lib/commonjs/api/cache/CachingTaskList.js.map +1 -0
- package/lib/commonjs/api/cache/CachingTaskParameters.js +6 -0
- package/lib/commonjs/api/cache/CachingTaskParameters.js.map +1 -0
- package/lib/commonjs/api/cache/MediaCacheAPI.js +24 -0
- package/lib/commonjs/api/cache/MediaCacheAPI.js.map +1 -0
- package/lib/commonjs/api/cache/barrel.js +83 -0
- package/lib/commonjs/api/cache/barrel.js.map +1 -0
- package/lib/commonjs/api/cache/events/CacheEvent.js +28 -0
- package/lib/commonjs/api/cache/events/CacheEvent.js.map +1 -0
- package/lib/commonjs/api/cache/events/CachingTaskEvent.js +17 -0
- package/lib/commonjs/api/cache/events/CachingTaskEvent.js.map +1 -0
- package/lib/commonjs/api/cache/events/barrel.js +28 -0
- package/lib/commonjs/api/cache/events/barrel.js.map +1 -0
- package/lib/commonjs/api/cache/hooks/barrel.js +39 -0
- package/lib/commonjs/api/cache/hooks/barrel.js.map +1 -0
- package/lib/commonjs/api/cache/hooks/useCachingTaskList.js +31 -0
- package/lib/commonjs/api/cache/hooks/useCachingTaskList.js.map +1 -0
- package/lib/commonjs/api/cache/hooks/useCachingTaskProgress.js +28 -0
- package/lib/commonjs/api/cache/hooks/useCachingTaskProgress.js.map +1 -0
- package/lib/commonjs/api/cache/hooks/useCachingTaskStatus.js +28 -0
- package/lib/commonjs/api/cache/hooks/useCachingTaskStatus.js.map +1 -0
- package/lib/commonjs/api/cast/CastState.js +3 -4
- package/lib/commonjs/api/cast/CastState.js.map +1 -1
- package/lib/commonjs/api/config/PlayerConfiguration.js.map +1 -1
- package/lib/commonjs/api/event/AdEvent.js +3 -4
- package/lib/commonjs/api/event/AdEvent.js.map +1 -1
- package/lib/commonjs/api/event/CastEvent.js +3 -4
- package/lib/commonjs/api/event/CastEvent.js.map +1 -1
- package/lib/commonjs/api/event/PlayerEvent.js +3 -4
- package/lib/commonjs/api/event/PlayerEvent.js.map +1 -1
- package/lib/commonjs/api/event/TrackEvent.js +12 -16
- package/lib/commonjs/api/event/TrackEvent.js.map +1 -1
- package/lib/commonjs/api/player/PlayerEventMap.js +7 -8
- package/lib/commonjs/api/player/PlayerEventMap.js.map +1 -1
- package/lib/commonjs/api/player/THEOplayer.js +6 -4
- package/lib/commonjs/api/player/THEOplayer.js.map +1 -1
- package/lib/commonjs/api/presentation/PresentationMode.js +3 -4
- package/lib/commonjs/api/presentation/PresentationMode.js.map +1 -1
- package/lib/commonjs/api/source/ads/Ads.js +3 -4
- package/lib/commonjs/api/source/ads/Ads.js.map +1 -1
- package/lib/commonjs/api/track/TextTrack.js +9 -12
- package/lib/commonjs/api/track/TextTrack.js.map +1 -1
- package/lib/commonjs/api/track/TextTrackStyle.js +3 -4
- package/lib/commonjs/api/track/TextTrackStyle.js.map +1 -1
- package/lib/commonjs/index.js +9 -1
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/internal/THEOplayerView.js +1 -1
- package/lib/commonjs/internal/THEOplayerView.js.map +1 -1
- package/lib/commonjs/internal/THEOplayerView.style.js +1 -2
- package/lib/commonjs/internal/THEOplayerView.style.js.map +1 -1
- package/lib/commonjs/internal/THEOplayerView.web.js +5 -5
- package/lib/commonjs/internal/THEOplayerView.web.js.map +1 -1
- package/lib/commonjs/internal/adapter/THEOplayerAdapter.js.map +1 -1
- package/lib/commonjs/internal/adapter/THEOplayerWebAdapter.js +12 -13
- package/lib/commonjs/internal/adapter/THEOplayerWebAdapter.js.map +1 -1
- package/lib/commonjs/internal/adapter/WebEventForwarder.js +10 -10
- package/lib/commonjs/internal/adapter/WebEventForwarder.js.map +1 -1
- package/lib/commonjs/internal/adapter/abr/AbrAdapter.js.map +1 -1
- package/lib/commonjs/internal/adapter/ads/THEOplayerWebAdsAdapter.js +2 -2
- package/lib/commonjs/internal/adapter/ads/THEOplayerWebAdsAdapter.js.map +1 -1
- package/lib/commonjs/internal/adapter/cast/THEOplayerNativeCastAdapter.js +1 -1
- package/lib/commonjs/internal/adapter/cast/THEOplayerNativeCastAdapter.js.map +1 -1
- package/lib/commonjs/internal/adapter/cast/THEOplayerWebCastAdapter.js.map +1 -1
- package/lib/commonjs/internal/adapter/event/BaseEvent.js.map +1 -1
- package/lib/commonjs/internal/adapter/event/DefaultEventDispatcher.js +1 -1
- package/lib/commonjs/internal/adapter/event/DefaultEventDispatcher.js.map +1 -1
- package/lib/commonjs/internal/adapter/event/native/NativeTrackEvent.js +12 -16
- package/lib/commonjs/internal/adapter/event/native/NativeTrackEvent.js.map +1 -1
- package/lib/commonjs/internal/adapter/track/TextTrackStyleAdapter.js.map +1 -1
- package/lib/commonjs/internal/adapter/web/FullscreenAPI.js +1 -2
- package/lib/commonjs/internal/adapter/web/FullscreenAPI.js.map +1 -1
- package/lib/commonjs/internal/adapter/web/WebMediaSession.js +9 -11
- package/lib/commonjs/internal/adapter/web/WebMediaSession.js.map +1 -1
- package/lib/commonjs/internal/adapter/web/WebPresentationModeManager.js +4 -4
- package/lib/commonjs/internal/adapter/web/WebPresentationModeManager.js.map +1 -1
- package/lib/commonjs/internal/cache/MediaCache.js +117 -0
- package/lib/commonjs/internal/cache/MediaCache.js.map +1 -0
- package/lib/commonjs/internal/cache/MediaCache.web.js +54 -0
- package/lib/commonjs/internal/cache/MediaCache.web.js.map +1 -0
- package/lib/commonjs/internal/cache/NativeCachingTaskAdapter.js +59 -0
- package/lib/commonjs/internal/cache/NativeCachingTaskAdapter.js.map +1 -0
- package/lib/commonjs/internal/cache/NativeCachingTaskParametersAdapter.js +27 -0
- package/lib/commonjs/internal/cache/NativeCachingTaskParametersAdapter.js.map +1 -0
- package/lib/commonjs/internal/cache/WebCachingTaskAdapter.js +71 -0
- package/lib/commonjs/internal/cache/WebCachingTaskAdapter.js.map +1 -0
- package/lib/commonjs/internal/drm/ContentProtectionRegistry.js +1 -2
- package/lib/commonjs/internal/drm/ContentProtectionRegistry.js.map +1 -1
- package/lib/commonjs/internal/drm/ContentProtectionRegistry.web.js +1 -2
- package/lib/commonjs/internal/drm/ContentProtectionRegistry.web.js.map +1 -1
- package/lib/commonjs/internal/drm/NativeCertificateResponse.js.map +1 -1
- package/lib/commonjs/internal/drm/NativeLicenseResponse.js.map +1 -1
- package/lib/commonjs/internal/utils/TypeUtils.js +2 -4
- package/lib/commonjs/internal/utils/TypeUtils.js.map +1 -1
- package/lib/module/api/abr/ABRConfiguration.js +24 -6
- package/lib/module/api/abr/ABRConfiguration.js.map +1 -1
- package/lib/module/api/ads/GoogleImaConfiguration.js.map +1 -1
- package/lib/module/api/barrel.js +1 -0
- package/lib/module/api/barrel.js.map +1 -1
- package/lib/module/api/cache/CachingPreferredTrackSelection.js +2 -0
- package/lib/module/api/cache/CachingPreferredTrackSelection.js.map +1 -0
- package/lib/module/api/cache/CachingTask.js +25 -0
- package/lib/module/api/cache/CachingTask.js.map +1 -0
- package/lib/module/api/cache/CachingTaskLicense.js +2 -0
- package/lib/module/api/cache/CachingTaskLicense.js.map +1 -0
- package/lib/module/api/cache/CachingTaskList.js +2 -0
- package/lib/module/api/cache/CachingTaskList.js.map +1 -0
- package/lib/module/api/cache/CachingTaskParameters.js +2 -0
- package/lib/module/api/cache/CachingTaskParameters.js.map +1 -0
- package/lib/module/api/cache/MediaCacheAPI.js +19 -0
- package/lib/module/api/cache/MediaCacheAPI.js.map +1 -0
- package/lib/module/api/cache/barrel.js +8 -0
- package/lib/module/api/cache/barrel.js.map +1 -0
- package/lib/module/api/cache/events/CacheEvent.js +25 -0
- package/lib/module/api/cache/events/CacheEvent.js.map +1 -0
- package/lib/module/api/cache/events/CachingTaskEvent.js +12 -0
- package/lib/module/api/cache/events/CachingTaskEvent.js.map +1 -0
- package/lib/module/api/cache/events/barrel.js +3 -0
- package/lib/module/api/cache/events/barrel.js.map +1 -0
- package/lib/module/api/cache/hooks/barrel.js +4 -0
- package/lib/module/api/cache/hooks/barrel.js.map +1 -0
- package/lib/module/api/cache/hooks/useCachingTaskList.js +24 -0
- package/lib/module/api/cache/hooks/useCachingTaskList.js.map +1 -0
- package/lib/module/api/cache/hooks/useCachingTaskProgress.js +21 -0
- package/lib/module/api/cache/hooks/useCachingTaskProgress.js.map +1 -0
- package/lib/module/api/cache/hooks/useCachingTaskStatus.js +21 -0
- package/lib/module/api/cache/hooks/useCachingTaskStatus.js.map +1 -0
- package/lib/module/api/cast/CastState.js +3 -3
- package/lib/module/api/cast/CastState.js.map +1 -1
- package/lib/module/api/config/PlayerConfiguration.js.map +1 -1
- package/lib/module/api/event/AdEvent.js +3 -3
- package/lib/module/api/event/AdEvent.js.map +1 -1
- package/lib/module/api/event/CastEvent.js +3 -3
- package/lib/module/api/event/CastEvent.js.map +1 -1
- package/lib/module/api/event/PlayerEvent.js +3 -3
- package/lib/module/api/event/PlayerEvent.js.map +1 -1
- package/lib/module/api/event/TrackEvent.js +12 -12
- package/lib/module/api/event/TrackEvent.js.map +1 -1
- package/lib/module/api/player/PlayerEventMap.js +8 -8
- package/lib/module/api/player/PlayerEventMap.js.map +1 -1
- package/lib/module/api/player/THEOplayer.js +7 -3
- package/lib/module/api/player/THEOplayer.js.map +1 -1
- package/lib/module/api/presentation/PresentationMode.js +3 -3
- package/lib/module/api/presentation/PresentationMode.js.map +1 -1
- package/lib/module/api/source/ads/Ads.js +3 -3
- package/lib/module/api/source/ads/Ads.js.map +1 -1
- package/lib/module/api/track/TextTrack.js +9 -9
- package/lib/module/api/track/TextTrack.js.map +1 -1
- package/lib/module/api/track/TextTrackStyle.js +3 -3
- package/lib/module/api/track/TextTrackStyle.js.map +1 -1
- package/lib/module/index.js +1 -0
- package/lib/module/index.js.map +1 -1
- package/lib/module/internal/THEOplayerView.js +1 -1
- package/lib/module/internal/THEOplayerView.js.map +1 -1
- package/lib/module/internal/THEOplayerView.web.js +5 -5
- package/lib/module/internal/THEOplayerView.web.js.map +1 -1
- package/lib/module/internal/adapter/THEOplayerAdapter.js.map +1 -1
- package/lib/module/internal/adapter/THEOplayerWebAdapter.js +12 -11
- package/lib/module/internal/adapter/THEOplayerWebAdapter.js.map +1 -1
- package/lib/module/internal/adapter/WebEventForwarder.js +10 -10
- package/lib/module/internal/adapter/WebEventForwarder.js.map +1 -1
- package/lib/module/internal/adapter/abr/AbrAdapter.js.map +1 -1
- package/lib/module/internal/adapter/ads/THEOplayerWebAdsAdapter.js +2 -2
- package/lib/module/internal/adapter/ads/THEOplayerWebAdsAdapter.js.map +1 -1
- package/lib/module/internal/adapter/cast/THEOplayerNativeCastAdapter.js +1 -1
- package/lib/module/internal/adapter/cast/THEOplayerNativeCastAdapter.js.map +1 -1
- package/lib/module/internal/adapter/cast/THEOplayerWebCastAdapter.js.map +1 -1
- package/lib/module/internal/adapter/event/BaseEvent.js.map +1 -1
- package/lib/module/internal/adapter/event/DefaultEventDispatcher.js +1 -1
- package/lib/module/internal/adapter/event/DefaultEventDispatcher.js.map +1 -1
- package/lib/module/internal/adapter/event/native/NativeTrackEvent.js +12 -12
- package/lib/module/internal/adapter/event/native/NativeTrackEvent.js.map +1 -1
- package/lib/module/internal/adapter/track/TextTrackStyleAdapter.js.map +1 -1
- package/lib/module/internal/adapter/web/FullscreenAPI.js.map +1 -1
- package/lib/module/internal/adapter/web/WebMediaSession.js +8 -9
- package/lib/module/internal/adapter/web/WebMediaSession.js.map +1 -1
- package/lib/module/internal/adapter/web/WebPresentationModeManager.js +4 -4
- package/lib/module/internal/adapter/web/WebPresentationModeManager.js.map +1 -1
- package/lib/module/internal/cache/MediaCache.js +110 -0
- package/lib/module/internal/cache/MediaCache.js.map +1 -0
- package/lib/module/internal/cache/MediaCache.web.js +45 -0
- package/lib/module/internal/cache/MediaCache.web.js.map +1 -0
- package/lib/module/internal/cache/NativeCachingTaskAdapter.js +52 -0
- package/lib/module/internal/cache/NativeCachingTaskAdapter.js.map +1 -0
- package/lib/module/internal/cache/NativeCachingTaskParametersAdapter.js +20 -0
- package/lib/module/internal/cache/NativeCachingTaskParametersAdapter.js.map +1 -0
- package/lib/module/internal/cache/WebCachingTaskAdapter.js +64 -0
- package/lib/module/internal/cache/WebCachingTaskAdapter.js.map +1 -0
- package/lib/module/internal/drm/ContentProtectionRegistry.js.map +1 -1
- package/lib/module/internal/drm/ContentProtectionRegistry.web.js.map +1 -1
- package/lib/module/internal/drm/NativeCertificateResponse.js.map +1 -1
- package/lib/module/internal/drm/NativeLicenseResponse.js.map +1 -1
- package/lib/typescript/api/abr/ABRConfiguration.d.ts +1 -1
- package/lib/typescript/api/ads/Ad.d.ts +2 -2
- package/lib/typescript/api/ads/AdsConfiguration.d.ts +2 -2
- package/lib/typescript/api/ads/GoogleImaConfiguration.d.ts +1 -0
- package/lib/typescript/api/barrel.d.ts +1 -0
- package/lib/typescript/api/cache/CachingPreferredTrackSelection.d.ts +23 -0
- package/lib/typescript/api/cache/CachingTask.d.ts +93 -0
- package/lib/typescript/api/cache/CachingTaskLicense.d.ts +14 -0
- package/lib/typescript/api/cache/CachingTaskList.d.ts +7 -0
- package/lib/typescript/api/cache/CachingTaskParameters.d.ts +57 -0
- package/lib/typescript/api/cache/MediaCacheAPI.d.ts +39 -0
- package/lib/typescript/api/cache/barrel.d.ts +7 -0
- package/lib/typescript/api/cache/events/CacheEvent.d.ts +55 -0
- package/lib/typescript/api/cache/events/CachingTaskEvent.d.ts +22 -0
- package/lib/typescript/api/cache/events/barrel.d.ts +2 -0
- package/lib/typescript/api/cache/hooks/barrel.d.ts +3 -0
- package/lib/typescript/api/cache/hooks/useCachingTaskList.d.ts +1 -0
- package/lib/typescript/api/cache/hooks/useCachingTaskProgress.d.ts +2 -0
- package/lib/typescript/api/cache/hooks/useCachingTaskStatus.d.ts +2 -0
- package/lib/typescript/api/cast/CastConfiguration.d.ts +1 -1
- package/lib/typescript/api/config/PlayerConfiguration.d.ts +4 -1
- package/lib/typescript/api/drm/ContentProtectionIntegration.d.ts +2 -2
- package/lib/typescript/api/drm/ContentProtectionRequest.d.ts +1 -1
- package/lib/typescript/api/error/ChromecastError.d.ts +1 -1
- package/lib/typescript/api/event/CastEvent.d.ts +1 -1
- package/lib/typescript/api/event/EventDispatcher.d.ts +2 -2
- package/lib/typescript/api/event/EventListener.d.ts +1 -1
- package/lib/typescript/api/player/THEOplayer.d.ts +2 -2
- package/lib/typescript/api/source/SourceDescription.d.ts +3 -3
- package/lib/typescript/api/source/ads/Ads.d.ts +1 -1
- package/lib/typescript/api/source/ads/FreeWheelAdDescription.d.ts +1 -1
- package/lib/typescript/api/source/ads/ssai/GoogleDAIConfiguration.d.ts +2 -2
- package/lib/typescript/api/source/ads/ssai/ImagineServerSideAdInsertionConfiguration.d.ts +1 -1
- package/lib/typescript/api/source/ads/ssai/ServerSideAdInsertionConfiguration.d.ts +1 -1
- package/lib/typescript/api/source/ads/ssai/YospaceServerSideAdInsertionConfiguration.d.ts +2 -2
- package/lib/typescript/api/source/dash/DashPlaybackConfiguration.d.ts +1 -1
- package/lib/typescript/api/source/drm/DRMConfiguration.d.ts +3 -3
- package/lib/typescript/api/source/hls/HlsPlaybackConfiguration.d.ts +1 -1
- package/lib/typescript/api/track/MediaTrack.d.ts +1 -1
- package/lib/typescript/index.d.ts +1 -0
- package/lib/typescript/internal/THEOplayerView.web.d.ts +1 -1
- package/lib/typescript/internal/adapter/THEOplayerWebAdapter.d.ts +2 -2
- package/lib/typescript/internal/adapter/WebEventForwarder.d.ts +2 -2
- package/lib/typescript/internal/adapter/ads/THEOplayerWebAdsAdapter.d.ts +2 -2
- package/lib/typescript/internal/adapter/cast/THEOplayerWebCastAdapter.d.ts +2 -2
- package/lib/typescript/internal/adapter/event/native/NativeCastEvent.d.ts +1 -1
- package/lib/typescript/internal/adapter/web/WebPresentationModeManager.d.ts +2 -2
- package/lib/typescript/internal/cache/MediaCache.d.ts +25 -0
- package/lib/typescript/internal/cache/MediaCache.web.d.ts +16 -0
- package/lib/typescript/internal/cache/NativeCachingTaskAdapter.d.ts +33 -0
- package/lib/typescript/internal/cache/NativeCachingTaskParametersAdapter.d.ts +11 -0
- package/lib/typescript/internal/cache/WebCachingTaskAdapter.d.ts +25 -0
- package/package.json +16 -15
- package/react-native-theoplayer.podspec +5 -5
- package/src/api/ads/GoogleImaConfiguration.ts +1 -0
- package/src/api/barrel.ts +1 -0
- package/src/api/cache/CachingPreferredTrackSelection.ts +24 -0
- package/src/api/cache/CachingTask.ts +107 -0
- package/src/api/cache/CachingTaskLicense.ts +15 -0
- package/src/api/cache/CachingTaskList.ts +8 -0
- package/src/api/cache/CachingTaskParameters.ts +62 -0
- package/src/api/cache/MediaCacheAPI.ts +43 -0
- package/src/api/cache/barrel.ts +7 -0
- package/src/api/cache/events/CacheEvent.ts +62 -0
- package/src/api/cache/events/CachingTaskEvent.ts +27 -0
- package/src/api/cache/events/barrel.ts +2 -0
- package/src/api/cache/hooks/barrel.ts +3 -0
- package/src/api/cache/hooks/useCachingTaskList.ts +23 -0
- package/src/api/cache/hooks/useCachingTaskProgress.ts +20 -0
- package/src/api/cache/hooks/useCachingTaskStatus.ts +20 -0
- package/src/api/config/PlayerConfiguration.ts +3 -0
- package/src/index.tsx +1 -0
- package/src/internal/THEOplayerView.web.tsx +5 -5
- package/src/internal/adapter/THEOplayerWebAdapter.ts +6 -6
- package/src/internal/adapter/WebEventForwarder.ts +3 -3
- package/src/internal/adapter/ads/THEOplayerWebAdsAdapter.ts +3 -3
- package/src/internal/adapter/cast/THEOplayerWebCastAdapter.ts +3 -3
- package/src/internal/adapter/web/WebPresentationModeManager.ts +3 -3
- package/src/internal/cache/MediaCache.ts +151 -0
- package/src/internal/cache/MediaCache.web.ts +54 -0
- package/src/internal/cache/NativeCachingTaskAdapter.ts +81 -0
- package/src/internal/cache/NativeCachingTaskParametersAdapter.ts +32 -0
- package/src/internal/cache/WebCachingTaskAdapter.ts +95 -0
- package/android/src/main/java/com/theoplayer/track/QualityListFilter.kt +0 -28
|
@@ -0,0 +1,238 @@
|
|
|
1
|
+
@file:Suppress("unused")
|
|
2
|
+
|
|
3
|
+
package com.theoplayer.cache
|
|
4
|
+
|
|
5
|
+
import android.os.Handler
|
|
6
|
+
import android.os.Looper
|
|
7
|
+
import android.util.Log
|
|
8
|
+
import com.facebook.react.bridge.Arguments
|
|
9
|
+
import com.facebook.react.bridge.Promise
|
|
10
|
+
import com.facebook.react.bridge.ReactApplicationContext
|
|
11
|
+
import com.facebook.react.bridge.ReactContextBaseJavaModule
|
|
12
|
+
import com.facebook.react.bridge.ReactMethod
|
|
13
|
+
import com.facebook.react.bridge.ReadableMap
|
|
14
|
+
import com.facebook.react.bridge.WritableMap
|
|
15
|
+
import com.facebook.react.modules.core.DeviceEventManagerModule
|
|
16
|
+
import com.google.gson.Gson
|
|
17
|
+
import com.theoplayer.util.ViewResolver
|
|
18
|
+
import com.theoplayer.android.api.THEOplayerGlobal
|
|
19
|
+
import com.theoplayer.android.api.cache.Cache
|
|
20
|
+
import com.theoplayer.android.api.cache.CachingTask
|
|
21
|
+
import com.theoplayer.android.api.event.EventListener
|
|
22
|
+
import com.theoplayer.android.api.event.cache.CacheEventTypes
|
|
23
|
+
import com.theoplayer.android.api.event.cache.task.CachingTaskErrorEvent
|
|
24
|
+
import com.theoplayer.android.api.event.cache.task.CachingTaskEventTypes
|
|
25
|
+
import com.theoplayer.android.api.event.cache.task.CachingTaskProgressEvent
|
|
26
|
+
import com.theoplayer.android.api.event.cache.task.CachingTaskStateChangeEvent
|
|
27
|
+
import com.theoplayer.android.api.event.cache.tasklist.CachingTaskListEventTypes
|
|
28
|
+
import com.theoplayer.drm.ContentProtectionAdapter
|
|
29
|
+
import com.theoplayer.source.SourceAdapter
|
|
30
|
+
import org.json.JSONException
|
|
31
|
+
import org.json.JSONObject
|
|
32
|
+
|
|
33
|
+
private const val TAG = "CacheModule"
|
|
34
|
+
|
|
35
|
+
private const val PROP_STATUS = "status"
|
|
36
|
+
private const val PROP_ID = "id"
|
|
37
|
+
private const val PROP_TASK = "task"
|
|
38
|
+
private const val PROP_TASKS = "tasks"
|
|
39
|
+
private const val PROP_PROGRESS = "progress"
|
|
40
|
+
private const val PROP_ERROR = "error"
|
|
41
|
+
|
|
42
|
+
class CacheModule(private val context: ReactApplicationContext) :
|
|
43
|
+
ReactContextBaseJavaModule(context) {
|
|
44
|
+
private val viewResolver: ViewResolver = ViewResolver(context)
|
|
45
|
+
private val onTaskProgress = mutableMapOf<String, EventListener<CachingTaskProgressEvent>>()
|
|
46
|
+
private val onTaskError = mutableMapOf<String, EventListener<CachingTaskErrorEvent>>()
|
|
47
|
+
private val onTaskStateChange = mutableMapOf<String, EventListener<CachingTaskStateChangeEvent>>()
|
|
48
|
+
private val sourceAdapter = SourceAdapter()
|
|
49
|
+
private val cache: Cache?
|
|
50
|
+
get() = THEOplayerGlobal.getSharedInstance(context.applicationContext).cache
|
|
51
|
+
private val handler = Handler(Looper.getMainLooper())
|
|
52
|
+
|
|
53
|
+
init {
|
|
54
|
+
// Add cache event listeners
|
|
55
|
+
cache?.apply {
|
|
56
|
+
// Listen for cache state changes
|
|
57
|
+
addEventListener(CacheEventTypes.CACHE_STATE_CHANGE) { event ->
|
|
58
|
+
emit("onCacheStatusChange", Arguments.createMap().apply {
|
|
59
|
+
putString(PROP_STATUS, CacheAdapter.fromCacheStatus(event.status))
|
|
60
|
+
})
|
|
61
|
+
}
|
|
62
|
+
// Listen for add task events
|
|
63
|
+
tasks.addEventListener(CachingTaskListEventTypes.ADD_TASK) { event ->
|
|
64
|
+
event.task?.let { task ->
|
|
65
|
+
// Notify AddCachingTaskEvent event
|
|
66
|
+
emit("onAddCachingTaskEvent", Arguments.createMap().apply {
|
|
67
|
+
putMap(PROP_TASK, CacheAdapter.fromCachingTask(task))
|
|
68
|
+
})
|
|
69
|
+
// Add CachingTask listeners
|
|
70
|
+
addCachingTaskListeners(task)
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
// Listen for task removal
|
|
75
|
+
tasks.addEventListener(CachingTaskListEventTypes.REMOVE_TASK) { event ->
|
|
76
|
+
event.task?.let { task ->
|
|
77
|
+
// Notify RemoveCachingTaskEvent event
|
|
78
|
+
emit("onRemoveCachingTaskEvent", Arguments.createMap().apply {
|
|
79
|
+
putMap(PROP_TASK, CacheAdapter.fromCachingTask(event.task))
|
|
80
|
+
})
|
|
81
|
+
// Remove CachingTask listeners
|
|
82
|
+
removeCachingTaskListeners(task)
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
override fun getName(): String {
|
|
89
|
+
return TAG
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
private fun addCachingTaskListeners(task: CachingTask) {
|
|
93
|
+
// Listen for task progress
|
|
94
|
+
onTaskProgress[task.id] = EventListener<CachingTaskProgressEvent> { progressEvent ->
|
|
95
|
+
emit("onCachingTaskProgressEvent", Arguments.createMap().apply {
|
|
96
|
+
putString(PROP_ID, task.id)
|
|
97
|
+
putMap(PROP_PROGRESS, CacheAdapter.fromCachingTaskProgress(progressEvent.progress))
|
|
98
|
+
})
|
|
99
|
+
}.also { listener ->
|
|
100
|
+
task.addEventListener(CachingTaskEventTypes.CACHING_TASK_PROGRESS, listener)
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
// Listen for task errors
|
|
104
|
+
onTaskError[task.id] = EventListener<CachingTaskErrorEvent> { errorEvent ->
|
|
105
|
+
emit("onCachingTaskErrorEvent", Arguments.createMap().apply {
|
|
106
|
+
putString(PROP_ID, task.id)
|
|
107
|
+
putString(PROP_ERROR, errorEvent.error.description)
|
|
108
|
+
})
|
|
109
|
+
}.also { listener ->
|
|
110
|
+
task.addEventListener(CachingTaskEventTypes.CACHING_TASK_ERROR, listener)
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
// Listen for task state changes
|
|
114
|
+
onTaskStateChange[task.id] = EventListener<CachingTaskStateChangeEvent> { changeEvent ->
|
|
115
|
+
emit("onCachingTaskStatusChangeEvent", Arguments.createMap().apply {
|
|
116
|
+
putString(PROP_ID, task.id)
|
|
117
|
+
putString(PROP_STATUS, CacheAdapter.fromCacheTaskStatus(changeEvent.status))
|
|
118
|
+
})
|
|
119
|
+
}.also { listener ->
|
|
120
|
+
task.addEventListener(CachingTaskEventTypes.CACHING_TASK_STATE_CHANGE, listener)
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
private fun removeCachingTaskListeners(task: CachingTask) {
|
|
125
|
+
onTaskProgress[task.id]?.apply {
|
|
126
|
+
task.removeEventListener(CachingTaskEventTypes.CACHING_TASK_PROGRESS, this)
|
|
127
|
+
}
|
|
128
|
+
onTaskProgress.remove(task.id)
|
|
129
|
+
onTaskError[task.id]?.apply {
|
|
130
|
+
task.removeEventListener(CachingTaskEventTypes.CACHING_TASK_ERROR, this)
|
|
131
|
+
}
|
|
132
|
+
onTaskError.remove(task.id)
|
|
133
|
+
onTaskStateChange[task.id]?.apply {
|
|
134
|
+
task.removeEventListener(CachingTaskEventTypes.CACHING_TASK_STATE_CHANGE, this)
|
|
135
|
+
}
|
|
136
|
+
onTaskStateChange.remove(task.id)
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
private fun emit(
|
|
140
|
+
eventName: String,
|
|
141
|
+
payload: WritableMap
|
|
142
|
+
) {
|
|
143
|
+
// Make sure we are not emitting before React has been setup.
|
|
144
|
+
if (!context.hasActiveReactInstance()) {
|
|
145
|
+
return
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
context
|
|
149
|
+
.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter::class.java)
|
|
150
|
+
.emit(eventName, payload)
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
@ReactMethod
|
|
154
|
+
fun getInitialState(promise: Promise) {
|
|
155
|
+
handler.post {
|
|
156
|
+
cache?.apply {
|
|
157
|
+
|
|
158
|
+
// Add listeners to existing tasks
|
|
159
|
+
tasks.forEach { task ->
|
|
160
|
+
addCachingTaskListeners(task)
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
promise.resolve(Arguments.createMap().apply {
|
|
164
|
+
putString(PROP_STATUS, CacheAdapter.fromCacheStatus(status))
|
|
165
|
+
putArray(PROP_TASKS, CacheAdapter.fromCachingTaskList(tasks))
|
|
166
|
+
})
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
@ReactMethod
|
|
172
|
+
fun createTask(source: ReadableMap, parameters: ReadableMap) {
|
|
173
|
+
val sourceDescription = sourceAdapter.parseSourceFromJS(source)
|
|
174
|
+
if (sourceDescription != null) {
|
|
175
|
+
handler.post {
|
|
176
|
+
cache?.createTask(
|
|
177
|
+
sourceDescription,
|
|
178
|
+
CacheAdapter.parseCachingParameters(parameters)
|
|
179
|
+
)
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
@ReactMethod
|
|
185
|
+
fun pauseCachingTask(id: String) {
|
|
186
|
+
handler.post {
|
|
187
|
+
cache?.tasks?.getTaskById(id)?.pause()
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
@ReactMethod
|
|
192
|
+
fun removeCachingTask(id: String) {
|
|
193
|
+
handler.post {
|
|
194
|
+
cache?.tasks?.getTaskById(id)?.remove()
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
@ReactMethod
|
|
199
|
+
fun startCachingTask(id: String) {
|
|
200
|
+
handler.post {
|
|
201
|
+
cache?.tasks?.getTaskById(id)?.start()
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
@ReactMethod
|
|
206
|
+
fun renewLicense(id: String, drmConfiguration: ReadableMap?) {
|
|
207
|
+
handler.post {
|
|
208
|
+
if (drmConfiguration == null) {
|
|
209
|
+
taskById(id)?.license()?.renew()
|
|
210
|
+
} else {
|
|
211
|
+
try {
|
|
212
|
+
val drmConfigurationJson = JSONObject(Gson().toJson(drmConfiguration.toHashMap()))
|
|
213
|
+
taskById(id)?.license()
|
|
214
|
+
?.renew(ContentProtectionAdapter.drmConfigurationFromJson(drmConfigurationJson))
|
|
215
|
+
} catch (e: JSONException) {
|
|
216
|
+
e.printStackTrace()
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
@ReactMethod
|
|
223
|
+
@Suppress("UNUSED_PARAMETER")
|
|
224
|
+
fun addListener(eventName: String?) {
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
@ReactMethod
|
|
228
|
+
@Suppress("UNUSED_PARAMETER")
|
|
229
|
+
fun removeListeners(count: Int?) {
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
private fun taskById(id: String): CachingTask? {
|
|
233
|
+
return cache?.tasks?.getTaskById(id) ?: run {
|
|
234
|
+
Log.w(TAG, "CachingTask with id $id not found")
|
|
235
|
+
return null
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
}
|
|
@@ -11,9 +11,7 @@ import com.theoplayer.android.api.player.track.mediatrack.quality.VideoQuality
|
|
|
11
11
|
import com.theoplayer.android.api.player.track.texttrack.TextTrackMode
|
|
12
12
|
import com.theoplayer.audio.BackgroundAudioConfigAdapter
|
|
13
13
|
import com.theoplayer.presentation.PipConfigAdapter
|
|
14
|
-
import com.theoplayer.track.QualityListFilter
|
|
15
14
|
import com.theoplayer.track.TextTrackStyleAdapter
|
|
16
|
-
import com.theoplayer.track.emptyQualityList
|
|
17
15
|
import com.theoplayer.util.ViewResolver
|
|
18
16
|
|
|
19
17
|
private const val TAG = "PlayerModule"
|
|
@@ -120,22 +118,39 @@ class PlayerModule(context: ReactApplicationContext) : ReactContextBaseJavaModul
|
|
|
120
118
|
}
|
|
121
119
|
}
|
|
122
120
|
|
|
121
|
+
/**
|
|
122
|
+
* Check whether a uid is contained in an array of uids.
|
|
123
|
+
*/
|
|
124
|
+
private fun containsUid(uid: Int, uids: ReadableArray): Boolean {
|
|
125
|
+
for (q in 0 until uids.size()) {
|
|
126
|
+
if (uids.getInt(q) == uid) {
|
|
127
|
+
return true
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
return false
|
|
131
|
+
}
|
|
132
|
+
|
|
123
133
|
@ReactMethod
|
|
124
134
|
fun setTargetVideoQuality(tag: Int, uids: ReadableArray) {
|
|
125
135
|
viewResolver.resolveViewByTag(tag) { view: ReactTHEOplayerView? ->
|
|
126
136
|
view?.player?.let {
|
|
127
137
|
// Apply the target quality to the current enabled video track
|
|
128
138
|
for (track in it.videoTracks) {
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
+
// Only consider enabled tracks
|
|
140
|
+
if (!track.isEnabled) {
|
|
141
|
+
continue
|
|
142
|
+
}
|
|
143
|
+
val currentVideoTrack = track as MediaTrack<VideoQuality>
|
|
144
|
+
if (uids.size() == 0) {
|
|
145
|
+
// Reset target qualities when passing empty list.
|
|
146
|
+
currentVideoTrack.setTargetQualities(listOf())
|
|
147
|
+
currentVideoTrack.targetQuality = null
|
|
148
|
+
} else {
|
|
149
|
+
// Filter qualities based on target uids
|
|
150
|
+
currentVideoTrack.qualities?.let { availableQualities ->
|
|
151
|
+
currentVideoTrack.setTargetQualities(availableQualities.filter { quality ->
|
|
152
|
+
containsUid(quality.uid, uids)
|
|
153
|
+
})
|
|
139
154
|
}
|
|
140
155
|
}
|
|
141
156
|
}
|
|
@@ -2,9 +2,12 @@ package com.theoplayer.source
|
|
|
2
2
|
|
|
3
3
|
import android.text.TextUtils
|
|
4
4
|
import android.util.Log
|
|
5
|
+
import com.facebook.react.bridge.Arguments
|
|
5
6
|
import com.google.gson.Gson
|
|
6
7
|
import com.theoplayer.android.api.error.THEOplayerException
|
|
7
8
|
import com.facebook.react.bridge.ReadableMap
|
|
9
|
+
import com.facebook.react.bridge.WritableArray
|
|
10
|
+
import com.facebook.react.bridge.WritableMap
|
|
8
11
|
import com.theoplayer.android.api.source.SourceDescription
|
|
9
12
|
import com.theoplayer.android.api.source.TypedSource
|
|
10
13
|
import com.theoplayer.android.api.source.metadata.MetadataDescription
|
|
@@ -15,17 +18,16 @@ import com.theoplayer.android.api.source.ssai.SsaiIntegration
|
|
|
15
18
|
import com.theoplayer.android.api.source.GoogleDaiTypedSource
|
|
16
19
|
import com.theoplayer.android.api.source.ssai.dai.GoogleDaiVodConfiguration
|
|
17
20
|
import com.theoplayer.android.api.source.ssai.dai.GoogleDaiLiveConfiguration
|
|
18
|
-
import com.theoplayer.android.api.source.ssai.YoSpaceDescription
|
|
19
21
|
import com.theoplayer.android.api.source.hls.HlsPlaybackConfiguration
|
|
20
22
|
import com.theoplayer.android.api.event.ads.AdIntegrationKind
|
|
21
23
|
import com.theoplayer.android.api.source.addescription.GoogleImaAdDescription
|
|
22
24
|
import com.theoplayer.android.api.player.track.texttrack.TextTrackKind
|
|
23
25
|
import com.theoplayer.android.api.source.metadata.ChromecastMetadataImage
|
|
24
|
-
import com.facebook.react.bridge.ReadableArray
|
|
25
26
|
import com.theoplayer.BuildConfig
|
|
26
27
|
import com.theoplayer.android.api.error.ErrorCode
|
|
27
28
|
import com.theoplayer.android.api.source.dash.DashPlaybackConfiguration
|
|
28
29
|
import com.theoplayer.drm.ContentProtectionAdapter
|
|
30
|
+
import com.theoplayer.util.BridgeUtils
|
|
29
31
|
import org.json.JSONArray
|
|
30
32
|
import org.json.JSONException
|
|
31
33
|
import org.json.JSONObject
|
|
@@ -38,6 +40,7 @@ private const val PROP_LIVE_OFFSET = "liveOffset"
|
|
|
38
40
|
private const val PROP_HLS_DATERANGE = "hlsDateRange"
|
|
39
41
|
private const val PROP_HLS_PLAYBACK_CONFIG = "hls"
|
|
40
42
|
private const val PROP_TIME_SERVER = "timeServer"
|
|
43
|
+
private const val PROP_DATA = "data"
|
|
41
44
|
private const val PROP_METADATA = "metadata"
|
|
42
45
|
private const val PROP_SSAI = "ssai"
|
|
43
46
|
private const val PROP_TYPE = "type"
|
|
@@ -69,10 +72,8 @@ class SourceAdapter {
|
|
|
69
72
|
if (source == null) {
|
|
70
73
|
return null
|
|
71
74
|
}
|
|
72
|
-
val hashmap = eliminateReadables(source)
|
|
73
75
|
try {
|
|
74
|
-
val
|
|
75
|
-
val jsonSourceObject = JSONObject(json)
|
|
76
|
+
val jsonSourceObject = JSONObject(gson.toJson(source.toHashMap()))
|
|
76
77
|
|
|
77
78
|
// typed sources
|
|
78
79
|
val typedSources = ArrayList<TypedSource>()
|
|
@@ -174,9 +175,6 @@ class SourceAdapter {
|
|
|
174
175
|
tsBuilder.type(SourceType.DASH)
|
|
175
176
|
}
|
|
176
177
|
}
|
|
177
|
-
SsaiIntegration.YOSPACE -> tsBuilder.ssai(
|
|
178
|
-
gson.fromJson(ssaiJson.toString(), YoSpaceDescription::class.java)
|
|
179
|
-
)
|
|
180
178
|
else -> throw THEOplayerException(
|
|
181
179
|
ErrorCode.AD_ERROR,
|
|
182
180
|
"$ERROR_UNSUPPORTED_SSAI_INTEGRATION: $ssaiIntegrationStr"
|
|
@@ -225,9 +223,8 @@ class SourceAdapter {
|
|
|
225
223
|
|
|
226
224
|
@Throws(THEOplayerException::class)
|
|
227
225
|
fun parseAdFromJS(map: ReadableMap): AdDescription? {
|
|
228
|
-
val hashmap = eliminateReadables(map)
|
|
229
226
|
return try {
|
|
230
|
-
val jsonAdDescription = JSONObject(gson.toJson(
|
|
227
|
+
val jsonAdDescription = JSONObject(gson.toJson(map.toHashMap()))
|
|
231
228
|
parseAdFromJS(jsonAdDescription)
|
|
232
229
|
} catch (e: JSONException) {
|
|
233
230
|
e.printStackTrace()
|
|
@@ -283,7 +280,7 @@ class SourceAdapter {
|
|
|
283
280
|
AdIntegrationKind.GOOGLE_IMA -> parseImaAdFromJS(
|
|
284
281
|
jsonAdDescription
|
|
285
282
|
)
|
|
286
|
-
AdIntegrationKind.DEFAULT
|
|
283
|
+
AdIntegrationKind.DEFAULT -> {
|
|
287
284
|
throw THEOplayerException(
|
|
288
285
|
ErrorCode.AD_ERROR,
|
|
289
286
|
"$ERROR_UNSUPPORTED_CSAI_INTEGRATION: $integrationKindStr"
|
|
@@ -386,33 +383,15 @@ class SourceAdapter {
|
|
|
386
383
|
return ChromecastMetadataImage(metadataImage.optString("src"), width, height)
|
|
387
384
|
}
|
|
388
385
|
|
|
389
|
-
|
|
390
|
-
val
|
|
391
|
-
val eliminatedHashMap = HashMap<String, Any>()
|
|
392
|
-
for (entry in hashMap.entries) {
|
|
393
|
-
var value = entry.value
|
|
394
|
-
if (value is ReadableMap) {
|
|
395
|
-
value = eliminateReadables(value)
|
|
396
|
-
} else if (value is ReadableArray) {
|
|
397
|
-
value = eliminateReadables(value)
|
|
398
|
-
}
|
|
399
|
-
eliminatedHashMap[entry.key] = value
|
|
400
|
-
}
|
|
401
|
-
return eliminatedHashMap
|
|
402
|
-
}
|
|
386
|
+
fun fromSourceDescription(source: SourceDescription): WritableMap {
|
|
387
|
+
val json = JSONObject(gson.toJson(source))
|
|
403
388
|
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
var value = o
|
|
409
|
-
if (value is ReadableMap) {
|
|
410
|
-
value = eliminateReadables(value)
|
|
411
|
-
} else if (value is ReadableArray) {
|
|
412
|
-
value = eliminateReadables(value)
|
|
413
|
-
}
|
|
414
|
-
eliminatedArrayList.add(value)
|
|
389
|
+
// Normalize metadata
|
|
390
|
+
// The player SDK adds an extra 'data' level within metadata: flatten.
|
|
391
|
+
json.optJSONObject(PROP_METADATA)?.optJSONObject(PROP_DATA)?.let { newMetadata ->
|
|
392
|
+
json.put(PROP_METADATA, newMetadata)
|
|
415
393
|
}
|
|
416
|
-
|
|
394
|
+
|
|
395
|
+
return BridgeUtils.fromJSONObjectToBridge(json)
|
|
417
396
|
}
|
|
418
397
|
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
package com.theoplayer.util
|
|
2
|
+
|
|
3
|
+
import com.facebook.react.bridge.Arguments
|
|
4
|
+
import com.facebook.react.bridge.WritableArray
|
|
5
|
+
import com.facebook.react.bridge.WritableMap
|
|
6
|
+
import org.json.JSONArray
|
|
7
|
+
import org.json.JSONException
|
|
8
|
+
import org.json.JSONObject
|
|
9
|
+
|
|
10
|
+
object BridgeUtils {
|
|
11
|
+
/**
|
|
12
|
+
* Convert a JSONObject to bridge data.
|
|
13
|
+
*/
|
|
14
|
+
fun fromJSONObjectToBridge(json: JSONObject): WritableMap {
|
|
15
|
+
return Arguments.createMap().apply {
|
|
16
|
+
try {
|
|
17
|
+
val iterator = json.keys()
|
|
18
|
+
while (iterator.hasNext()) {
|
|
19
|
+
val key = iterator.next()
|
|
20
|
+
when (val value = json.opt(key)) {
|
|
21
|
+
// null -> putNull(key)
|
|
22
|
+
is Boolean -> putBoolean(key, value)
|
|
23
|
+
is Int -> putInt(key, value)
|
|
24
|
+
is Double -> putDouble(key, value)
|
|
25
|
+
is String -> putString(key, value)
|
|
26
|
+
is JSONObject -> putMap(key, fromJSONObjectToBridge(value))
|
|
27
|
+
is JSONArray -> putArray(key, fromJSONArrayToBridge(value))
|
|
28
|
+
// Add other cases if needed for custom data types
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
} catch (e: JSONException) {
|
|
32
|
+
e.printStackTrace()
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Convert a JSONArray to bridge data.
|
|
39
|
+
*/
|
|
40
|
+
fun fromJSONArrayToBridge(jsonArray: JSONArray): WritableArray {
|
|
41
|
+
return Arguments.createArray().apply {
|
|
42
|
+
try {
|
|
43
|
+
for (i in 0 until jsonArray.length()) {
|
|
44
|
+
when (val value = jsonArray.opt(i)) {
|
|
45
|
+
// null -> writableArray.pushNull()
|
|
46
|
+
is Boolean -> pushBoolean(value)
|
|
47
|
+
is Int -> pushInt(value)
|
|
48
|
+
is Double -> pushDouble(value)
|
|
49
|
+
is String -> pushString(value)
|
|
50
|
+
is JSONObject -> pushMap(fromJSONObjectToBridge(value))
|
|
51
|
+
is JSONArray -> pushArray(fromJSONArrayToBridge(value))
|
|
52
|
+
// Add other cases if needed for custom data types
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
} catch (e: JSONException) {
|
|
56
|
+
e.printStackTrace()
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
@@ -226,18 +226,18 @@ class PayloadBuilder {
|
|
|
226
226
|
payload.putMap(EVENT_PROP_QUALITIES, TrackListAdapter.fromQuality(quality))
|
|
227
227
|
}
|
|
228
228
|
|
|
229
|
-
|
|
230
|
-
val payload = Arguments.createArray()
|
|
231
|
-
timeRanges?.forEach { timeRange ->
|
|
232
|
-
val range = Arguments.createMap()
|
|
233
|
-
range.putDouble(EVENT_PROP_START, 1e03 * timeRange.start)
|
|
234
|
-
range.putDouble(EVENT_PROP_END, 1e03 * timeRange.end)
|
|
235
|
-
payload.pushMap(range)
|
|
236
|
-
}
|
|
229
|
+
fun build(): WritableMap {
|
|
237
230
|
return payload
|
|
238
231
|
}
|
|
232
|
+
}
|
|
239
233
|
|
|
240
|
-
|
|
241
|
-
|
|
234
|
+
fun fromTimeRanges(timeRanges: TimeRanges?): WritableArray {
|
|
235
|
+
val payload = Arguments.createArray()
|
|
236
|
+
timeRanges?.forEach { timeRange ->
|
|
237
|
+
val range = Arguments.createMap()
|
|
238
|
+
range.putDouble(EVENT_PROP_START, 1e03 * timeRange.start)
|
|
239
|
+
range.putDouble(EVENT_PROP_END, 1e03 * timeRange.end)
|
|
240
|
+
payload.pushMap(range)
|
|
242
241
|
}
|
|
242
|
+
return payload
|
|
243
243
|
}
|
|
@@ -217,3 +217,25 @@ RCT_EXTERN_METHOD(airplayStart:(nonnull NSNumber *)node)
|
|
|
217
217
|
RCT_EXTERN_METHOD(airplayStop:(nonnull NSNumber *)node)
|
|
218
218
|
|
|
219
219
|
@end
|
|
220
|
+
|
|
221
|
+
// ----------------------------------------------------------------------------
|
|
222
|
+
// Cache Module
|
|
223
|
+
// ----------------------------------------------------------------------------
|
|
224
|
+
@interface RCT_EXTERN_REMAP_MODULE(CacheModule, THEOplayerRCTCacheAPI, RCTEventEmitter)
|
|
225
|
+
|
|
226
|
+
RCT_EXTERN_METHOD(getInitialState:(RCTPromiseResolveBlock)resolve
|
|
227
|
+
rejecter:(RCTPromiseRejectBlock)reject)
|
|
228
|
+
|
|
229
|
+
RCT_EXTERN_METHOD(createTask:(NSDictionary)src
|
|
230
|
+
params:(NSDictionary)params)
|
|
231
|
+
|
|
232
|
+
RCT_EXTERN_METHOD(startCachingTask:(nonnull NSString *)id)
|
|
233
|
+
|
|
234
|
+
RCT_EXTERN_METHOD(pauseCachingTask:(nonnull NSString *)id)
|
|
235
|
+
|
|
236
|
+
RCT_EXTERN_METHOD(removeCachingTask:(nonnull NSString *)id)
|
|
237
|
+
|
|
238
|
+
RCT_EXTERN_METHOD(renewLicense:(nonnull NSString *)id
|
|
239
|
+
drmConfig:(NSDictionary)drmConfig)
|
|
240
|
+
|
|
241
|
+
@end
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
let DEBUG = true
|
|
5
5
|
|
|
6
6
|
// Debug flag to monitor incoming Theoplayer events
|
|
7
|
-
let DEBUG_THEOPLAYER_EVENTS = DEBUG &&
|
|
7
|
+
let DEBUG_THEOPLAYER_EVENTS = DEBUG && false
|
|
8
8
|
|
|
9
9
|
// Debug flag to monitor eventhandler setup and breakdown
|
|
10
10
|
let DEBUG_EVENTHANDLER = DEBUG && false
|
|
@@ -38,3 +38,9 @@ let DEBUG_REMOTECOMMANDS = DEBUG && false
|
|
|
38
38
|
|
|
39
39
|
// Debug flag to monitor PIP Controls updates
|
|
40
40
|
let DEBUG_PIPCONTROLS = DEBUG && false
|
|
41
|
+
|
|
42
|
+
// Debug flag to monitor incoming cache events
|
|
43
|
+
let DEBUG_CACHE_EVENTS = DEBUG && true
|
|
44
|
+
|
|
45
|
+
// Debug flag to monitor cache API usage
|
|
46
|
+
let DEBUG_CACHE_API = DEBUG && true
|
|
@@ -156,34 +156,32 @@ public class THEOplayerRCTMainEventHandler {
|
|
|
156
156
|
//if DEBUG_THEOPLAYER_EVENTS { PrintUtils.printLog(logText: "[NATIVE] Received PROGRESS event from THEOplayer") }
|
|
157
157
|
if let wplayer = player,
|
|
158
158
|
let forwardedProgressEvent = self?.onNativeProgress {
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
})
|
|
179
|
-
forwardedProgressEvent(
|
|
180
|
-
[
|
|
181
|
-
"seekable":seekable,
|
|
182
|
-
"buffered":buffered
|
|
183
|
-
]
|
|
184
|
-
)
|
|
185
|
-
})
|
|
159
|
+
let seekableTimeRanges = wplayer.seekable
|
|
160
|
+
let bufferedTimeRanges = wplayer.buffered
|
|
161
|
+
var seekable: [[String:Double]] = []
|
|
162
|
+
seekableTimeRanges.forEach({ timeRange in
|
|
163
|
+
seekable.append(
|
|
164
|
+
[
|
|
165
|
+
"start": timeRange.start * 1000, // sec -> msec
|
|
166
|
+
"end": timeRange.end * 1000 // sec -> msec
|
|
167
|
+
]
|
|
168
|
+
)
|
|
169
|
+
})
|
|
170
|
+
var buffered: [[String:Double]] = []
|
|
171
|
+
bufferedTimeRanges.forEach({ timeRange in
|
|
172
|
+
buffered.append(
|
|
173
|
+
[
|
|
174
|
+
"start": timeRange.start * 1000, // sec -> msec
|
|
175
|
+
"end": timeRange.end * 1000 // sec -> msec
|
|
176
|
+
]
|
|
177
|
+
)
|
|
186
178
|
})
|
|
179
|
+
forwardedProgressEvent(
|
|
180
|
+
[
|
|
181
|
+
"seekable":seekable,
|
|
182
|
+
"buffered":buffered
|
|
183
|
+
]
|
|
184
|
+
)
|
|
187
185
|
}
|
|
188
186
|
}
|
|
189
187
|
if DEBUG_EVENTHANDLER { PrintUtils.printLog(logText: "[NATIVE] Progress listener attached to THEOplayer") }
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
// THEOplayerRCTSourceDescriptionBuilder.swift
|
|
2
|
+
|
|
3
|
+
import Foundation
|
|
4
|
+
import THEOplayerSDK
|
|
5
|
+
import UIKit
|
|
6
|
+
|
|
7
|
+
class THEOplayerRCTSourceDescriptionAggregator {
|
|
8
|
+
class func aggregateCacheTaskSourceDescription(sourceDescription: SourceDescription) -> [String:Any]? {
|
|
9
|
+
do {
|
|
10
|
+
let jsonEncoder = JSONEncoder()
|
|
11
|
+
let data = try jsonEncoder.encode(sourceDescription)
|
|
12
|
+
if let result = try? JSONSerialization.jsonObject(with: data, options: []) as? [String:Any] {
|
|
13
|
+
return THEOplayerRCTSourceDescriptionAggregator.sanitiseSourceDescriptionMetadata(input: result)
|
|
14
|
+
}
|
|
15
|
+
} catch {
|
|
16
|
+
if DEBUG { PrintUtils.printLog(logText: "[NATIVE] Could not aggregate sourceDescription for caching task: \(error.localizedDescription)")}
|
|
17
|
+
return nil
|
|
18
|
+
}
|
|
19
|
+
return nil
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
private class func sanitiseSourceDescriptionMetadata(input: [String:Any]) -> [String:Any] {
|
|
23
|
+
var output: [String:Any] = input
|
|
24
|
+
if let metadata = output[SD_PROP_METADATA] as? [String:Any],
|
|
25
|
+
let metadataKeys = metadata[SD_PROP_METADATAKEYS] as? [String:Any] {
|
|
26
|
+
var newMetadata: [String:Any] = [:]
|
|
27
|
+
// keep all but lower level metadataKeys
|
|
28
|
+
for (key, value) in metadata {
|
|
29
|
+
if (key != SD_PROP_METADATAKEYS) {
|
|
30
|
+
newMetadata[key] = value
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
// now add metadataKeys at metadata level
|
|
34
|
+
for (key, value) in metadataKeys {
|
|
35
|
+
newMetadata[key] = value
|
|
36
|
+
}
|
|
37
|
+
output[SD_PROP_METADATA] = newMetadata
|
|
38
|
+
}
|
|
39
|
+
return output
|
|
40
|
+
}
|
|
41
|
+
}
|