react-native-theoplayer 1.6.1 → 1.7.1
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 +76 -33
- 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 +273 -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
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { Buffer } from 'buffer';
|
|
2
|
+
|
|
3
|
+
// from object
|
|
4
|
+
export function fromObjectToString(obj: { [key: string]: any }): string {
|
|
5
|
+
return JSON.stringify(obj);
|
|
6
|
+
}
|
|
7
|
+
export function fromObjectToBase64String(obj: { [key: string]: any }): string {
|
|
8
|
+
return fromStringToBase64String(fromObjectToString(obj));
|
|
9
|
+
}
|
|
10
|
+
export function fromObjectToUint8Array(obj: { [key: string]: any }): Uint8Array {
|
|
11
|
+
return fromStringToUint8Array(fromObjectToString(obj));
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
// from string
|
|
15
|
+
export function fromStringToBase64String(str: string): string {
|
|
16
|
+
return Buffer.from(str, 'utf8').toString('base64');
|
|
17
|
+
}
|
|
18
|
+
export function fromStringToUint8Array(str: string): Uint8Array {
|
|
19
|
+
return Buffer.from(str, 'utf8');
|
|
20
|
+
}
|
|
21
|
+
export function fromStringToObject(str: string): { [key: string]: any } {
|
|
22
|
+
return JSON.parse(str);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
// from base64 string
|
|
26
|
+
export function fromBase64StringToUint8Array(str: string): Uint8Array {
|
|
27
|
+
return Buffer.from(str, 'base64');
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
// from uint8Array
|
|
31
|
+
export function fromUint8ArrayToBase64String(array: Uint8Array): string {
|
|
32
|
+
return Buffer.from(array).toString('base64');
|
|
33
|
+
}
|
|
34
|
+
export function fromUint8ArrayToString(array: Uint8Array): string {
|
|
35
|
+
return Buffer.from(array).toString('utf8');
|
|
36
|
+
}
|
|
37
|
+
export function fromUint8ArrayToObject(array: Uint8Array): { [key: string]: any } {
|
|
38
|
+
return fromStringToObject(fromUint8ArrayToString(array));
|
|
39
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './TypeUtils';
|
package/src/index.tsx
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React, { PureComponent } from 'react';
|
|
2
|
-
import { findNodeHandle, StyleSheet, requireNativeComponent, View, UIManager, Platform, NativeSyntheticEvent } from 'react-native';
|
|
2
|
+
import { findNodeHandle, StyleSheet, requireNativeComponent, View, UIManager, Platform, NativeSyntheticEvent, HostComponent } from 'react-native';
|
|
3
3
|
import type {
|
|
4
4
|
DurationChangeEvent,
|
|
5
5
|
ErrorEvent,
|
|
@@ -13,10 +13,14 @@ import type {
|
|
|
13
13
|
SegmentNotFoundEvent,
|
|
14
14
|
TextTrackListEvent,
|
|
15
15
|
TextTrackEvent,
|
|
16
|
+
AdEvent,
|
|
17
|
+
AdsAPI,
|
|
16
18
|
} from 'react-native-theoplayer';
|
|
17
19
|
|
|
18
20
|
import styles from './THEOplayerView.style';
|
|
19
21
|
import type { SourceDescription } from 'react-native-theoplayer';
|
|
22
|
+
import { THEOplayerNativeAdsAPI } from './ads/THEOplayerNativeAdsAPI';
|
|
23
|
+
import { decodeNanInf } from './utils/TypeUtils';
|
|
20
24
|
|
|
21
25
|
interface THEOplayerRCTViewProps extends THEOplayerViewProps {
|
|
22
26
|
ref: React.RefObject<THEOplayerViewNativeComponent>;
|
|
@@ -41,6 +45,7 @@ interface THEOplayerRCTViewProps extends THEOplayerViewProps {
|
|
|
41
45
|
onNativeSegmentNotFound: (event: NativeSyntheticEvent<SegmentNotFoundEvent>) => void;
|
|
42
46
|
onNativeTextTrackListEvent: (event: NativeSyntheticEvent<TextTrackListEvent>) => void;
|
|
43
47
|
onNativeTextTrackEvent: (event: NativeSyntheticEvent<TextTrackEvent>) => void;
|
|
48
|
+
onNativeAdEvent: (event: NativeSyntheticEvent<AdEvent>) => void;
|
|
44
49
|
onNativeFullscreenPlayerWillPresent?: () => void;
|
|
45
50
|
onNativeFullscreenPlayerDidPresent?: () => void;
|
|
46
51
|
onNativeFullscreenPlayerWillDismiss?: () => void;
|
|
@@ -52,12 +57,13 @@ interface THEOplayerRCTViewState {
|
|
|
52
57
|
error?: PlayerError;
|
|
53
58
|
}
|
|
54
59
|
|
|
55
|
-
interface THEOplayerViewNativeComponent extends THEOplayerViewComponent {
|
|
60
|
+
interface THEOplayerViewNativeComponent extends THEOplayerViewComponent, HostComponent<THEOplayerViewProps> {
|
|
56
61
|
setNativeProps: (props: Partial<THEOplayerRCTViewProps>) => void;
|
|
57
62
|
}
|
|
58
63
|
|
|
59
|
-
export class THEOplayerView extends PureComponent<THEOplayerViewProps, THEOplayerRCTViewState> {
|
|
64
|
+
export class THEOplayerView extends PureComponent<THEOplayerViewProps, THEOplayerRCTViewState> implements THEOplayerViewComponent {
|
|
60
65
|
private readonly _root: React.RefObject<THEOplayerViewNativeComponent>;
|
|
66
|
+
private readonly _adsApi: THEOplayerNativeAdsAPI;
|
|
61
67
|
|
|
62
68
|
private static initialState: THEOplayerRCTViewState = {
|
|
63
69
|
isBuffering: false,
|
|
@@ -68,6 +74,7 @@ export class THEOplayerView extends PureComponent<THEOplayerViewProps, THEOplaye
|
|
|
68
74
|
super(props);
|
|
69
75
|
this._root = React.createRef();
|
|
70
76
|
this.state = THEOplayerView.initialState;
|
|
77
|
+
this._adsApi = new THEOplayerNativeAdsAPI(this);
|
|
71
78
|
}
|
|
72
79
|
|
|
73
80
|
componentWillUnmount() {
|
|
@@ -79,7 +86,7 @@ export class THEOplayerView extends PureComponent<THEOplayerViewProps, THEOplaye
|
|
|
79
86
|
|
|
80
87
|
private destroyTheoPlayer() {
|
|
81
88
|
const node = findNodeHandle(this._root.current);
|
|
82
|
-
const command = (UIManager as {[index: string]: any})['THEOplayerRCTView'].Commands.destroy;
|
|
89
|
+
const command = (UIManager as { [index: string]: any })['THEOplayerRCTView'].Commands.destroy;
|
|
83
90
|
const params: any[] = [];
|
|
84
91
|
UIManager.dispatchViewManagerCommand(node, command, params);
|
|
85
92
|
}
|
|
@@ -91,6 +98,14 @@ export class THEOplayerView extends PureComponent<THEOplayerViewProps, THEOplaye
|
|
|
91
98
|
this.setNativeProps({ seek: time });
|
|
92
99
|
}
|
|
93
100
|
|
|
101
|
+
public get nativeHandle(): number | null {
|
|
102
|
+
return findNodeHandle(this._root.current);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
public get ads(): AdsAPI {
|
|
106
|
+
return this._adsApi;
|
|
107
|
+
}
|
|
108
|
+
|
|
94
109
|
private reset() {
|
|
95
110
|
this.setState(THEOplayerView.initialState);
|
|
96
111
|
}
|
|
@@ -140,7 +155,10 @@ export class THEOplayerView extends PureComponent<THEOplayerViewProps, THEOplaye
|
|
|
140
155
|
|
|
141
156
|
private _onLoadedMetadata = (event: NativeSyntheticEvent<LoadedMetadataEvent>) => {
|
|
142
157
|
if (this.props.onLoadedMetadata) {
|
|
143
|
-
this.props.onLoadedMetadata(
|
|
158
|
+
this.props.onLoadedMetadata({
|
|
159
|
+
...event.nativeEvent,
|
|
160
|
+
duration: decodeNanInf(event.nativeEvent.duration),
|
|
161
|
+
});
|
|
144
162
|
}
|
|
145
163
|
};
|
|
146
164
|
|
|
@@ -169,6 +187,9 @@ export class THEOplayerView extends PureComponent<THEOplayerViewProps, THEOplaye
|
|
|
169
187
|
};
|
|
170
188
|
|
|
171
189
|
private _onPlaying = () => {
|
|
190
|
+
// potentially notify change in buffering state
|
|
191
|
+
this.maybeChangeBufferingState(false);
|
|
192
|
+
|
|
172
193
|
if (this.props.onPlaying) {
|
|
173
194
|
this.props.onPlaying();
|
|
174
195
|
}
|
|
@@ -215,7 +236,9 @@ export class THEOplayerView extends PureComponent<THEOplayerViewProps, THEOplaye
|
|
|
215
236
|
|
|
216
237
|
private _onDurationChange = (event: NativeSyntheticEvent<DurationChangeEvent>) => {
|
|
217
238
|
if (this.props.onDurationChange) {
|
|
218
|
-
this.props.onDurationChange(
|
|
239
|
+
this.props.onDurationChange({
|
|
240
|
+
duration: decodeNanInf(event.nativeEvent.duration),
|
|
241
|
+
});
|
|
219
242
|
}
|
|
220
243
|
};
|
|
221
244
|
|
|
@@ -237,6 +260,12 @@ export class THEOplayerView extends PureComponent<THEOplayerViewProps, THEOplaye
|
|
|
237
260
|
}
|
|
238
261
|
};
|
|
239
262
|
|
|
263
|
+
private _onAdEvent = (event: NativeSyntheticEvent<AdEvent>) => {
|
|
264
|
+
if (this.props.onAdEvent) {
|
|
265
|
+
this.props.onAdEvent(event.nativeEvent);
|
|
266
|
+
}
|
|
267
|
+
};
|
|
268
|
+
|
|
240
269
|
private _onFullscreenPlayerWillPresent = () => {
|
|
241
270
|
if (this.props.onFullscreenPlayerWillPresent) {
|
|
242
271
|
this.props.onFullscreenPlayerWillPresent();
|
|
@@ -261,9 +290,20 @@ export class THEOplayerView extends PureComponent<THEOplayerViewProps, THEOplaye
|
|
|
261
290
|
}
|
|
262
291
|
};
|
|
263
292
|
|
|
264
|
-
|
|
265
|
-
const
|
|
293
|
+
private buildWrapperProps(): THEOplayerViewProps {
|
|
294
|
+
const { targetVideoQuality } = this.props;
|
|
295
|
+
return Object.assign(
|
|
296
|
+
{},
|
|
297
|
+
{
|
|
298
|
+
...this.props,
|
|
299
|
+
// Always pass an array for targetVideoQuality.
|
|
300
|
+
targetVideoQuality: !targetVideoQuality ? [] : Array.isArray(targetVideoQuality) ? targetVideoQuality : [targetVideoQuality],
|
|
301
|
+
},
|
|
302
|
+
);
|
|
303
|
+
}
|
|
266
304
|
|
|
305
|
+
public render(): JSX.Element {
|
|
306
|
+
const wrapperProps = this.buildWrapperProps();
|
|
267
307
|
return (
|
|
268
308
|
<View style={[styles.base, wrapperProps.style]}>
|
|
269
309
|
<THEOplayerRCTView
|
|
@@ -287,6 +327,7 @@ export class THEOplayerView extends PureComponent<THEOplayerViewProps, THEOplaye
|
|
|
287
327
|
onNativeSegmentNotFound={this._onSegmentNotFound}
|
|
288
328
|
onNativeTextTrackListEvent={this._onTextTrackListEvent}
|
|
289
329
|
onNativeTextTrackEvent={this._onTextTrackEvent}
|
|
330
|
+
onNativeAdEvent={this._onAdEvent}
|
|
290
331
|
onNativeFullscreenPlayerWillPresent={this._onFullscreenPlayerWillPresent}
|
|
291
332
|
onNativeFullscreenPlayerDidPresent={this._onFullscreenPlayerDidPresent}
|
|
292
333
|
onNativeFullscreenPlayerWillDismiss={this._onFullscreenPlayerWillDismiss}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React, { PureComponent } from 'react';
|
|
2
2
|
|
|
3
|
-
import type { PlayerError, TextTrack, THEOplayerViewProps, TimeRange } from 'react-native-theoplayer';
|
|
4
|
-
import { TextTrackEventType, TrackListEventType } from 'react-native-theoplayer';
|
|
3
|
+
import type { AdEvent, AdsAPI, PlayerError, TextTrack, THEOplayerViewProps, TimeRange } from 'react-native-theoplayer';
|
|
4
|
+
import { AdEventNames, TextTrackEventType, THEOplayerViewComponent, TrackListEventType } from 'react-native-theoplayer';
|
|
5
5
|
import type { Event, TextTrackCue as NativeTextTrackCue } from 'theoplayer';
|
|
6
6
|
|
|
7
7
|
import type {
|
|
@@ -13,15 +13,17 @@ import type {
|
|
|
13
13
|
TextTrack as NativeTextTrack,
|
|
14
14
|
} from 'theoplayer';
|
|
15
15
|
import * as THEOplayer from 'theoplayer';
|
|
16
|
-
import { fromNativeCue, fromNativeMediaTrack, fromNativeTextTrack } from './web/TrackUtils';
|
|
16
|
+
import { findNativeQualitiesByUid, fromNativeCue, fromNativeMediaTrack, fromNativeTextTrack } from './web/TrackUtils';
|
|
17
|
+
import { THEOplayerWebAdsAPI } from './ads/THEOplayerWebAdsAPI';
|
|
17
18
|
|
|
18
19
|
interface THEOplayerRCTViewState {
|
|
19
20
|
isBuffering: boolean;
|
|
20
21
|
error?: PlayerError;
|
|
21
22
|
}
|
|
22
23
|
|
|
23
|
-
export class THEOplayerView extends PureComponent<THEOplayerViewProps, THEOplayerRCTViewState> {
|
|
24
|
+
export class THEOplayerView extends PureComponent<THEOplayerViewProps, THEOplayerRCTViewState> implements THEOplayerViewComponent {
|
|
24
25
|
private _player: THEOplayer.ChromelessPlayer | null = null;
|
|
26
|
+
private _adsApi: THEOplayerWebAdsAPI;
|
|
25
27
|
|
|
26
28
|
private static initialState: THEOplayerRCTViewState = {
|
|
27
29
|
isBuffering: false,
|
|
@@ -31,10 +33,11 @@ export class THEOplayerView extends PureComponent<THEOplayerViewProps, THEOplaye
|
|
|
31
33
|
constructor(props: THEOplayerViewProps) {
|
|
32
34
|
super(props);
|
|
33
35
|
this.state = THEOplayerView.initialState;
|
|
36
|
+
this._adsApi = new THEOplayerWebAdsAPI(this);
|
|
34
37
|
}
|
|
35
38
|
|
|
36
39
|
componentDidMount() {
|
|
37
|
-
const { config, source } = this.props;
|
|
40
|
+
const { config, source, abrConfig } = this.props;
|
|
38
41
|
const element = document.querySelector('.theoplayer-container') as HTMLElement;
|
|
39
42
|
if (config?.chromeless === true || config?.chromeless === undefined) {
|
|
40
43
|
this._player = new THEOplayer.ChromelessPlayer(element, {
|
|
@@ -50,6 +53,8 @@ export class THEOplayerView extends PureComponent<THEOplayerViewProps, THEOplaye
|
|
|
50
53
|
},
|
|
51
54
|
});
|
|
52
55
|
}
|
|
56
|
+
|
|
57
|
+
Object.assign(this._player.abr, abrConfig);
|
|
53
58
|
this._player.prepareWithUserAction();
|
|
54
59
|
this._player.source = source;
|
|
55
60
|
this.addEventListeners();
|
|
@@ -70,6 +75,14 @@ export class THEOplayerView extends PureComponent<THEOplayerViewProps, THEOplaye
|
|
|
70
75
|
}
|
|
71
76
|
}
|
|
72
77
|
|
|
78
|
+
public get ads(): AdsAPI {
|
|
79
|
+
return this._adsApi;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
public get nativePlayer(): THEOplayer.ChromelessPlayer | null {
|
|
83
|
+
return this._player;
|
|
84
|
+
}
|
|
85
|
+
|
|
73
86
|
private reset() {
|
|
74
87
|
this.setState(THEOplayerView.initialState);
|
|
75
88
|
}
|
|
@@ -79,12 +92,14 @@ export class THEOplayerView extends PureComponent<THEOplayerViewProps, THEOplaye
|
|
|
79
92
|
return;
|
|
80
93
|
}
|
|
81
94
|
// track property changes
|
|
82
|
-
const { paused, volume, selectedTextTrack, selectedAudioTrack, selectedVideoTrack, source, muted, playbackRate, fullscreen } =
|
|
95
|
+
const { paused, volume, selectedTextTrack, selectedAudioTrack, selectedVideoTrack, targetVideoQuality, source, muted, playbackRate, fullscreen } =
|
|
96
|
+
this.props;
|
|
83
97
|
const {
|
|
84
98
|
paused: wasPaused,
|
|
85
99
|
selectedTextTrack: prevSelectedTextTrack,
|
|
86
100
|
selectedAudioTrack: prevSelectedAudioTrack,
|
|
87
101
|
selectedVideoTrack: prevSelectedVideoTrack,
|
|
102
|
+
targetVideoQuality: prevTargetVideoQuality,
|
|
88
103
|
source: prevSource,
|
|
89
104
|
muted: wasMuted,
|
|
90
105
|
playbackRate: prevPlaybackRate,
|
|
@@ -141,6 +156,12 @@ export class THEOplayerView extends PureComponent<THEOplayerViewProps, THEOplaye
|
|
|
141
156
|
videoTrack.enabled = videoTrack.uid === selectedVideoTrack;
|
|
142
157
|
});
|
|
143
158
|
}
|
|
159
|
+
if (targetVideoQuality != prevTargetVideoQuality) {
|
|
160
|
+
const videoTrack = this._player.videoTracks.find((videoTrack: NativeMediaTrack) => videoTrack.uid === selectedVideoTrack);
|
|
161
|
+
if (videoTrack) {
|
|
162
|
+
videoTrack.targetQuality = findNativeQualitiesByUid(videoTrack, targetVideoQuality);
|
|
163
|
+
}
|
|
164
|
+
}
|
|
144
165
|
}
|
|
145
166
|
|
|
146
167
|
private maybeChangeBufferingState(isBuffering: boolean) {
|
|
@@ -227,7 +248,7 @@ export class THEOplayerView extends PureComponent<THEOplayerViewProps, THEOplaye
|
|
|
227
248
|
textTracks: player.textTracks.map((textTrack: NativeTextTrack) => fromNativeTextTrack(textTrack)),
|
|
228
249
|
audioTracks: player.audioTracks.map((audioTrack: NativeMediaTrack) => fromNativeMediaTrack(audioTrack)),
|
|
229
250
|
videoTracks: player.videoTracks.map((videoTrack: NativeMediaTrack) => fromNativeMediaTrack(videoTrack)),
|
|
230
|
-
duration:
|
|
251
|
+
duration: 1e3 * player.duration,
|
|
231
252
|
selectedTextTrack: player.textTracks.find((track: NativeTextTrack) => track.mode === 'showing')?.uid,
|
|
232
253
|
selectedVideoTrack: player.videoTracks.find((track: NativeMediaTrack) => track.enabled)?.uid,
|
|
233
254
|
selectedAudioTrack: player.audioTracks.find((track: NativeMediaTrack) => track.enabled)?.uid,
|
|
@@ -274,6 +295,9 @@ export class THEOplayerView extends PureComponent<THEOplayerViewProps, THEOplaye
|
|
|
274
295
|
});
|
|
275
296
|
|
|
276
297
|
player.addEventListener('playing', () => {
|
|
298
|
+
// potentially notify change in buffering state
|
|
299
|
+
this.maybeChangeBufferingState(false);
|
|
300
|
+
|
|
277
301
|
const { onPlaying } = this.props;
|
|
278
302
|
if (onPlaying) {
|
|
279
303
|
onPlaying();
|
|
@@ -384,6 +408,12 @@ export class THEOplayerView extends PureComponent<THEOplayerViewProps, THEOplaye
|
|
|
384
408
|
});
|
|
385
409
|
}
|
|
386
410
|
});
|
|
411
|
+
player.ads?.addEventListener(AdEventNames, (event) => {
|
|
412
|
+
const { onAdEvent } = this.props;
|
|
413
|
+
if (onAdEvent) {
|
|
414
|
+
onAdEvent(event as AdEvent);
|
|
415
|
+
}
|
|
416
|
+
});
|
|
387
417
|
}
|
|
388
418
|
|
|
389
419
|
public render(): JSX.Element {
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import type { AdBreak, AdsAPI } from "react-native-theoplayer";
|
|
2
|
+
import { NativeModules } from "react-native";
|
|
3
|
+
import type { AdDescription } from "react-native-theoplayer";
|
|
4
|
+
import type { Ad } from "react-native-theoplayer";
|
|
5
|
+
import type { THEOplayerView } from "react-native-theoplayer";
|
|
6
|
+
import type { GoogleDAI } from "react-native-theoplayer";
|
|
7
|
+
import { THEOplayerNativeGoogleDAI } from "./THEOplayerNativeGoogleDAI";
|
|
8
|
+
|
|
9
|
+
export class THEOplayerNativeAdsAPI implements AdsAPI {
|
|
10
|
+
|
|
11
|
+
private readonly _dai: GoogleDAI;
|
|
12
|
+
|
|
13
|
+
constructor(private _player: THEOplayerView) {
|
|
14
|
+
this._dai = new THEOplayerNativeGoogleDAI(this._player);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
playing(): Promise<boolean> {
|
|
18
|
+
return NativeModules.AdsModule.playing(this._player.nativeHandle);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
skip(): void {
|
|
22
|
+
NativeModules.AdsModule.skip(this._player.nativeHandle);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
currentAdBreak(): Promise<AdBreak> {
|
|
26
|
+
return NativeModules.AdsModule.currentAdBreak(this._player.nativeHandle);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
currentAds(): Promise<Ad[]> {
|
|
30
|
+
return NativeModules.AdsModule.currentAds(this._player.nativeHandle);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
scheduledAdBreaks(): Promise<AdBreak[]> {
|
|
34
|
+
return NativeModules.AdsModule.scheduledAdBreaks(this._player.nativeHandle);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
schedule(ad: AdDescription): void {
|
|
38
|
+
NativeModules.AdsModule.schedule(this._player.nativeHandle, ad);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
get dai(): GoogleDAI | undefined {
|
|
42
|
+
return this._dai;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { GoogleDAI } from 'react-native-theoplayer';
|
|
2
|
+
import { NativeModules } from 'react-native';
|
|
3
|
+
import type { THEOplayerView } from 'react-native-theoplayer';
|
|
4
|
+
|
|
5
|
+
export class THEOplayerNativeGoogleDAI implements GoogleDAI {
|
|
6
|
+
public constructor(private readonly _player: THEOplayerView) {}
|
|
7
|
+
|
|
8
|
+
get snapback(): Promise<boolean> {
|
|
9
|
+
return NativeModules.AdsModule.daiSnapback(this._player.nativeHandle);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
setSnapback(enabled: boolean): void {
|
|
13
|
+
NativeModules.AdsModule.daiSetSnapback(this._player.nativeHandle, enabled);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
contentTimeForStreamTime(time: number): Promise<number> {
|
|
17
|
+
return NativeModules.AdsModule.daiContentTimeForStreamTime(this._player.nativeHandle, time);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
streamTimeForContentTime(time: number): Promise<number> {
|
|
21
|
+
return NativeModules.AdsModule.daiStreamTimeForContentTime(this._player.nativeHandle, time);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import type { Ad, AdDescription, AdBreak, AdsAPI } from "react-native-theoplayer";
|
|
2
|
+
import type { THEOplayerView } from "../THEOplayerView.web";
|
|
3
|
+
import type { GoogleDAI } from "react-native-theoplayer";
|
|
4
|
+
import { THEOplayerWebGoogleDAI } from "./THEOplayerWebGoogleDAI";
|
|
5
|
+
|
|
6
|
+
export class THEOplayerWebAdsAPI implements AdsAPI {
|
|
7
|
+
|
|
8
|
+
private _dai: GoogleDAI | undefined;
|
|
9
|
+
|
|
10
|
+
constructor(private readonly _player: THEOplayerView) {
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
currentAdBreak(): Promise<AdBreak> {
|
|
14
|
+
const adBreak = this._player.nativePlayer?.ads?.currentAdBreak;
|
|
15
|
+
return adBreak ? Promise.resolve(adBreak) : Promise.reject<AdBreak>();
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
currentAds(): Promise<Ad[]> {
|
|
19
|
+
const ads = this._player.nativePlayer?.ads?.currentAds;
|
|
20
|
+
return ads ? Promise.resolve(ads) : Promise.reject<Ad[]>();
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
playing(): Promise<boolean> {
|
|
24
|
+
return Promise.resolve<boolean>(this._player.nativePlayer?.ads?.playing || false);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
schedule(ad: AdDescription): void {
|
|
28
|
+
this._player.nativePlayer?.ads?.schedule(ad);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
scheduledAdBreaks(): Promise<AdBreak[]> {
|
|
32
|
+
const adBreaks = this._player.nativePlayer?.ads?.scheduledAdBreaks;
|
|
33
|
+
return adBreaks ? Promise.resolve(adBreaks) : Promise.reject<AdBreak[]>();
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
skip(): void {
|
|
37
|
+
this._player.nativePlayer?.ads?.skip();
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
get dai(): GoogleDAI | undefined {
|
|
41
|
+
if (!this._dai) {
|
|
42
|
+
const nativeDai = this._player.nativePlayer?.ads?.dai;
|
|
43
|
+
if (!nativeDai) {
|
|
44
|
+
// Not native DAI available
|
|
45
|
+
return undefined;
|
|
46
|
+
}
|
|
47
|
+
this._dai = new THEOplayerWebGoogleDAI(nativeDai);
|
|
48
|
+
}
|
|
49
|
+
return this._dai;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { GoogleDAI } from 'react-native-theoplayer';
|
|
2
|
+
import type { GoogleDAI as NativeGoogleDAI } from 'theoplayer';
|
|
3
|
+
|
|
4
|
+
export class THEOplayerWebGoogleDAI implements GoogleDAI {
|
|
5
|
+
public constructor(private readonly _googleDAI: NativeGoogleDAI) {}
|
|
6
|
+
|
|
7
|
+
get snapback(): Promise<boolean> {
|
|
8
|
+
return Promise.resolve(this._googleDAI.snapback);
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
setSnapback(enabled: boolean): void {
|
|
12
|
+
this._googleDAI.snapback = enabled;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
contentTimeForStreamTime(time: number): Promise<number> {
|
|
16
|
+
return Promise.resolve(this._googleDAI.contentTimeForStreamTime(time));
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
streamTimeForContentTime(time: number): Promise<number> {
|
|
20
|
+
return Promise.resolve(this._googleDAI.streamTimeForContentTime(time));
|
|
21
|
+
}
|
|
22
|
+
}
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
import type { CertificateRequest, ContentProtectionAPI, DRMConfiguration, LicenseRequest } from 'react-native-theoplayer';
|
|
2
|
+
import type { KeySystemId } from 'react-native-theoplayer';
|
|
3
|
+
import type { ContentProtectionIntegrationFactory } from 'react-native-theoplayer';
|
|
4
|
+
import { NativeEventEmitter, NativeModules } from 'react-native';
|
|
5
|
+
import type { ContentProtectionIntegration } from 'react-native-theoplayer';
|
|
6
|
+
import type { NativeContentProtectionEvent } from './NativeContentProtectionEvent';
|
|
7
|
+
import { fromNativeLicenseRequest, NativeLicenseRequest, toNativeLicenseRequest } from './NativeLicenseRequest';
|
|
8
|
+
import { fromNativeLicenseResponse, NativeLicenseResponse, toNativeLicenseResponseResult } from './NativeLicenseResponse';
|
|
9
|
+
import { fromNativeCertificateRequest, NativeCertificateRequest, toNativeCertificateRequest } from './NativeCertificateRequest';
|
|
10
|
+
import { fromNativeCertificateResponse, NativeCertificateResponse, toNativeCertificateResponseResult } from './NativeCertificateResponse';
|
|
11
|
+
import { isBufferSource } from '../utils/TypeUtils';
|
|
12
|
+
|
|
13
|
+
interface WrappedContentProtectionIntegrationFactory {
|
|
14
|
+
integrationId: string;
|
|
15
|
+
keySystemId: string;
|
|
16
|
+
integrationFactory: ContentProtectionIntegrationFactory;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
interface WrappedContentProtectionIntegration {
|
|
20
|
+
integrationId: string;
|
|
21
|
+
keySystemId: string;
|
|
22
|
+
integration: ContentProtectionIntegration;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
interface BuildEvent extends NativeContentProtectionEvent {
|
|
26
|
+
drmConfig: DRMConfiguration;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
interface ExtractFaiplayContentIdEvent extends NativeContentProtectionEvent {
|
|
30
|
+
fairplaySkdUrl: string;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export class NativeContentProtectionRegistry implements ContentProtectionAPI {
|
|
34
|
+
private emitter: NativeEventEmitter;
|
|
35
|
+
private registeredFactories: WrappedContentProtectionIntegrationFactory[] = [];
|
|
36
|
+
private currentIntegration: WrappedContentProtectionIntegration | undefined = undefined;
|
|
37
|
+
|
|
38
|
+
constructor() {
|
|
39
|
+
this.emitter = new NativeEventEmitter(NativeModules.ContentProtectionModule);
|
|
40
|
+
this.emitter.addListener('onBuildIntegration', this.onBuildIntegrationRequest);
|
|
41
|
+
this.emitter.addListener('onCertificateRequest', this.onCertificateRequest);
|
|
42
|
+
this.emitter.addListener('onCertificateResponse', this.onCertificateResponse);
|
|
43
|
+
this.emitter.addListener('onLicenseRequest', this.onLicenseRequest);
|
|
44
|
+
this.emitter.addListener('onLicenseResponse', this.onLicenseResponse);
|
|
45
|
+
this.emitter.addListener('onExtractFairplayContentId', this.onExtractFairplayContentId);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
registerContentProtectionIntegration(integrationId: string, keySystemId: KeySystemId, integrationFactory: ContentProtectionIntegrationFactory) {
|
|
49
|
+
this.registeredFactories.push({
|
|
50
|
+
integrationId,
|
|
51
|
+
keySystemId,
|
|
52
|
+
integrationFactory,
|
|
53
|
+
});
|
|
54
|
+
NativeModules.ContentProtectionModule.registerContentProtectionIntegration(integrationId, keySystemId);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
private getFactory(integrationId: string, keySystemId: string): ContentProtectionIntegrationFactory | undefined {
|
|
58
|
+
return this.registeredFactories.find((init) => init.integrationId === integrationId && init.keySystemId === keySystemId)?.integrationFactory;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
private getIntegration(integrationId: string, keySystemId: string): ContentProtectionIntegration | undefined {
|
|
62
|
+
return this.currentIntegration?.integrationId === integrationId && this.currentIntegration?.keySystemId === keySystemId
|
|
63
|
+
? this.currentIntegration?.integration
|
|
64
|
+
: undefined;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
private onBuildIntegrationRequest = (event: BuildEvent) => {
|
|
68
|
+
const { requestId, integrationId, keySystemId, drmConfig } = event;
|
|
69
|
+
console.log('ContentProtectionModule', `onBuildIntegrationRequest ${integrationId} ${keySystemId}`);
|
|
70
|
+
const factory = this.getFactory(integrationId, keySystemId);
|
|
71
|
+
if (factory) {
|
|
72
|
+
this.currentIntegration = {
|
|
73
|
+
integrationId,
|
|
74
|
+
keySystemId,
|
|
75
|
+
integration: factory.build(drmConfig),
|
|
76
|
+
};
|
|
77
|
+
NativeModules.ContentProtectionModule.onBuildProcessed({ requestId, resultString: 'success' });
|
|
78
|
+
} else {
|
|
79
|
+
NativeModules.ContentProtectionModule.onBuildProcessed({
|
|
80
|
+
requestId,
|
|
81
|
+
resultString: 'failed',
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
private onCertificateRequest = async (request: NativeCertificateRequest) => {
|
|
87
|
+
const { requestId, integrationId, keySystemId } = request;
|
|
88
|
+
console.log('ContentProtectionModule', `onCertificateRequest ${integrationId} ${keySystemId}`);
|
|
89
|
+
const integration = this.getIntegration(integrationId, keySystemId);
|
|
90
|
+
if (integration?.onCertificateRequest) {
|
|
91
|
+
const result = await integration.onCertificateRequest(fromNativeCertificateRequest(request));
|
|
92
|
+
// TODO: we also want to support ArrayBufferView results
|
|
93
|
+
if (isBufferSource(result)) {
|
|
94
|
+
const nativeResponse = toNativeCertificateResponseResult(requestId, integrationId, keySystemId, result as ArrayBuffer);
|
|
95
|
+
NativeModules.ContentProtectionModule.onCertificateRequestProcessedAsCertificate(nativeResponse);
|
|
96
|
+
} else if (result as CertificateRequest) {
|
|
97
|
+
const modifiedNativeRequest = toNativeCertificateRequest(requestId, integrationId, keySystemId, result as CertificateRequest);
|
|
98
|
+
NativeModules.ContentProtectionModule.onCertificateRequestProcessedAsRequest(modifiedNativeRequest);
|
|
99
|
+
}
|
|
100
|
+
} else {
|
|
101
|
+
NativeModules.ContentProtectionModule.onCertificateRequestProcessedAsRequest(request);
|
|
102
|
+
}
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
private onCertificateResponse = async (response: NativeCertificateResponse) => {
|
|
106
|
+
const { requestId, integrationId, keySystemId } = response;
|
|
107
|
+
console.log('ContentProtectionModule', `onCertificateResponse ${integrationId} ${keySystemId}`);
|
|
108
|
+
const integration = this.getIntegration(integrationId, keySystemId);
|
|
109
|
+
if (integration?.onCertificateResponse) {
|
|
110
|
+
const responseResult = await integration.onCertificateResponse(fromNativeCertificateResponse(response));
|
|
111
|
+
// TODO: we also want to support ArrayBufferView results
|
|
112
|
+
const modifiedNativeResponse = toNativeCertificateResponseResult(requestId, integrationId, keySystemId, responseResult as ArrayBuffer);
|
|
113
|
+
NativeModules.ContentProtectionModule.onCertificateResponseProcessed(modifiedNativeResponse);
|
|
114
|
+
} else {
|
|
115
|
+
NativeModules.ContentProtectionModule.onCertificateResponseProcessed(response);
|
|
116
|
+
}
|
|
117
|
+
};
|
|
118
|
+
|
|
119
|
+
private onLicenseRequest = async (request: NativeLicenseRequest) => {
|
|
120
|
+
const { requestId, integrationId, keySystemId } = request;
|
|
121
|
+
console.log('ContentProtectionModule', `onLicenseRequest ${integrationId} ${keySystemId}`);
|
|
122
|
+
const integration = this.getIntegration(integrationId, keySystemId);
|
|
123
|
+
// Optionally let the custom integration modify the request.
|
|
124
|
+
if (integration?.onLicenseRequest) {
|
|
125
|
+
const result = await integration.onLicenseRequest(fromNativeLicenseRequest(request));
|
|
126
|
+
// TODO: we also want to support ArrayBufferView results
|
|
127
|
+
if (isBufferSource(result)) {
|
|
128
|
+
const nativeResponse = toNativeLicenseResponseResult(requestId, integrationId, keySystemId, result as ArrayBuffer);
|
|
129
|
+
NativeModules.ContentProtectionModule.onLicenseRequestProcessedAsLicense(nativeResponse);
|
|
130
|
+
} else if (result as LicenseRequest) {
|
|
131
|
+
const modifiedNativeRequest = toNativeLicenseRequest(requestId, integrationId, keySystemId, result as LicenseRequest);
|
|
132
|
+
NativeModules.ContentProtectionModule.onLicenseRequestProcessedAsRequest(modifiedNativeRequest);
|
|
133
|
+
}
|
|
134
|
+
} else {
|
|
135
|
+
NativeModules.ContentProtectionModule.onLicenseRequestProcessedAsRequest(request);
|
|
136
|
+
}
|
|
137
|
+
};
|
|
138
|
+
|
|
139
|
+
private onLicenseResponse = async (response: NativeLicenseResponse) => {
|
|
140
|
+
const { requestId, integrationId, keySystemId } = response;
|
|
141
|
+
console.log('ContentProtectionModule', `onLicenseResponse ${integrationId} ${keySystemId}`);
|
|
142
|
+
const integration = this.getIntegration(integrationId, keySystemId);
|
|
143
|
+
if (integration?.onLicenseResponse) {
|
|
144
|
+
const responseResult = await integration.onLicenseResponse(fromNativeLicenseResponse(response));
|
|
145
|
+
// TODO: we also want to support ArrayBufferView results
|
|
146
|
+
const modifiedNativeResponse = toNativeLicenseResponseResult(requestId, integrationId, keySystemId, responseResult as ArrayBuffer);
|
|
147
|
+
NativeModules.ContentProtectionModule.onLicenseResponseProcessed(modifiedNativeResponse);
|
|
148
|
+
} else {
|
|
149
|
+
NativeModules.ContentProtectionModule.onLicenseResponseProcessed(response);
|
|
150
|
+
}
|
|
151
|
+
};
|
|
152
|
+
|
|
153
|
+
private onExtractFairplayContentId = async (event: ExtractFaiplayContentIdEvent) => {
|
|
154
|
+
const { integrationId, keySystemId, fairplaySkdUrl, requestId } = event;
|
|
155
|
+
console.log('ContentProtectionModule', `onExtractFairplayContentId ${integrationId} ${keySystemId}`);
|
|
156
|
+
const integration = this.getIntegration(integrationId, keySystemId);
|
|
157
|
+
if (integration?.extractFairplayContentId) {
|
|
158
|
+
const contentId = await integration.extractFairplayContentId(fairplaySkdUrl);
|
|
159
|
+
NativeModules.ContentProtectionModule.onExtractFairplayContentIdProcessed({
|
|
160
|
+
requestId,
|
|
161
|
+
contentId,
|
|
162
|
+
});
|
|
163
|
+
} else {
|
|
164
|
+
const contentId = fairplaySkdUrl;
|
|
165
|
+
NativeModules.ContentProtectionModule.onExtractFairplayContentIdProcessed({
|
|
166
|
+
requestId,
|
|
167
|
+
contentId,
|
|
168
|
+
});
|
|
169
|
+
}
|
|
170
|
+
};
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
export const ContentProtectionRegistry = new NativeContentProtectionRegistry();
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { ContentProtectionAPI, ContentProtectionIntegrationFactory, KeySystemId } from 'react-native-theoplayer';
|
|
2
|
+
import { registerContentProtectionIntegration } from 'theoplayer';
|
|
3
|
+
|
|
4
|
+
export class WebContentProtectionRegistry implements ContentProtectionAPI {
|
|
5
|
+
registerContentProtectionIntegration(integrationId: string, keySystem: KeySystemId, integrationFactory: ContentProtectionIntegrationFactory): void {
|
|
6
|
+
registerContentProtectionIntegration(integrationId, keySystem, integrationFactory);
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export const ContentProtectionRegistry = new WebContentProtectionRegistry();
|