react-native-theoplayer 1.7.1 → 1.8.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 +2 -0
- package/android/src/main/java/com/theoplayer/PlayerConfigAdapter.kt +115 -0
- package/android/src/main/java/com/theoplayer/PlayerEventEmitter.kt +648 -0
- package/android/src/main/java/com/theoplayer/ReactTHEOplayerPackage.kt +23 -0
- package/android/src/main/java/com/theoplayer/ReactTHEOplayerView.kt +446 -0
- package/android/src/main/java/com/theoplayer/ReactTHEOplayerViewManager.kt +117 -0
- package/android/src/main/java/com/theoplayer/{TimeUpdateRate.java → TimeUpdateRate.kt} +2 -2
- package/android/src/main/java/com/theoplayer/ads/AdAdapter.kt +161 -0
- package/android/src/main/java/com/theoplayer/ads/AdEventAdapter.kt +90 -0
- package/android/src/main/java/com/theoplayer/ads/AdsModule.kt +140 -0
- package/android/src/main/java/com/theoplayer/cast/CastEventAdapter.kt +81 -0
- package/android/src/main/java/com/theoplayer/cast/CastModule.kt +75 -0
- package/android/src/main/java/com/theoplayer/drm/ContentProtectionAdapter.kt +2 -2
- package/android/src/main/java/com/theoplayer/drm/ContentProtectionModule.kt +1 -2
- package/android/src/main/java/com/theoplayer/drm/ProxyContentProtectionIntegration.kt +1 -2
- package/android/src/main/java/com/theoplayer/drm/ProxyContentProtectionIntegrationFactory.kt +3 -5
- package/android/src/main/java/com/theoplayer/source/SourceAdapter.kt +402 -0
- package/android/src/main/java/com/theoplayer/track/MediaTrackEventType.kt +6 -0
- package/android/src/main/java/com/theoplayer/track/MediaTrackType.kt +6 -0
- package/android/src/main/java/com/theoplayer/track/QualityListAdapter.kt +43 -0
- package/android/src/main/java/com/theoplayer/track/QualityListFilter.kt +28 -0
- package/android/src/main/java/com/theoplayer/track/TextTrackCueEventType.kt +10 -0
- package/android/src/main/java/com/theoplayer/track/TrackEventType.kt +7 -0
- package/android/src/main/java/com/theoplayer/track/TrackListAdapter.kt +219 -0
- package/android/src/main/java/com/theoplayer/util/ViewResolver.kt +19 -0
- package/ios/THEOplayerRCTAdAggregator.swift +15 -6
- package/ios/THEOplayerRCTAdsAPI.swift +39 -40
- package/ios/THEOplayerRCTBridge.m +54 -1
- package/ios/THEOplayerRCTCastAPI.swift +275 -0
- package/ios/THEOplayerRCTDebug.swift +3 -0
- package/ios/THEOplayerRCTSourceDescriptionBuilder.swift +91 -19
- package/ios/THEOplayerRCTTrackEventTypes.swift +17 -0
- package/ios/{THEOplayerRCTMetadataAggregator.swift → THEOplayerRCTTrackMetadataAggregator.swift} +69 -55
- package/ios/THEOplayerRCTView.swift +126 -22
- package/ios/THEOplayerRCTViewAdEventHandler.swift +7 -5
- package/ios/THEOplayerRCTViewCastEventHandler.swift +124 -0
- package/ios/THEOplayerRCTViewMainEventHandler.swift +1 -1
- package/ios/THEOplayerRCTViewMediaTrackEventHandler.swift +185 -0
- package/ios/THEOplayerRCTViewTextTrackEventHandler.swift +30 -13
- package/ios/custom/Frameworks/ios/put_custom_ios_xcframework_here.txt +1 -1
- package/ios/custom/Frameworks/tvos/put_custom_tvos_xcframework_here.txt +2 -0
- package/ios/custom/react-native-theoplayer_custom.podspec +46 -0
- package/lib/commonjs/api/THEOplayerView.js.map +1 -1
- package/lib/commonjs/api/barrel.js +21 -8
- package/lib/commonjs/api/barrel.js.map +1 -1
- package/lib/commonjs/api/cast/Airplay.js +6 -0
- package/lib/commonjs/api/cast/Airplay.js.map +1 -0
- package/lib/commonjs/api/cast/CastAPI.js +6 -0
- package/lib/commonjs/api/cast/CastAPI.js.map +1 -0
- package/lib/commonjs/api/cast/CastConfiguration.js +2 -0
- package/lib/commonjs/api/cast/CastConfiguration.js.map +1 -0
- package/lib/commonjs/api/cast/CastState.js +2 -0
- package/lib/commonjs/api/cast/CastState.js.map +1 -0
- package/lib/commonjs/api/cast/Chromecast.js +6 -0
- package/lib/commonjs/api/cast/Chromecast.js.map +1 -0
- package/lib/commonjs/api/cast/barrel.js +71 -0
- package/lib/commonjs/api/cast/barrel.js.map +1 -0
- package/lib/commonjs/api/config/PlayerConfiguration.js.map +1 -1
- package/lib/commonjs/api/error/ChromecastError.js +2 -0
- package/lib/commonjs/api/error/ChromecastError.js.map +1 -0
- package/lib/commonjs/api/error/barrel.js +13 -0
- package/lib/commonjs/api/error/barrel.js.map +1 -1
- package/lib/commonjs/api/event/CastEvent.js +21 -0
- package/lib/commonjs/api/event/CastEvent.js.map +1 -0
- package/lib/commonjs/api/event/TrackEvent.js +17 -1
- package/lib/commonjs/api/event/TrackEvent.js.map +1 -1
- package/lib/commonjs/api/event/barrel.js +25 -12
- 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/barrel.js +13 -0
- package/lib/commonjs/api/source/barrel.js.map +1 -1
- package/lib/commonjs/api/source/metadata/MetadataDescription.js +2 -0
- package/lib/commonjs/api/source/metadata/MetadataDescription.js.map +1 -0
- package/lib/commonjs/api/source/metadata/barrel.js +19 -0
- package/lib/commonjs/api/source/metadata/barrel.js.map +1 -0
- package/lib/commonjs/internal/THEOplayerView.js +30 -0
- package/lib/commonjs/internal/THEOplayerView.js.map +1 -1
- package/lib/commonjs/internal/THEOplayerView.web.js +80 -20
- package/lib/commonjs/internal/THEOplayerView.web.js.map +1 -1
- package/lib/commonjs/internal/cast/THEOplayerNativeAirplay.js +34 -0
- package/lib/commonjs/internal/cast/THEOplayerNativeAirplay.js.map +1 -0
- package/lib/commonjs/internal/cast/THEOplayerNativeCastApi.js +46 -0
- package/lib/commonjs/internal/cast/THEOplayerNativeCastApi.js.map +1 -0
- package/lib/commonjs/internal/cast/THEOplayerNativeChromecast.js +42 -0
- package/lib/commonjs/internal/cast/THEOplayerNativeChromecast.js.map +1 -0
- package/lib/commonjs/internal/cast/THEOplayerWebCastApi.js +31 -0
- package/lib/commonjs/internal/cast/THEOplayerWebCastApi.js.map +1 -0
- package/lib/commonjs/internal/web/stub/CastButtonStub.js +16 -0
- package/lib/commonjs/internal/web/stub/CastButtonStub.js.map +1 -0
- package/lib/module/api/THEOplayerView.js.map +1 -1
- package/lib/module/api/barrel.js +1 -0
- package/lib/module/api/barrel.js.map +1 -1
- package/lib/module/api/cast/Airplay.js +2 -0
- package/lib/module/api/cast/Airplay.js.map +1 -0
- package/lib/module/api/cast/CastAPI.js +2 -0
- package/lib/module/api/cast/CastAPI.js.map +1 -0
- package/lib/module/api/cast/CastConfiguration.js +2 -0
- package/lib/module/api/cast/CastConfiguration.js.map +1 -0
- package/lib/module/api/cast/CastState.js +2 -0
- package/lib/module/api/cast/CastState.js.map +1 -0
- package/lib/module/api/cast/Chromecast.js +2 -0
- package/lib/module/api/cast/Chromecast.js.map +1 -0
- package/lib/module/api/cast/barrel.js +6 -0
- package/lib/module/api/cast/barrel.js.map +1 -0
- package/lib/module/api/config/PlayerConfiguration.js.map +1 -1
- package/lib/module/api/error/ChromecastError.js +2 -0
- package/lib/module/api/error/ChromecastError.js.map +1 -0
- package/lib/module/api/error/barrel.js +1 -0
- package/lib/module/api/error/barrel.js.map +1 -1
- package/lib/module/api/event/CastEvent.js +14 -0
- package/lib/module/api/event/CastEvent.js.map +1 -0
- package/lib/module/api/event/TrackEvent.js +14 -0
- package/lib/module/api/event/TrackEvent.js.map +1 -1
- package/lib/module/api/event/barrel.js +2 -1
- 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/barrel.js +1 -0
- package/lib/module/api/source/barrel.js.map +1 -1
- package/lib/module/api/source/metadata/MetadataDescription.js +2 -0
- package/lib/module/api/source/metadata/MetadataDescription.js.map +1 -0
- package/lib/module/api/source/metadata/barrel.js +2 -0
- package/lib/module/api/source/metadata/barrel.js.map +1 -0
- package/lib/module/internal/THEOplayerView.js +29 -0
- package/lib/module/internal/THEOplayerView.js.map +1 -1
- package/lib/module/internal/THEOplayerView.web.js +80 -21
- package/lib/module/internal/THEOplayerView.web.js.map +1 -1
- package/lib/module/internal/cast/THEOplayerNativeAirplay.js +24 -0
- package/lib/module/internal/cast/THEOplayerNativeAirplay.js.map +1 -0
- package/lib/module/internal/cast/THEOplayerNativeCastApi.js +34 -0
- package/lib/module/internal/cast/THEOplayerNativeCastApi.js.map +1 -0
- package/lib/module/internal/cast/THEOplayerNativeChromecast.js +32 -0
- package/lib/module/internal/cast/THEOplayerNativeChromecast.js.map +1 -0
- package/lib/module/internal/cast/THEOplayerWebCastApi.js +22 -0
- package/lib/module/internal/cast/THEOplayerWebCastApi.js.map +1 -0
- package/lib/module/internal/web/stub/CastButtonStub.js +6 -0
- package/lib/module/internal/web/stub/CastButtonStub.js.map +1 -0
- package/lib/typescript/lib/commonjs/api/cast/Airplay.d.ts +1 -0
- package/lib/typescript/lib/commonjs/api/cast/CastAPI.d.ts +1 -0
- package/lib/typescript/lib/commonjs/api/cast/CastConfiguration.d.ts +0 -0
- package/lib/typescript/lib/commonjs/api/cast/CastState.d.ts +0 -0
- package/lib/typescript/lib/commonjs/api/cast/Chromecast.d.ts +1 -0
- package/lib/typescript/lib/commonjs/api/cast/barrel.d.ts +1 -0
- package/lib/typescript/lib/commonjs/api/error/ChromecastError.d.ts +0 -0
- package/lib/typescript/lib/commonjs/api/event/CastEvent.d.ts +2 -0
- package/lib/typescript/lib/commonjs/api/event/TrackEvent.d.ts +4 -0
- package/lib/typescript/lib/commonjs/api/source/metadata/MetadataDescription.d.ts +0 -0
- package/lib/typescript/lib/commonjs/api/source/metadata/barrel.d.ts +1 -0
- package/lib/typescript/lib/commonjs/internal/THEOplayerView.d.ts +3 -0
- package/lib/typescript/lib/commonjs/internal/THEOplayerView.web.d.ts +3 -0
- package/lib/typescript/lib/commonjs/internal/cast/THEOplayerNativeAirplay.d.ts +9 -0
- package/lib/typescript/lib/commonjs/internal/cast/THEOplayerNativeCastApi.d.ts +12 -0
- package/lib/typescript/lib/commonjs/internal/cast/THEOplayerNativeChromecast.d.ts +11 -0
- package/lib/typescript/lib/commonjs/internal/cast/THEOplayerWebCastApi.d.ts +8 -0
- package/lib/typescript/lib/commonjs/internal/web/stub/CastButtonStub.d.ts +2 -0
- package/lib/typescript/lib/module/api/barrel.d.ts +1 -0
- package/lib/typescript/lib/module/api/cast/Airplay.d.ts +1 -0
- package/lib/typescript/lib/module/api/cast/CastAPI.d.ts +1 -0
- package/lib/typescript/lib/module/api/cast/CastConfiguration.d.ts +0 -0
- package/lib/typescript/lib/module/api/cast/CastState.d.ts +0 -0
- package/lib/typescript/lib/module/api/cast/Chromecast.d.ts +1 -0
- package/lib/typescript/lib/module/api/cast/barrel.d.ts +3 -0
- package/lib/typescript/lib/module/api/error/ChromecastError.d.ts +0 -0
- package/lib/typescript/lib/module/api/event/CastEvent.d.ts +1 -0
- package/lib/typescript/lib/module/api/event/TrackEvent.d.ts +2 -0
- package/lib/typescript/lib/module/api/event/barrel.d.ts +2 -1
- package/lib/typescript/lib/module/api/source/barrel.d.ts +1 -0
- package/lib/typescript/lib/module/api/source/metadata/MetadataDescription.d.ts +0 -0
- package/lib/typescript/lib/module/api/source/metadata/barrel.d.ts +1 -0
- package/lib/typescript/lib/module/internal/THEOplayerView.d.ts +3 -0
- package/lib/typescript/lib/module/internal/THEOplayerView.web.d.ts +3 -0
- package/lib/typescript/lib/module/internal/cast/THEOplayerNativeAirplay.d.ts +8 -0
- package/lib/typescript/lib/module/internal/cast/THEOplayerNativeCastApi.d.ts +11 -0
- package/lib/typescript/lib/module/internal/cast/THEOplayerNativeChromecast.d.ts +10 -0
- package/lib/typescript/lib/module/internal/cast/THEOplayerWebCastApi.d.ts +7 -0
- package/lib/typescript/lib/module/internal/web/stub/CastButtonStub.d.ts +2 -0
- package/lib/typescript/src/api/THEOplayerView.d.ts +21 -3
- package/lib/typescript/src/api/barrel.d.ts +1 -0
- package/lib/typescript/src/api/cast/Airplay.d.ts +27 -0
- package/lib/typescript/src/api/cast/CastAPI.d.ts +25 -0
- package/lib/typescript/src/api/cast/CastConfiguration.d.ts +41 -0
- package/lib/typescript/src/api/cast/CastState.d.ts +10 -0
- package/lib/typescript/src/api/cast/Chromecast.d.ts +39 -0
- package/lib/typescript/src/api/cast/barrel.d.ts +5 -0
- package/lib/typescript/src/api/config/PlayerConfiguration.d.ts +6 -1
- package/lib/typescript/src/api/error/ChromecastError.d.ts +34 -0
- package/lib/typescript/src/api/error/barrel.d.ts +1 -0
- package/lib/typescript/src/api/event/CastEvent.d.ts +21 -0
- package/lib/typescript/src/api/event/TrackEvent.d.ts +49 -3
- package/lib/typescript/src/api/event/barrel.d.ts +2 -1
- package/lib/typescript/src/api/source/SourceDescription.d.ts +7 -0
- package/lib/typescript/src/api/source/barrel.d.ts +1 -0
- package/lib/typescript/src/api/source/metadata/MetadataDescription.d.ts +12 -0
- package/lib/typescript/src/api/source/metadata/barrel.d.ts +1 -0
- package/lib/typescript/src/internal/THEOplayerView.d.ts +9 -1
- package/lib/typescript/src/internal/THEOplayerView.web.d.ts +7 -2
- package/lib/typescript/src/internal/cast/THEOplayerNativeAirplay.d.ts +9 -0
- package/lib/typescript/src/internal/cast/THEOplayerNativeCastApi.d.ts +10 -0
- package/lib/typescript/src/internal/cast/THEOplayerNativeChromecast.d.ts +11 -0
- package/lib/typescript/src/internal/cast/THEOplayerWebCastApi.d.ts +9 -0
- package/lib/typescript/src/internal/web/stub/CastButtonStub.d.ts +3 -0
- package/package.json +2 -2
- package/react-native-theoplayer.podspec +2 -2
- package/src/api/THEOplayerView.ts +25 -3
- package/src/api/barrel.ts +1 -0
- package/src/api/cast/Airplay.ts +31 -0
- package/src/api/cast/CastAPI.ts +30 -0
- package/src/api/cast/CastConfiguration.ts +44 -0
- package/src/api/cast/CastState.ts +10 -0
- package/src/api/cast/Chromecast.ts +45 -0
- package/src/api/cast/barrel.ts +5 -0
- package/src/api/config/PlayerConfiguration.ts +7 -1
- package/src/api/error/ChromecastError.ts +46 -0
- package/src/api/error/barrel.ts +1 -0
- package/src/api/event/CastEvent.ts +45 -0
- package/src/api/event/TrackEvent.ts +58 -2
- package/src/api/event/barrel.ts +2 -1
- package/src/api/source/SourceDescription.ts +8 -0
- package/src/api/source/barrel.ts +1 -0
- package/src/api/source/metadata/MetadataDescription.ts +13 -0
- package/src/api/source/metadata/barrel.ts +1 -0
- package/src/internal/THEOplayerView.tsx +35 -0
- package/src/internal/THEOplayerView.web.tsx +87 -19
- package/src/internal/cast/THEOplayerNativeAirplay.ts +22 -0
- package/src/internal/cast/THEOplayerNativeCastApi.ts +28 -0
- package/src/internal/cast/THEOplayerNativeChromecast.ts +30 -0
- package/src/internal/cast/THEOplayerWebCastApi.ts +21 -0
- package/src/internal/web/stub/CastButtonStub.tsx +7 -0
- package/android/src/main/java/com/theoplayer/PlayerConfigHelper.java +0 -70
- package/android/src/main/java/com/theoplayer/ReactTHEOplayerPackage.java +0 -32
- package/android/src/main/java/com/theoplayer/ReactTHEOplayerView.java +0 -525
- package/android/src/main/java/com/theoplayer/ReactTHEOplayerViewManager.java +0 -127
- package/android/src/main/java/com/theoplayer/SourceHelper.java +0 -362
- package/android/src/main/java/com/theoplayer/VideoEventEmitter.java +0 -442
- package/android/src/main/java/com/theoplayer/ads/AdEventAdapter.java +0 -92
- package/android/src/main/java/com/theoplayer/ads/AdInfo.java +0 -168
- package/android/src/main/java/com/theoplayer/ads/AdsModule.java +0 -152
- package/android/src/main/java/com/theoplayer/track/QualityListAdapter.java +0 -54
- package/android/src/main/java/com/theoplayer/track/QualityListFilter.java +0 -40
- package/android/src/main/java/com/theoplayer/track/TextTrackCueEventType.java +0 -11
- package/android/src/main/java/com/theoplayer/track/TrackEventType.java +0 -11
- package/android/src/main/java/com/theoplayer/track/TrackListInfo.java +0 -212
- package/android/src/main/java/com/theoplayer/util/ViewResolver.java +0 -42
- package/ios/custom/react-native-theoplayer_custom_ios.podspec +0 -36
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
package com.theoplayer.ads
|
|
2
|
+
|
|
3
|
+
import com.facebook.react.bridge.Arguments
|
|
4
|
+
import com.facebook.react.bridge.WritableMap
|
|
5
|
+
import com.facebook.react.bridge.WritableArray
|
|
6
|
+
import com.theoplayer.android.api.ads.Ad
|
|
7
|
+
import com.theoplayer.android.api.ads.AdBreak
|
|
8
|
+
import com.theoplayer.android.api.ads.CompanionAd
|
|
9
|
+
import com.theoplayer.android.api.ads.GoogleImaAd
|
|
10
|
+
import java.lang.Exception
|
|
11
|
+
|
|
12
|
+
private const val PROP_AD_SYSTEM = "adSystem"
|
|
13
|
+
private const val PROP_AD_INTEGRATION = "integration"
|
|
14
|
+
private const val PROP_AD_TYPE = "type"
|
|
15
|
+
private const val PROP_AD_ID = "id"
|
|
16
|
+
private const val PROP_AD_BREAK = "adBreak"
|
|
17
|
+
private const val PROP_AD_COMPANIONS = "companions"
|
|
18
|
+
private const val PROP_AD_SKIPOFFSET = "skipOffset"
|
|
19
|
+
private const val PROP_AD_CREATIVE_ID = "creativeId"
|
|
20
|
+
private const val PROP_AD_TRAFFICKING_PARAMETERS = "traffickingParametersString"
|
|
21
|
+
private const val PROP_AD_BITRATE = "bitrate"
|
|
22
|
+
private const val PROP_AD_UNIVERSAL_AD_IDS = "universalAdIds"
|
|
23
|
+
private const val PROP_AD_TITLE = "title"
|
|
24
|
+
private const val PROP_AD_DURATION = "duration"
|
|
25
|
+
private const val PROP_AD_WRAPPER_AD_IDS = "wrapperAdIds"
|
|
26
|
+
private const val PROP_AD_WRAPPER_AD_SYSTEMS = "wrapperAdSystems"
|
|
27
|
+
private const val PROP_AD_WRAPPER_CREATIVE_IDS = "wrapperCreativeIds"
|
|
28
|
+
private const val PROP_AD_WIDTH = "width"
|
|
29
|
+
private const val PROP_AD_HEIGHT = "height"
|
|
30
|
+
private const val PROP_AD_CONTENT_TYPE = "contentType"
|
|
31
|
+
private const val PROP_ADBREAK_INTEGRATION = "integration"
|
|
32
|
+
private const val PROP_ADBREAK_MAXDURATION = "maxDuration"
|
|
33
|
+
private const val PROP_ADBREAK_TIMEOFFSET = "timeOffset"
|
|
34
|
+
private const val PROP_ADBREAK_MAXREMAININGDURATION = "maxRemainingDuration"
|
|
35
|
+
private const val PROP_ADBREAK_ADS = "ads"
|
|
36
|
+
private const val PROP_COMPANION_ADSLOTID = "adSlotId"
|
|
37
|
+
private const val PROP_COMPANION_ALTTEXT = "altText"
|
|
38
|
+
private const val PROP_COMPANION_CLICKTHROUGH = "clickThrough"
|
|
39
|
+
private const val PROP_COMPANION_WIDTH = "width"
|
|
40
|
+
private const val PROP_COMPANION_HEIGHT = "height"
|
|
41
|
+
private const val PROP_COMPANION_RESOURCEURI = "resourceURI"
|
|
42
|
+
private const val PROP_UNIVERSAL_AD_ID_REGISTRY = "adIdRegistry"
|
|
43
|
+
private const val PROP_UNIVERSAL_AD_ID_VALUE = "adIdValue"
|
|
44
|
+
|
|
45
|
+
object AdAdapter {
|
|
46
|
+
fun fromAd(ad: Ad): WritableMap {
|
|
47
|
+
return fromAd(ad, true)
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
fun fromAds(ads: List<Ad>): WritableArray {
|
|
51
|
+
val payload = Arguments.createArray()
|
|
52
|
+
for (ad in ads) {
|
|
53
|
+
payload.pushMap(fromAd(ad, true))
|
|
54
|
+
}
|
|
55
|
+
return payload
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
private fun fromAd(ad: Ad, includeAdBreak: Boolean): WritableMap {
|
|
59
|
+
val adPayload = Arguments.createMap()
|
|
60
|
+
adPayload.putString(
|
|
61
|
+
PROP_AD_INTEGRATION, if (ad.integration != null) ad.integration!!
|
|
62
|
+
.type else ""
|
|
63
|
+
)
|
|
64
|
+
adPayload.putString(PROP_AD_TYPE, ad.type)
|
|
65
|
+
adPayload.putString(PROP_AD_ID, ad.id)
|
|
66
|
+
val adBreak = ad.adBreak
|
|
67
|
+
if (includeAdBreak && adBreak != null) {
|
|
68
|
+
adPayload.putMap(PROP_AD_BREAK, fromAdBreak(adBreak))
|
|
69
|
+
}
|
|
70
|
+
adPayload.putArray(PROP_AD_COMPANIONS, fromCompanions(ad.companions))
|
|
71
|
+
adPayload.putInt(PROP_AD_SKIPOFFSET, ad.skipOffset)
|
|
72
|
+
if (ad is GoogleImaAd) {
|
|
73
|
+
adPayload.putString(PROP_AD_SYSTEM, ad.adSystem)
|
|
74
|
+
adPayload.putString(PROP_AD_CREATIVE_ID, ad.creativeId)
|
|
75
|
+
adPayload.putString(PROP_AD_TRAFFICKING_PARAMETERS, ad.traffickingParameters)
|
|
76
|
+
adPayload.putInt(PROP_AD_BITRATE, ad.vastMediaBitrate)
|
|
77
|
+
try {
|
|
78
|
+
adPayload.putString(PROP_AD_TITLE, ad.imaAd.title)
|
|
79
|
+
adPayload.putInt(PROP_AD_DURATION, (1e3 * ad.imaAd.duration).toInt())
|
|
80
|
+
adPayload.putDouble(PROP_AD_WIDTH, ad.imaAd.vastMediaWidth.toDouble())
|
|
81
|
+
adPayload.putDouble(PROP_AD_HEIGHT, ad.imaAd.vastMediaHeight.toDouble())
|
|
82
|
+
adPayload.putString(PROP_AD_CONTENT_TYPE, ad.imaAd.contentType)
|
|
83
|
+
} catch (ignore: Exception) {
|
|
84
|
+
// googleImaAd.getImaAd() is not known yet
|
|
85
|
+
}
|
|
86
|
+
val universalAdIdsPayload = Arguments.createArray()
|
|
87
|
+
for (universalAdId in ad.universalAdIds) {
|
|
88
|
+
val idPayload = Arguments.createMap()
|
|
89
|
+
idPayload.putString(
|
|
90
|
+
PROP_UNIVERSAL_AD_ID_REGISTRY,
|
|
91
|
+
universalAdId.universalAdIdRegistry
|
|
92
|
+
)
|
|
93
|
+
idPayload.putString(PROP_UNIVERSAL_AD_ID_VALUE, universalAdId.universalAdIdValue)
|
|
94
|
+
universalAdIdsPayload.pushMap(idPayload)
|
|
95
|
+
}
|
|
96
|
+
adPayload.putArray(PROP_AD_UNIVERSAL_AD_IDS, universalAdIdsPayload)
|
|
97
|
+
val wrapperAdIdsPayload = Arguments.createArray()
|
|
98
|
+
for (wrapperAdId in ad.wrapperAdIds) {
|
|
99
|
+
wrapperAdIdsPayload.pushString(wrapperAdId)
|
|
100
|
+
}
|
|
101
|
+
adPayload.putArray(PROP_AD_WRAPPER_AD_IDS, wrapperAdIdsPayload)
|
|
102
|
+
val wrapperAdSystemsPayload = Arguments.createArray()
|
|
103
|
+
for (wrapperAdSystem in ad.wrapperAdSystems) {
|
|
104
|
+
wrapperAdSystemsPayload.pushString(wrapperAdSystem)
|
|
105
|
+
}
|
|
106
|
+
adPayload.putArray(PROP_AD_WRAPPER_AD_SYSTEMS, wrapperAdSystemsPayload)
|
|
107
|
+
val wrapperCreativeIdsPayload = Arguments.createArray()
|
|
108
|
+
for (wrapperCreativeId in ad.wrapperCreativeIds) {
|
|
109
|
+
wrapperCreativeIdsPayload.pushString(wrapperCreativeId)
|
|
110
|
+
}
|
|
111
|
+
adPayload.putArray(PROP_AD_WRAPPER_CREATIVE_IDS, wrapperCreativeIdsPayload)
|
|
112
|
+
}
|
|
113
|
+
return adPayload
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
fun fromAdBreak(adbreak: AdBreak?): WritableMap {
|
|
117
|
+
val adbreakPayload = Arguments.createMap()
|
|
118
|
+
if (adbreak == null) {
|
|
119
|
+
return adbreakPayload
|
|
120
|
+
}
|
|
121
|
+
adbreakPayload.putString(PROP_ADBREAK_INTEGRATION, adbreak.integration.type)
|
|
122
|
+
adbreakPayload.putInt(PROP_ADBREAK_MAXDURATION, (1e3 * adbreak.maxDuration).toInt())
|
|
123
|
+
adbreakPayload.putInt(PROP_ADBREAK_TIMEOFFSET, (1e3 * adbreak.timeOffset).toInt())
|
|
124
|
+
adbreakPayload.putInt(
|
|
125
|
+
PROP_ADBREAK_MAXREMAININGDURATION,
|
|
126
|
+
(1e3 * adbreak.maxRemainingDuration).toInt()
|
|
127
|
+
)
|
|
128
|
+
val adsPayload = Arguments.createArray()
|
|
129
|
+
for (ad in adbreak.ads) {
|
|
130
|
+
// Some ads in the ad break are possibly not loaded yet.
|
|
131
|
+
if (ad != null) {
|
|
132
|
+
adsPayload.pushMap(fromAd(ad, false))
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
adbreakPayload.putArray(PROP_ADBREAK_ADS, adsPayload)
|
|
136
|
+
return adbreakPayload
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
fun fromAdBreaks(adbreaks: List<AdBreak?>): WritableArray {
|
|
140
|
+
val payload = Arguments.createArray()
|
|
141
|
+
for (adbreak in adbreaks) {
|
|
142
|
+
payload.pushMap(fromAdBreak(adbreak))
|
|
143
|
+
}
|
|
144
|
+
return payload
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
private fun fromCompanions(companions: List<CompanionAd>): WritableArray {
|
|
148
|
+
val companionsPayload = Arguments.createArray()
|
|
149
|
+
for (companionAd in companions) {
|
|
150
|
+
val adPayload = Arguments.createMap()
|
|
151
|
+
adPayload.putString(PROP_COMPANION_ADSLOTID, companionAd.adSlotId)
|
|
152
|
+
adPayload.putString(PROP_COMPANION_ALTTEXT, companionAd.altText)
|
|
153
|
+
adPayload.putString(PROP_COMPANION_CLICKTHROUGH, companionAd.clickThrough)
|
|
154
|
+
adPayload.putInt(PROP_COMPANION_WIDTH, companionAd.width)
|
|
155
|
+
adPayload.putInt(PROP_COMPANION_HEIGHT, companionAd.height)
|
|
156
|
+
adPayload.putString(PROP_COMPANION_RESOURCEURI, companionAd.resourceURI)
|
|
157
|
+
companionsPayload.pushMap(adPayload)
|
|
158
|
+
}
|
|
159
|
+
return companionsPayload
|
|
160
|
+
}
|
|
161
|
+
}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
package com.theoplayer.ads
|
|
2
|
+
|
|
3
|
+
import com.facebook.react.bridge.Arguments
|
|
4
|
+
import com.theoplayer.android.api.ads.wrapper.AdsApiWrapper
|
|
5
|
+
import com.facebook.react.bridge.WritableMap
|
|
6
|
+
import com.theoplayer.android.api.ads.Ad
|
|
7
|
+
import com.theoplayer.android.api.ads.AdBreak
|
|
8
|
+
import com.theoplayer.android.api.ads.ima.GoogleImaAdEventType
|
|
9
|
+
import com.theoplayer.android.api.ads.wrapper.AdEventListener
|
|
10
|
+
import com.theoplayer.android.api.event.EventType
|
|
11
|
+
import com.theoplayer.android.api.event.ads.AdEvent
|
|
12
|
+
import java.util.*
|
|
13
|
+
|
|
14
|
+
private const val EVENT_PROP_AD = "ad"
|
|
15
|
+
private const val EVENT_PROP_TYPE = "type"
|
|
16
|
+
private val ALL_AD_EVENTS = arrayOf(
|
|
17
|
+
GoogleImaAdEventType.LOADED,
|
|
18
|
+
GoogleImaAdEventType.AD_BREAK_STARTED,
|
|
19
|
+
GoogleImaAdEventType.STARTED,
|
|
20
|
+
GoogleImaAdEventType.FIRST_QUARTILE,
|
|
21
|
+
GoogleImaAdEventType.MIDPOINT,
|
|
22
|
+
GoogleImaAdEventType.THIRD_QUARTILE,
|
|
23
|
+
GoogleImaAdEventType.COMPLETED,
|
|
24
|
+
GoogleImaAdEventType.AD_BREAK_ENDED,
|
|
25
|
+
GoogleImaAdEventType.SKIPPED,
|
|
26
|
+
GoogleImaAdEventType.AD_ERROR,
|
|
27
|
+
GoogleImaAdEventType.AD_BUFFERING,
|
|
28
|
+
GoogleImaAdEventType.AD_BREAK_FETCH_ERROR
|
|
29
|
+
)
|
|
30
|
+
|
|
31
|
+
class AdEventAdapter(private val adsApi: AdsApiWrapper, eventEmitter: AdEventEmitter) {
|
|
32
|
+
private val eventListener: AdEventListener
|
|
33
|
+
|
|
34
|
+
interface AdEventEmitter {
|
|
35
|
+
fun emit(payload: WritableMap?)
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
init {
|
|
39
|
+
eventListener = object : AdEventListener {
|
|
40
|
+
override fun <E : AdEvent<*>?> onAdEvent(type: EventType<E>?, ad: Ad?) {
|
|
41
|
+
val payload = Arguments.createMap()
|
|
42
|
+
if (type != null) {
|
|
43
|
+
payload.putString(EVENT_PROP_TYPE, mapAdType(type))
|
|
44
|
+
}
|
|
45
|
+
if (ad != null) {
|
|
46
|
+
payload.putMap(EVENT_PROP_AD, AdAdapter.fromAd(ad))
|
|
47
|
+
}
|
|
48
|
+
eventEmitter.emit(payload)
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
override fun <E : AdEvent<*>?> onAdBreakEvent(type: EventType<E>?, adBreak: AdBreak?) {
|
|
52
|
+
val payload = Arguments.createMap()
|
|
53
|
+
if (type != null) {
|
|
54
|
+
payload.putString(EVENT_PROP_TYPE, mapAdType(type))
|
|
55
|
+
}
|
|
56
|
+
if (adBreak != null) {
|
|
57
|
+
payload.putMap(EVENT_PROP_AD, AdAdapter.fromAdBreak(adBreak))
|
|
58
|
+
}
|
|
59
|
+
eventEmitter.emit(payload)
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
for (eventType in ALL_AD_EVENTS) {
|
|
63
|
+
adsApi.addEventListener(eventType, eventListener)
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
private fun mapAdType(eventType: EventType<*>): String {
|
|
68
|
+
return when (eventType as GoogleImaAdEventType) {
|
|
69
|
+
GoogleImaAdEventType.LOADED -> "adloaded"
|
|
70
|
+
GoogleImaAdEventType.STARTED -> "adbegin"
|
|
71
|
+
GoogleImaAdEventType.FIRST_QUARTILE -> "adfirstquartile"
|
|
72
|
+
GoogleImaAdEventType.MIDPOINT -> "admidpoint"
|
|
73
|
+
GoogleImaAdEventType.THIRD_QUARTILE -> "adthirdquartile"
|
|
74
|
+
GoogleImaAdEventType.COMPLETED -> "adend"
|
|
75
|
+
GoogleImaAdEventType.SKIPPED -> "adskip"
|
|
76
|
+
GoogleImaAdEventType.AD_ERROR -> "aderror"
|
|
77
|
+
GoogleImaAdEventType.AD_BUFFERING -> "adbuffering"
|
|
78
|
+
GoogleImaAdEventType.AD_BREAK_STARTED -> "adbreakbegin"
|
|
79
|
+
GoogleImaAdEventType.AD_BREAK_ENDED -> "adbreakend"
|
|
80
|
+
GoogleImaAdEventType.AD_BREAK_FETCH_ERROR -> "aderror"
|
|
81
|
+
else -> eventType.getName().lowercase(Locale.getDefault())
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
fun destroy() {
|
|
86
|
+
for (eventType in ALL_AD_EVENTS) {
|
|
87
|
+
adsApi.removeEventListener(eventType, eventListener)
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
@file:Suppress("unused")
|
|
2
|
+
|
|
3
|
+
package com.theoplayer.ads
|
|
4
|
+
|
|
5
|
+
import android.util.Log
|
|
6
|
+
import com.facebook.react.bridge.*
|
|
7
|
+
import com.theoplayer.source.SourceAdapter
|
|
8
|
+
import com.theoplayer.util.ViewResolver
|
|
9
|
+
import com.theoplayer.ReactTHEOplayerView
|
|
10
|
+
import com.theoplayer.android.api.error.THEOplayerException
|
|
11
|
+
|
|
12
|
+
private const val TAG = "AdsModule"
|
|
13
|
+
|
|
14
|
+
class AdsModule(context: ReactApplicationContext) : ReactContextBaseJavaModule(context) {
|
|
15
|
+
private val sourceHelper = SourceAdapter()
|
|
16
|
+
private val viewResolver: ViewResolver
|
|
17
|
+
|
|
18
|
+
init {
|
|
19
|
+
viewResolver = ViewResolver(context)
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
override fun getName(): String {
|
|
23
|
+
return TAG
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
// Add an ad break request.
|
|
27
|
+
@ReactMethod
|
|
28
|
+
fun schedule(tag: Int, ad: ReadableMap) {
|
|
29
|
+
viewResolver.resolveViewByTag(tag) { view: ReactTHEOplayerView? ->
|
|
30
|
+
if (view != null) {
|
|
31
|
+
try {
|
|
32
|
+
view.adsApi.schedule(sourceHelper.parseAdFromJS(ad))
|
|
33
|
+
} catch (exception: THEOplayerException) {
|
|
34
|
+
Log.e(TAG, exception.message!!)
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
// The currently playing ad break.
|
|
41
|
+
@ReactMethod
|
|
42
|
+
fun currentAdBreak(tag: Int, promise: Promise) {
|
|
43
|
+
viewResolver.resolveViewByTag(tag) { view: ReactTHEOplayerView? ->
|
|
44
|
+
if (view == null) {
|
|
45
|
+
promise.resolve(Arguments.createMap())
|
|
46
|
+
} else {
|
|
47
|
+
promise.resolve(AdAdapter.fromAdBreak(view.adsApi.currentAdBreak))
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
// List of currently playing ads.
|
|
53
|
+
@ReactMethod
|
|
54
|
+
fun currentAds(tag: Int, promise: Promise) {
|
|
55
|
+
viewResolver.resolveViewByTag(tag) { view: ReactTHEOplayerView? ->
|
|
56
|
+
if (view == null) {
|
|
57
|
+
promise.resolve(Arguments.createMap())
|
|
58
|
+
} else {
|
|
59
|
+
promise.resolve(AdAdapter.fromAds(view.adsApi.currentAds))
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
// List of ad breaks which still need to be played.
|
|
65
|
+
@ReactMethod
|
|
66
|
+
fun scheduledAdBreaks(tag: Int, promise: Promise) {
|
|
67
|
+
viewResolver.resolveViewByTag(tag) { view: ReactTHEOplayerView? ->
|
|
68
|
+
if (view == null) {
|
|
69
|
+
promise.resolve(Arguments.createMap())
|
|
70
|
+
} else {
|
|
71
|
+
promise.resolve(AdAdapter.fromAdBreaks(view.adsApi.scheduledAdBreaks))
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
// Whether a linear ad is currently playing.
|
|
77
|
+
@ReactMethod
|
|
78
|
+
fun playing(tag: Int, promise: Promise) {
|
|
79
|
+
viewResolver.resolveViewByTag(tag) { view: ReactTHEOplayerView? ->
|
|
80
|
+
if (view == null) {
|
|
81
|
+
promise.resolve(false)
|
|
82
|
+
} else {
|
|
83
|
+
promise.resolve(view.adsApi.isPlaying)
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
// Skip the current linear ad.
|
|
89
|
+
// NOTE: This will have no effect when the current linear ad is (not yet) skippable.
|
|
90
|
+
@ReactMethod
|
|
91
|
+
fun skip(tag: Int) {
|
|
92
|
+
viewResolver.resolveViewByTag(tag) { view: ReactTHEOplayerView? -> view?.adsApi?.skip() }
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
@ReactMethod
|
|
96
|
+
fun daiSnapback(tag: Int, promise: Promise) {
|
|
97
|
+
viewResolver.resolveViewByTag(tag) { view: ReactTHEOplayerView? ->
|
|
98
|
+
val daiIntegration = view?.daiIntegration
|
|
99
|
+
if (daiIntegration == null) {
|
|
100
|
+
promise.resolve(false)
|
|
101
|
+
} else {
|
|
102
|
+
promise.resolve(daiIntegration.enableSnapback)
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
@ReactMethod
|
|
108
|
+
fun daiSetSnapback(tag: Int, enabled: Boolean?) {
|
|
109
|
+
viewResolver.resolveViewByTag(tag) { view: ReactTHEOplayerView? ->
|
|
110
|
+
val daiIntegration = view?.daiIntegration
|
|
111
|
+
if (daiIntegration != null) {
|
|
112
|
+
daiIntegration.enableSnapback = enabled!!
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
@ReactMethod
|
|
118
|
+
fun daiContentTimeForStreamTime(tag: Int, time: Int, promise: Promise) {
|
|
119
|
+
viewResolver.resolveViewByTag(tag) { view: ReactTHEOplayerView? ->
|
|
120
|
+
val daiIntegration = view?.daiIntegration
|
|
121
|
+
if (daiIntegration == null) {
|
|
122
|
+
promise.resolve(time)
|
|
123
|
+
} else {
|
|
124
|
+
promise.resolve((1e03 * daiIntegration.contentTimeForStreamTime(1e-03 * time)).toInt())
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
@ReactMethod
|
|
130
|
+
fun daiStreamTimeForContentTime(tag: Int, time: Int, promise: Promise) {
|
|
131
|
+
viewResolver.resolveViewByTag(tag) { view: ReactTHEOplayerView? ->
|
|
132
|
+
val daiIntegration = view?.daiIntegration
|
|
133
|
+
if (daiIntegration == null) {
|
|
134
|
+
promise.resolve(time)
|
|
135
|
+
} else {
|
|
136
|
+
promise.resolve((1e03 * daiIntegration.streamTimeForContentTime(1e-03 * time)).toInt())
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
package com.theoplayer.cast
|
|
2
|
+
|
|
3
|
+
import com.facebook.react.bridge.Arguments
|
|
4
|
+
import com.facebook.react.bridge.WritableMap
|
|
5
|
+
import com.theoplayer.android.api.cast.Cast
|
|
6
|
+
import com.theoplayer.android.api.cast.chromecast.CastError
|
|
7
|
+
import com.theoplayer.android.api.cast.chromecast.ErrorCode
|
|
8
|
+
import com.theoplayer.android.api.cast.chromecast.PlayerCastState
|
|
9
|
+
import com.theoplayer.android.api.event.chromecast.CastErrorEvent
|
|
10
|
+
import com.theoplayer.android.api.event.chromecast.CastStateChangeEvent
|
|
11
|
+
import com.theoplayer.android.api.event.chromecast.ChromecastEventTypes
|
|
12
|
+
|
|
13
|
+
const val EVENT_PROP_TYPE = "type"
|
|
14
|
+
const val EVENT_PROP_STATE = "state"
|
|
15
|
+
const val EVENT_PROP_ERROR = "error"
|
|
16
|
+
const val EVENT_PROP_ERROR_CODE = "errorCode"
|
|
17
|
+
const val EVENT_PROP_ERROR_DESCRIPTION = "description"
|
|
18
|
+
|
|
19
|
+
class CastEventAdapter(private val castApi: Cast, private val emitter: Emitter) {
|
|
20
|
+
|
|
21
|
+
interface Emitter {
|
|
22
|
+
fun emit(payload: WritableMap?)
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
init {
|
|
26
|
+
castApi.chromecast.addEventListener(ChromecastEventTypes.ERROR, this::onCastError)
|
|
27
|
+
castApi.chromecast.addEventListener(ChromecastEventTypes.STATECHANGE, this::onStateChange)
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
fun destroy() {
|
|
31
|
+
castApi.chromecast.removeEventListener(ChromecastEventTypes.ERROR, this::onCastError)
|
|
32
|
+
castApi.chromecast.removeEventListener(ChromecastEventTypes.STATECHANGE, this::onStateChange)
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
private fun onCastError(event: CastErrorEvent) {
|
|
36
|
+
val payload = Arguments.createMap()
|
|
37
|
+
payload.putString(EVENT_PROP_TYPE, "chromecasterror")
|
|
38
|
+
payload.putMap(EVENT_PROP_ERROR, serializeError(event.error))
|
|
39
|
+
emitter.emit(payload)
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
private fun serializeError(error: CastError): WritableMap {
|
|
43
|
+
val errorPayload = Arguments.createMap()
|
|
44
|
+
errorPayload.putString(
|
|
45
|
+
EVENT_PROP_ERROR_CODE,
|
|
46
|
+
when (error.errorCode) {
|
|
47
|
+
ErrorCode.CANCEL -> "CANCEL"
|
|
48
|
+
ErrorCode.TIMEOUT -> "TIMEOUT"
|
|
49
|
+
ErrorCode.API_NOT_INITIALIZED -> "API_NOT_INITIALIZED"
|
|
50
|
+
ErrorCode.INVALID_PARAMETER -> "INVALID_PARAMETER"
|
|
51
|
+
ErrorCode.EXTENSION_NOT_COMPATIBLE -> "EXTENSION_NOT_COMPATIBLE"
|
|
52
|
+
ErrorCode.EXTENSION_MISSING -> "EXTENSION_MISSING"
|
|
53
|
+
ErrorCode.RECEIVER_UNAVAILABLE -> "RECEIVER_UNAVAILABLE"
|
|
54
|
+
ErrorCode.SESSION_ERROR -> "SESSION_ERROR"
|
|
55
|
+
ErrorCode.CHANNEL_ERROR -> "CHANNEL_ERROR"
|
|
56
|
+
ErrorCode.LOAD_MEDIA_FAILED -> "LOAD_MEDIA_FAILED"
|
|
57
|
+
null -> ""
|
|
58
|
+
}
|
|
59
|
+
)
|
|
60
|
+
errorPayload.putString(EVENT_PROP_ERROR_DESCRIPTION, error.description)
|
|
61
|
+
return errorPayload
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
private fun onStateChange(event: CastStateChangeEvent) {
|
|
65
|
+
val payload = Arguments.createMap()
|
|
66
|
+
payload.putString(EVENT_PROP_TYPE, "chromecaststatechange")
|
|
67
|
+
if (event.state != null) {
|
|
68
|
+
payload.putString(
|
|
69
|
+
EVENT_PROP_STATE,
|
|
70
|
+
when (event.state) {
|
|
71
|
+
PlayerCastState.UNAVAILABLE -> "unavailable"
|
|
72
|
+
PlayerCastState.AVAILABLE -> "available"
|
|
73
|
+
PlayerCastState.CONNECTING -> "connecting"
|
|
74
|
+
PlayerCastState.CONNECTED -> "connected"
|
|
75
|
+
null -> "unavailable"
|
|
76
|
+
}
|
|
77
|
+
)
|
|
78
|
+
}
|
|
79
|
+
emitter.emit(payload)
|
|
80
|
+
}
|
|
81
|
+
}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
@file:Suppress("unused")
|
|
2
|
+
package com.theoplayer.cast
|
|
3
|
+
|
|
4
|
+
import com.facebook.react.bridge.ReactApplicationContext
|
|
5
|
+
import com.facebook.react.bridge.ReactContextBaseJavaModule
|
|
6
|
+
import com.theoplayer.util.ViewResolver
|
|
7
|
+
import com.facebook.react.bridge.ReactMethod
|
|
8
|
+
import com.facebook.react.bridge.Promise
|
|
9
|
+
import com.theoplayer.ReactTHEOplayerView
|
|
10
|
+
import com.theoplayer.android.api.cast.chromecast.PlayerCastState
|
|
11
|
+
|
|
12
|
+
class CastModule(context: ReactApplicationContext) : ReactContextBaseJavaModule(context) {
|
|
13
|
+
private val viewResolver: ViewResolver = ViewResolver(context)
|
|
14
|
+
|
|
15
|
+
override fun getName(): String {
|
|
16
|
+
return "CastModule"
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
@ReactMethod
|
|
20
|
+
fun casting(tag: Int, promise: Promise) {
|
|
21
|
+
viewResolver.resolveViewByTag(tag) { view: ReactTHEOplayerView? ->
|
|
22
|
+
promise.resolve(view?.castIntegration?.isCasting() ?: false)
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
@ReactMethod
|
|
27
|
+
fun chromecastCasting(tag: Int, promise: Promise) {
|
|
28
|
+
casting(tag, promise)
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
@ReactMethod
|
|
32
|
+
fun chromecastState(tag: Int, promise: Promise) {
|
|
33
|
+
viewResolver.resolveViewByTag(tag) { view: ReactTHEOplayerView? ->
|
|
34
|
+
promise.resolve(castStateToString(view?.castIntegration?.getState() ?: PlayerCastState.UNAVAILABLE))
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
private fun castStateToString(state: PlayerCastState): String {
|
|
39
|
+
return when (state) {
|
|
40
|
+
PlayerCastState.AVAILABLE -> "available"
|
|
41
|
+
PlayerCastState.CONNECTED -> "connected"
|
|
42
|
+
PlayerCastState.CONNECTING -> "connecting"
|
|
43
|
+
PlayerCastState.UNAVAILABLE -> "unavailable"
|
|
44
|
+
else -> "unavailable"
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
@ReactMethod
|
|
49
|
+
fun chromecastStart(tag: Int) {
|
|
50
|
+
viewResolver.resolveViewByTag(tag) { view: ReactTHEOplayerView? ->
|
|
51
|
+
view?.castIntegration?.start()
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
@ReactMethod
|
|
56
|
+
fun chromecastStop(tag: Int) {
|
|
57
|
+
viewResolver.resolveViewByTag(tag) { view: ReactTHEOplayerView? ->
|
|
58
|
+
view?.castIntegration?.stop()
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
@ReactMethod
|
|
63
|
+
fun chromecastJoin(tag: Int) {
|
|
64
|
+
viewResolver.resolveViewByTag(tag) { view: ReactTHEOplayerView? ->
|
|
65
|
+
view?.castIntegration?.join()
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
@ReactMethod
|
|
70
|
+
fun chromecastLeave(tag: Int) {
|
|
71
|
+
viewResolver.resolveViewByTag(tag) { view: ReactTHEOplayerView? ->
|
|
72
|
+
view?.castIntegration?.leave()
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
@@ -15,6 +15,8 @@ import com.theoplayer.android.api.source.drm.KeySystemConfiguration
|
|
|
15
15
|
import com.theoplayer.android.api.source.drm.preintegration.*
|
|
16
16
|
import org.json.JSONObject
|
|
17
17
|
|
|
18
|
+
private const val TAG = "ContentProtection"
|
|
19
|
+
|
|
18
20
|
const val PROP_INTEGRATION: String = "integration"
|
|
19
21
|
const val PROP_INTEGRATION_ID: String = "integrationId"
|
|
20
22
|
const val PROP_INTEGRATION_PARAMETERS: String = "integrationParameters"
|
|
@@ -34,8 +36,6 @@ const val PROP_USE_CREDENTIALS: String = "useCredentials"
|
|
|
34
36
|
|
|
35
37
|
object ContentProtectionAdapter {
|
|
36
38
|
|
|
37
|
-
const val TAG = "ContentProtection"
|
|
38
|
-
|
|
39
39
|
private fun createBridgeData(integrationId: String, keySystemId: KeySystemId): WritableMap {
|
|
40
40
|
return Arguments.createMap().apply {
|
|
41
41
|
putString(PROP_INTEGRATION_ID, integrationId)
|
|
@@ -12,7 +12,6 @@ import com.theoplayer.android.api.contentprotection.*
|
|
|
12
12
|
import com.theoplayer.android.api.error.ErrorCode
|
|
13
13
|
import com.theoplayer.android.api.error.THEOplayerException
|
|
14
14
|
import com.theoplayer.android.api.source.drm.DRMConfiguration
|
|
15
|
-
import com.theoplayer.drm.ContentProtectionAdapter.fromDRMConfiguration
|
|
16
15
|
|
|
17
16
|
data class BridgeRequest(
|
|
18
17
|
val onResult: HashMap<String, (result: ReadableMap) -> Unit>,
|
|
@@ -108,7 +107,7 @@ class ContentProtectionModule(private val context: ReactApplicationContext) :
|
|
|
108
107
|
fun onBuild(integrationId: String, keySystemId: KeySystemId, config: DRMConfiguration?) {
|
|
109
108
|
val payload = createBridgeData(integrationId, keySystemId)
|
|
110
109
|
if (config != null) {
|
|
111
|
-
payload.putMap(PROP_DRM_CONFIG, fromDRMConfiguration(config))
|
|
110
|
+
payload.putMap(PROP_DRM_CONFIG, ContentProtectionAdapter.fromDRMConfiguration(config))
|
|
112
111
|
}
|
|
113
112
|
emit(
|
|
114
113
|
EVENT_BUILD_INTEGRATION, payload,
|
|
@@ -8,8 +8,7 @@ class ProxyContentProtectionIntegration(
|
|
|
8
8
|
private val keySystemId: KeySystemId,
|
|
9
9
|
config: DRMConfiguration?,
|
|
10
10
|
private val module: ContentProtectionModule
|
|
11
|
-
) :
|
|
12
|
-
ContentProtectionIntegration() {
|
|
11
|
+
) : ContentProtectionIntegration() {
|
|
13
12
|
|
|
14
13
|
init {
|
|
15
14
|
module.onBuild(integrationId, keySystemId, config)
|
package/android/src/main/java/com/theoplayer/drm/ProxyContentProtectionIntegrationFactory.kt
CHANGED
|
@@ -9,11 +9,9 @@ class ProxyContentProtectionIntegrationFactory(
|
|
|
9
9
|
private val integrationId: String,
|
|
10
10
|
private val keySystemId: KeySystemId,
|
|
11
11
|
private val module: ContentProtectionModule
|
|
12
|
-
) :
|
|
13
|
-
|
|
14
|
-
override fun build(
|
|
15
|
-
config: DRMConfiguration?
|
|
16
|
-
): ContentProtectionIntegration {
|
|
12
|
+
) : ContentProtectionIntegrationFactory {
|
|
13
|
+
|
|
14
|
+
override fun build(config: DRMConfiguration?): ContentProtectionIntegration {
|
|
17
15
|
return ProxyContentProtectionIntegration(integrationId, keySystemId, config, module)
|
|
18
16
|
}
|
|
19
17
|
}
|