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