react-native-theoplayer 9.10.0 → 10.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +35 -0
- package/README.md +2 -1
- package/android/build.gradle +11 -12
- package/android/local/com/theoplayer/theoplayer-sdk-android/ads-wrapper/10.0.0/ads-wrapper-10.0.0.aar +0 -0
- package/android/local/com/theoplayer/theoplayer-sdk-android/ads-wrapper/{9.0.0/ads-wrapper-9.0.0.pom → 10.0.0/ads-wrapper-10.0.0.pom} +3 -3
- package/android/local/com/theoplayer/theoplayer-sdk-android/ads-wrapper/maven-metadata-local.xml +4 -4
- package/android/src/main/AndroidManifest.xml +1 -1
- package/android/src/main/java/com/theoplayer/PlayerEventEmitter.kt +39 -10
- package/android/src/main/java/com/theoplayer/ReactTHEOplayerPackage.kt +32 -14
- package/android/src/main/java/com/theoplayer/ads/AdsModule.kt +18 -6
- package/android/src/main/java/com/theoplayer/broadcast/EventBroadcastModule.kt +15 -5
- package/android/src/main/java/com/theoplayer/cache/CacheAdapter.kt +0 -12
- package/android/src/main/java/com/theoplayer/cache/CacheModule.kt +20 -7
- package/android/src/main/java/com/theoplayer/cast/CastEventAdapter.kt +11 -7
- package/android/src/main/java/com/theoplayer/cast/CastModule.kt +17 -3
- package/android/src/main/java/com/theoplayer/drm/ContentProtectionAdapter.kt +1 -1
- package/android/src/main/java/com/theoplayer/drm/ContentProtectionModule.kt +28 -11
- package/android/src/main/java/com/theoplayer/media/ConditionalMediaButtonReceiver.kt +38 -0
- package/android/src/main/java/com/theoplayer/player/PlayerModule.kt +17 -4
- package/android/src/main/java/com/theoplayer/presentation/PresentationManager.kt +12 -3
- package/android/src/main/java/com/theoplayer/source/SourceAdapter.kt +16 -37
- package/android/src/main/java/com/theoplayer/theoads/THEOadsAdapter.kt +83 -0
- package/android/src/main/java/com/theoplayer/theoads/THEOadsEventAdapter.kt +55 -0
- package/android/src/main/java/com/theoplayer/theoads/THEOadsModule.kt +63 -0
- package/android/src/main/java/com/theoplayer/theolive/THEOliveEventAdapter.kt +21 -8
- package/android/src/main/java/com/theoplayer/theolive/THEOliveModule.kt +16 -3
- package/android/src/main/java/com/theoplayer/track/TextTrackStyleAdapter.kt +8 -1
- package/android/src/main/java/com/theoplayer/util/PayloadBuilder.kt +8 -0
- package/ios/THEOplayerRCTBridge.m +21 -1
- package/ios/THEOplayerRCTDebug.swift +4 -1
- package/ios/THEOplayerRCTMainEventHandler.swift +24 -21
- package/ios/THEOplayerRCTPlayerAPI.swift +3 -3
- package/ios/THEOplayerRCTSourceDescriptionBuilder.swift +2 -1
- package/ios/THEOplayerRCTView.swift +22 -4
- package/ios/backgroundAudio/THEOplayerRCTNowPlayingManager.swift +96 -50
- package/ios/backgroundAudio/THEOplayerRCTRemoteCommandsManager.swift +0 -1
- package/ios/casting/THEOplayerRCTCastEventHandler.swift +1 -1
- package/ios/presentationMode/THEOplayerRCTPresentationModeManager.swift +24 -6
- package/ios/theoAds/THEOplayerRCTTHEOAdsAPI.swift +101 -0
- package/ios/theoAds/THEOplayerRCTTHEOAdsEventAdapter.swift +118 -0
- package/ios/theoAds/THEOplayerRCTTHEOAdsEventHandler.swift +174 -0
- package/ios/theolive/THEOplayerRCTSourceDescriptionBuilder+Theolive.swift +0 -1
- package/ios/theolive/THEOplayerRCTTHEOliveEventHandler.swift +1 -1
- package/ios/theolive/THEOplayerRCTView+THEOlive.swift +1 -5
- package/ios/theolive/THEOplayerRCTView+THEOliveConfig.swift +0 -2
- package/lib/commonjs/api/barrel.js +45 -56
- package/lib/commonjs/api/barrel.js.map +1 -1
- package/lib/commonjs/api/cache/CachingTaskParameters.js +0 -19
- package/lib/commonjs/api/cache/CachingTaskParameters.js.map +1 -1
- package/lib/commonjs/api/event/PlayerEvent.js +16 -0
- package/lib/commonjs/api/event/PlayerEvent.js.map +1 -1
- package/lib/commonjs/api/event/TheoAdsEvent.js +7 -0
- package/lib/commonjs/api/event/TheoAdsEvent.js.map +1 -1
- package/lib/commonjs/api/player/PlayerEventMap.js +2 -0
- package/lib/commonjs/api/player/PlayerEventMap.js.map +1 -1
- package/lib/commonjs/api/source/SourceDescription.js +1 -13
- package/lib/commonjs/api/source/SourceDescription.js.map +1 -1
- package/lib/commonjs/api/source/ads/{THEOplayerAdDescription.js → CsaiAdDescription.js} +1 -1
- package/lib/commonjs/api/source/ads/CsaiAdDescription.js.map +1 -0
- package/lib/commonjs/api/source/ads/barrel.js +4 -4
- package/lib/commonjs/api/source/ads/barrel.js.map +1 -1
- package/lib/commonjs/api/track/Quality.js +37 -0
- package/lib/commonjs/api/track/Quality.js.map +1 -1
- package/lib/commonjs/api/track/TextTrackStyle.js.map +1 -1
- package/lib/commonjs/index.js +0 -8
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/internal/THEOplayerView.js +15 -3
- package/lib/commonjs/internal/THEOplayerView.js.map +1 -1
- package/lib/commonjs/internal/THEOplayerView.web.js +1 -1
- package/lib/commonjs/internal/THEOplayerView.web.js.map +1 -1
- package/lib/commonjs/internal/adapter/DefaultNativePlayerState.js +2 -0
- package/lib/commonjs/internal/adapter/DefaultNativePlayerState.js.map +1 -1
- package/lib/commonjs/internal/adapter/THEOplayerAdapter.js +27 -9
- package/lib/commonjs/internal/adapter/THEOplayerAdapter.js.map +1 -1
- package/lib/commonjs/internal/adapter/THEOplayerWebAdapter.js +18 -1
- package/lib/commonjs/internal/adapter/THEOplayerWebAdapter.js.map +1 -1
- package/lib/commonjs/internal/adapter/WebEventForwarder.js +15 -1
- package/lib/commonjs/internal/adapter/WebEventForwarder.js.map +1 -1
- package/lib/commonjs/internal/adapter/event/PlayerEvents.js +30 -1
- package/lib/commonjs/internal/adapter/event/PlayerEvents.js.map +1 -1
- package/lib/commonjs/internal/adapter/event/native/NativeTheoAdsEvent.js +20 -0
- package/lib/commonjs/internal/adapter/event/native/NativeTheoAdsEvent.js.map +1 -0
- package/lib/commonjs/internal/adapter/theoads/THEOAdsNativeAdapter.js +6 -12
- package/lib/commonjs/internal/adapter/theoads/THEOAdsNativeAdapter.js.map +1 -1
- package/lib/commonjs/internal/adapter/track/TextTrackStyleAdapter.js +10 -0
- package/lib/commonjs/internal/adapter/track/TextTrackStyleAdapter.js.map +1 -1
- package/lib/commonjs/internal/utils/TypeUtils.js +4 -1
- package/lib/commonjs/internal/utils/TypeUtils.js.map +1 -1
- package/lib/commonjs/manifest.json +1 -1
- package/lib/module/api/barrel.js +0 -1
- package/lib/module/api/barrel.js.map +1 -1
- package/lib/module/api/cache/CachingTaskParameters.js +1 -19
- package/lib/module/api/cache/CachingTaskParameters.js.map +1 -1
- package/lib/module/api/event/PlayerEvent.js +18 -0
- package/lib/module/api/event/PlayerEvent.js.map +1 -1
- package/lib/module/api/event/TheoAdsEvent.js +8 -0
- package/lib/module/api/event/TheoAdsEvent.js.map +1 -1
- package/lib/module/api/player/PlayerEventMap.js +2 -0
- package/lib/module/api/player/PlayerEventMap.js.map +1 -1
- package/lib/module/api/source/SourceDescription.js +0 -13
- package/lib/module/api/source/SourceDescription.js.map +1 -1
- package/lib/module/api/source/ads/CsaiAdDescription.js +4 -0
- package/lib/module/api/source/ads/CsaiAdDescription.js.map +1 -0
- package/lib/module/api/source/ads/barrel.js +1 -1
- package/lib/module/api/source/ads/barrel.js.map +1 -1
- package/lib/module/api/track/Quality.js +34 -0
- package/lib/module/api/track/Quality.js.map +1 -1
- package/lib/module/api/track/TextTrackStyle.js.map +1 -1
- package/lib/module/index.js +0 -1
- package/lib/module/index.js.map +1 -1
- package/lib/module/internal/THEOplayerView.js +16 -4
- package/lib/module/internal/THEOplayerView.js.map +1 -1
- package/lib/module/internal/THEOplayerView.web.js +1 -1
- package/lib/module/internal/THEOplayerView.web.js.map +1 -1
- package/lib/module/internal/adapter/DefaultNativePlayerState.js +2 -0
- package/lib/module/internal/adapter/DefaultNativePlayerState.js.map +1 -1
- package/lib/module/internal/adapter/THEOplayerAdapter.js +28 -10
- package/lib/module/internal/adapter/THEOplayerAdapter.js.map +1 -1
- package/lib/module/internal/adapter/THEOplayerWebAdapter.js +18 -1
- package/lib/module/internal/adapter/THEOplayerWebAdapter.js.map +1 -1
- package/lib/module/internal/adapter/WebEventForwarder.js +16 -2
- package/lib/module/internal/adapter/WebEventForwarder.js.map +1 -1
- package/lib/module/internal/adapter/event/PlayerEvents.js +26 -0
- package/lib/module/internal/adapter/event/PlayerEvents.js.map +1 -1
- package/lib/module/internal/adapter/event/native/NativeTheoAdsEvent.js +16 -0
- package/lib/module/internal/adapter/event/native/NativeTheoAdsEvent.js.map +1 -0
- package/lib/module/internal/adapter/theoads/THEOAdsNativeAdapter.js +6 -12
- package/lib/module/internal/adapter/theoads/THEOAdsNativeAdapter.js.map +1 -1
- package/lib/module/internal/adapter/track/TextTrackStyleAdapter.js +10 -0
- package/lib/module/internal/adapter/track/TextTrackStyleAdapter.js.map +1 -1
- package/lib/module/internal/utils/TypeUtils.js +3 -0
- package/lib/module/internal/utils/TypeUtils.js.map +1 -1
- package/lib/module/manifest.json +1 -1
- package/lib/typescript/api/barrel.d.ts +0 -1
- package/lib/typescript/api/barrel.d.ts.map +1 -1
- package/lib/typescript/api/cache/CachingTaskParameters.d.ts +0 -34
- package/lib/typescript/api/cache/CachingTaskParameters.d.ts.map +1 -1
- package/lib/typescript/api/event/PlayerEvent.d.ts +36 -0
- package/lib/typescript/api/event/PlayerEvent.d.ts.map +1 -1
- package/lib/typescript/api/event/TheoAdsEvent.d.ts +13 -0
- package/lib/typescript/api/event/TheoAdsEvent.d.ts.map +1 -1
- package/lib/typescript/api/player/PlayerEventMap.d.ts +17 -2
- package/lib/typescript/api/player/PlayerEventMap.d.ts.map +1 -1
- package/lib/typescript/api/player/THEOplayer.d.ts +8 -0
- package/lib/typescript/api/player/THEOplayer.d.ts.map +1 -1
- package/lib/typescript/api/source/SourceDescription.d.ts +0 -20
- package/lib/typescript/api/source/SourceDescription.d.ts.map +1 -1
- package/lib/typescript/api/source/ads/{THEOplayerAdDescription.d.ts → CsaiAdDescription.d.ts} +2 -2
- package/lib/typescript/api/source/ads/CsaiAdDescription.d.ts.map +1 -0
- package/lib/typescript/api/source/ads/barrel.d.ts +1 -1
- package/lib/typescript/api/source/ads/barrel.d.ts.map +1 -1
- package/lib/typescript/api/track/Quality.d.ts +1 -0
- package/lib/typescript/api/track/Quality.d.ts.map +1 -1
- package/lib/typescript/api/track/TextTrackStyle.d.ts +7 -0
- package/lib/typescript/api/track/TextTrackStyle.d.ts.map +1 -1
- package/lib/typescript/index.d.ts +0 -1
- package/lib/typescript/index.d.ts.map +1 -1
- package/lib/typescript/internal/THEOplayerView.d.ts +3 -1
- package/lib/typescript/internal/THEOplayerView.d.ts.map +1 -1
- package/lib/typescript/internal/adapter/DefaultNativePlayerState.d.ts +2 -0
- package/lib/typescript/internal/adapter/DefaultNativePlayerState.d.ts.map +1 -1
- package/lib/typescript/internal/adapter/NativePlayerState.d.ts +2 -0
- package/lib/typescript/internal/adapter/NativePlayerState.d.ts.map +1 -1
- package/lib/typescript/internal/adapter/THEOplayerAdapter.d.ts +5 -3
- package/lib/typescript/internal/adapter/THEOplayerAdapter.d.ts.map +1 -1
- package/lib/typescript/internal/adapter/THEOplayerWebAdapter.d.ts +5 -0
- package/lib/typescript/internal/adapter/THEOplayerWebAdapter.d.ts.map +1 -1
- package/lib/typescript/internal/adapter/WebEventForwarder.d.ts +1 -0
- package/lib/typescript/internal/adapter/WebEventForwarder.d.ts.map +1 -1
- package/lib/typescript/internal/adapter/event/PlayerEvents.d.ts +20 -1
- package/lib/typescript/internal/adapter/event/PlayerEvents.d.ts.map +1 -1
- package/lib/typescript/internal/adapter/event/native/NativePlayerEvent.d.ts +11 -1
- package/lib/typescript/internal/adapter/event/native/NativePlayerEvent.d.ts.map +1 -1
- package/lib/typescript/internal/adapter/event/native/NativeTheoAdsEvent.d.ts +18 -0
- package/lib/typescript/internal/adapter/event/native/NativeTheoAdsEvent.d.ts.map +1 -0
- package/lib/typescript/internal/adapter/theoads/THEOAdsNativeAdapter.d.ts +1 -1
- package/lib/typescript/internal/adapter/theoads/THEOAdsNativeAdapter.d.ts.map +1 -1
- package/lib/typescript/internal/adapter/track/TextTrackStyleAdapter.d.ts +3 -0
- package/lib/typescript/internal/adapter/track/TextTrackStyleAdapter.d.ts.map +1 -1
- package/lib/typescript/internal/utils/TypeUtils.d.ts +1 -0
- package/lib/typescript/internal/utils/TypeUtils.d.ts.map +1 -1
- package/package.json +6 -6
- package/react-native-theoplayer.podspec +7 -7
- package/src/api/barrel.ts +0 -1
- package/src/api/cache/CachingTaskParameters.ts +0 -37
- package/src/api/event/PlayerEvent.ts +40 -0
- package/src/api/event/TheoAdsEvent.ts +14 -0
- package/src/api/player/PlayerEventMap.ts +19 -0
- package/src/api/player/THEOplayer.ts +10 -0
- package/src/api/source/SourceDescription.ts +0 -22
- package/src/api/source/ads/{THEOplayerAdDescription.ts → CsaiAdDescription.ts} +1 -1
- package/src/api/source/ads/barrel.ts +1 -1
- package/src/api/track/Quality.ts +15 -0
- package/src/api/track/TextTrackStyle.ts +8 -0
- package/src/index.tsx +0 -1
- package/src/internal/THEOplayerView.tsx +24 -5
- package/src/internal/THEOplayerView.web.tsx +1 -1
- package/src/internal/adapter/DefaultNativePlayerState.ts +2 -0
- package/src/internal/adapter/NativePlayerState.ts +2 -0
- package/src/internal/adapter/THEOplayerAdapter.ts +43 -21
- package/src/internal/adapter/THEOplayerWebAdapter.ts +22 -2
- package/src/internal/adapter/WebEventForwarder.ts +17 -1
- package/src/internal/adapter/event/PlayerEvents.ts +34 -0
- package/src/internal/adapter/event/native/NativePlayerEvent.ts +13 -1
- package/src/internal/adapter/event/native/NativeTheoAdsEvent.ts +30 -0
- package/src/internal/adapter/theoads/THEOAdsNativeAdapter.ts +7 -12
- package/src/internal/adapter/track/TextTrackStyleAdapter.ts +12 -0
- package/src/internal/utils/TypeUtils.ts +6 -0
- package/src/manifest.json +1 -1
- package/android/local/com/theoplayer/theoplayer-sdk-android/ads-wrapper/9.0.0/ads-wrapper-9.0.0.aar +0 -0
- package/android/src/main/java/com/theoplayer/playback/PlaybackSettingsModule.kt +0 -28
- package/lib/commonjs/api/playback/PlaybackSettingsAPI.js +0 -2
- package/lib/commonjs/api/playback/PlaybackSettingsAPI.js.map +0 -1
- package/lib/commonjs/api/playback/barrel.js +0 -17
- package/lib/commonjs/api/playback/barrel.js.map +0 -1
- package/lib/commonjs/api/source/ads/THEOplayerAdDescription.js.map +0 -1
- package/lib/commonjs/internal/playback/PlaybackSettings.js +0 -28
- package/lib/commonjs/internal/playback/PlaybackSettings.js.map +0 -1
- package/lib/module/api/playback/PlaybackSettingsAPI.js +0 -2
- package/lib/module/api/playback/PlaybackSettingsAPI.js.map +0 -1
- package/lib/module/api/playback/barrel.js +0 -4
- package/lib/module/api/playback/barrel.js.map +0 -1
- package/lib/module/api/source/ads/THEOplayerAdDescription.js +0 -4
- package/lib/module/api/source/ads/THEOplayerAdDescription.js.map +0 -1
- package/lib/module/internal/playback/PlaybackSettings.js +0 -23
- package/lib/module/internal/playback/PlaybackSettings.js.map +0 -1
- package/lib/typescript/api/playback/PlaybackSettingsAPI.d.ts +0 -35
- package/lib/typescript/api/playback/PlaybackSettingsAPI.d.ts.map +0 -1
- package/lib/typescript/api/playback/barrel.d.ts +0 -2
- package/lib/typescript/api/playback/barrel.d.ts.map +0 -1
- package/lib/typescript/api/source/ads/THEOplayerAdDescription.d.ts.map +0 -1
- package/lib/typescript/internal/playback/PlaybackSettings.d.ts +0 -7
- package/lib/typescript/internal/playback/PlaybackSettings.d.ts.map +0 -1
- package/src/api/playback/PlaybackSettingsAPI.ts +0 -36
- package/src/api/playback/barrel.ts +0 -1
- package/src/internal/playback/PlaybackSettings.ts +0 -25
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
@file:Suppress("unused")
|
|
2
|
-
|
|
3
1
|
package com.theoplayer.cast
|
|
4
2
|
|
|
5
3
|
import com.facebook.react.bridge.ReactApplicationContext
|
|
@@ -7,14 +5,30 @@ import com.facebook.react.bridge.ReactContextBaseJavaModule
|
|
|
7
5
|
import com.theoplayer.util.ViewResolver
|
|
8
6
|
import com.facebook.react.bridge.ReactMethod
|
|
9
7
|
import com.facebook.react.bridge.Promise
|
|
8
|
+
import com.facebook.react.module.annotations.ReactModule
|
|
9
|
+
import com.facebook.react.module.model.ReactModuleInfo
|
|
10
10
|
import com.theoplayer.ReactTHEOplayerView
|
|
11
11
|
import com.theoplayer.android.api.cast.chromecast.PlayerCastState
|
|
12
12
|
|
|
13
|
+
@Suppress("unused")
|
|
14
|
+
@ReactModule(name = CastModule.NAME)
|
|
13
15
|
class CastModule(context: ReactApplicationContext) : ReactContextBaseJavaModule(context) {
|
|
16
|
+
companion object {
|
|
17
|
+
const val NAME = "THEORCTCastModule"
|
|
18
|
+
val INFO = ReactModuleInfo(
|
|
19
|
+
name = NAME,
|
|
20
|
+
className = NAME,
|
|
21
|
+
canOverrideExistingModule = false,
|
|
22
|
+
needsEagerInit = false,
|
|
23
|
+
isCxxModule = false,
|
|
24
|
+
isTurboModule = false,
|
|
25
|
+
)
|
|
26
|
+
}
|
|
27
|
+
|
|
14
28
|
private val viewResolver: ViewResolver = ViewResolver(context)
|
|
15
29
|
|
|
16
30
|
override fun getName(): String {
|
|
17
|
-
return
|
|
31
|
+
return NAME
|
|
18
32
|
}
|
|
19
33
|
|
|
20
34
|
@ReactMethod
|
|
@@ -165,7 +165,7 @@ object ContentProtectionAdapter {
|
|
|
165
165
|
if (widevine != null) {
|
|
166
166
|
putMap(PROP_WIDEVINE, Arguments.createMap().apply {
|
|
167
167
|
putString(PROP_LA_URL, widevine.licenseAcquisitionURL)
|
|
168
|
-
putBoolean(PROP_USE_CREDENTIALS, widevine.
|
|
168
|
+
putBoolean(PROP_USE_CREDENTIALS, widevine.useCredentials)
|
|
169
169
|
})
|
|
170
170
|
}
|
|
171
171
|
}
|
|
@@ -5,6 +5,8 @@ import android.os.Looper
|
|
|
5
5
|
import android.util.Base64
|
|
6
6
|
import android.util.Log
|
|
7
7
|
import com.facebook.react.bridge.*
|
|
8
|
+
import com.facebook.react.module.annotations.ReactModule
|
|
9
|
+
import com.facebook.react.module.model.ReactModuleInfo
|
|
8
10
|
import com.facebook.react.modules.core.DeviceEventManagerModule.RCTDeviceEventEmitter
|
|
9
11
|
import com.theoplayer.BuildConfig
|
|
10
12
|
import com.theoplayer.android.api.THEOplayerGlobal
|
|
@@ -19,11 +21,11 @@ data class BridgeRequest(
|
|
|
19
21
|
val onTimeout: Runnable
|
|
20
22
|
)
|
|
21
23
|
|
|
22
|
-
private const val TAG = "ContentProtectionModule"
|
|
23
|
-
|
|
24
24
|
private const val EVENT_CERTIFICATE_REQUEST = "onCertificateRequest"
|
|
25
|
-
private const val EVENT_CERTIFICATE_REQUEST_PROCESSED_AS_REQUEST =
|
|
26
|
-
|
|
25
|
+
private const val EVENT_CERTIFICATE_REQUEST_PROCESSED_AS_REQUEST =
|
|
26
|
+
"onCertificateRequestProcessedAsRequest"
|
|
27
|
+
private const val EVENT_CERTIFICATE_REQUEST_PROCESSED_AS_CERTIFICATE =
|
|
28
|
+
"onCertificateRequestProcessedAsCertificate"
|
|
27
29
|
private const val EVENT_CERTIFICATE_RESPONSE = "onCertificateResponse"
|
|
28
30
|
private const val EVENT_CERTIFICATE_RESPONSE_PROCESSED = "onCertificateResponseProcessed"
|
|
29
31
|
private const val EVENT_BUILD_INTEGRATION = "onBuildIntegration"
|
|
@@ -35,10 +37,20 @@ private const val EVENT_LICENSE_RESPONSE = "onLicenseResponse"
|
|
|
35
37
|
private const val EVENT_LICENSE_RESPONSE_PROCESSED = "onLicenseResponseProcessed"
|
|
36
38
|
|
|
37
39
|
@Suppress("unused")
|
|
40
|
+
@ReactModule(name = ContentProtectionModule.NAME)
|
|
38
41
|
class ContentProtectionModule(private val context: ReactApplicationContext) :
|
|
39
42
|
ReactContextBaseJavaModule(context) {
|
|
40
43
|
|
|
41
44
|
companion object {
|
|
45
|
+
const val NAME = "THEORCTContentProtectionModule"
|
|
46
|
+
val INFO = ReactModuleInfo(
|
|
47
|
+
name = NAME,
|
|
48
|
+
className = ContentProtectionModule::class.qualifiedName!!,
|
|
49
|
+
canOverrideExistingModule = false,
|
|
50
|
+
needsEagerInit = false,
|
|
51
|
+
isCxxModule = false,
|
|
52
|
+
isTurboModule = false,
|
|
53
|
+
)
|
|
42
54
|
const val REQUEST_TIMEOUT_MS = 10000L
|
|
43
55
|
}
|
|
44
56
|
|
|
@@ -49,7 +61,7 @@ class ContentProtectionModule(private val context: ReactApplicationContext) :
|
|
|
49
61
|
private val requestQueue: HashMap<String, BridgeRequest> = HashMap()
|
|
50
62
|
|
|
51
63
|
override fun getName(): String {
|
|
52
|
-
return
|
|
64
|
+
return NAME
|
|
53
65
|
}
|
|
54
66
|
|
|
55
67
|
@ReactMethod
|
|
@@ -66,7 +78,7 @@ class ContentProtectionModule(private val context: ReactApplicationContext) :
|
|
|
66
78
|
.registerContentProtectionIntegration(integrationId, keySystemId, factory)
|
|
67
79
|
}
|
|
68
80
|
} else {
|
|
69
|
-
Log.e(
|
|
81
|
+
Log.e(NAME, "Invalid keySystemId $keySystemIdStr")
|
|
70
82
|
}
|
|
71
83
|
}
|
|
72
84
|
|
|
@@ -131,7 +143,8 @@ class ContentProtectionModule(private val context: ReactApplicationContext) :
|
|
|
131
143
|
EVENT_CERTIFICATE_REQUEST_PROCESSED_AS_REQUEST to { result ->
|
|
132
144
|
request.url = result.getString(PROP_URL)!!
|
|
133
145
|
request.method = RequestMethodAdapter.fromString(result.getString(PROP_METHOD))
|
|
134
|
-
val headers =
|
|
146
|
+
val headers =
|
|
147
|
+
result.getMap(PROP_HEADERS)?.toHashMap()?.mapValues { entry -> entry.value as? String }
|
|
135
148
|
if (headers != null) {
|
|
136
149
|
request.headers = headers
|
|
137
150
|
}
|
|
@@ -180,7 +193,8 @@ class ContentProtectionModule(private val context: ReactApplicationContext) :
|
|
|
180
193
|
EVENT_LICENSE_REQUEST_PROCESSED_AS_REQUEST to { result ->
|
|
181
194
|
request.url = result.getString(PROP_URL)!!
|
|
182
195
|
request.method = RequestMethodAdapter.fromString(result.getString(PROP_METHOD))
|
|
183
|
-
val headers =
|
|
196
|
+
val headers =
|
|
197
|
+
result.getMap(PROP_HEADERS)?.toHashMap()?.mapValues { entry -> entry.value as? String }
|
|
184
198
|
if (headers != null) {
|
|
185
199
|
request.headers = headers
|
|
186
200
|
}
|
|
@@ -234,7 +248,7 @@ class ContentProtectionModule(private val context: ReactApplicationContext) :
|
|
|
234
248
|
) {
|
|
235
249
|
val requestId = createRequestId()
|
|
236
250
|
if (BuildConfig.DEBUG) {
|
|
237
|
-
Log.d(
|
|
251
|
+
Log.d(NAME, "emit $eventName ($requestId)")
|
|
238
252
|
}
|
|
239
253
|
payload.putString(PROP_REQUEST_ID, requestId)
|
|
240
254
|
val onTimeout = Runnable {
|
|
@@ -252,7 +266,7 @@ class ContentProtectionModule(private val context: ReactApplicationContext) :
|
|
|
252
266
|
private fun receive(eventName: String, payload: ReadableMap) {
|
|
253
267
|
val requestId = payload.getString(PROP_REQUEST_ID)
|
|
254
268
|
if (BuildConfig.DEBUG) {
|
|
255
|
-
Log.d(
|
|
269
|
+
Log.d(NAME, "receive $eventName ($requestId)")
|
|
256
270
|
}
|
|
257
271
|
val request = requestQueue.remove(requestId)
|
|
258
272
|
if (request != null) {
|
|
@@ -262,7 +276,10 @@ class ContentProtectionModule(private val context: ReactApplicationContext) :
|
|
|
262
276
|
onEventResult(payload)
|
|
263
277
|
} else {
|
|
264
278
|
request.onError(
|
|
265
|
-
THEOplayerException(
|
|
279
|
+
THEOplayerException(
|
|
280
|
+
ErrorCode.CONTENT_PROTECTION_ERROR,
|
|
281
|
+
"Unknown bridge event: $eventName."
|
|
282
|
+
)
|
|
266
283
|
)
|
|
267
284
|
}
|
|
268
285
|
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
package com.theoplayer.media
|
|
2
|
+
|
|
3
|
+
import android.app.ActivityManager
|
|
4
|
+
import android.content.BroadcastReceiver
|
|
5
|
+
import android.content.Context
|
|
6
|
+
import android.content.Intent
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* A MediaButtonReceiver that only forwards MediaButton events if the MediaPlaybackService is
|
|
10
|
+
* running, otherwise ignore the event.
|
|
11
|
+
* This avoid the service is being restarted when the parent app was closed.
|
|
12
|
+
* It also avoids the ForegroundServiceDidNotStartInTimeException, which is sent when the
|
|
13
|
+
* service doesn't start in time (within 5 seconds) due to heavy load.
|
|
14
|
+
*/
|
|
15
|
+
class ConditionalMediaButtonReceiver : BroadcastReceiver() {
|
|
16
|
+
|
|
17
|
+
override fun onReceive(context: Context, intent: Intent) {
|
|
18
|
+
if (Intent.ACTION_MEDIA_BUTTON == intent.action) {
|
|
19
|
+
// Only send the intent if service is already running.
|
|
20
|
+
if (isServiceRunning(context, MediaPlaybackService::class.java)) {
|
|
21
|
+
intent.setClass(context, MediaPlaybackService::class.java)
|
|
22
|
+
context.startService(intent)
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
private fun isServiceRunning(context: Context, serviceClass: Class<*>): Boolean {
|
|
28
|
+
val am = context.getSystemService(Context.ACTIVITY_SERVICE) as ActivityManager
|
|
29
|
+
@Suppress("DEPRECATION") // Only alternative is usage stats, heavier
|
|
30
|
+
val runningServices = am.getRunningServices(Int.MAX_VALUE)
|
|
31
|
+
for (service in runningServices) {
|
|
32
|
+
if (serviceClass.name == service.service.className) {
|
|
33
|
+
return true
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
return false
|
|
37
|
+
}
|
|
38
|
+
}
|
|
@@ -2,6 +2,8 @@ package com.theoplayer.player
|
|
|
2
2
|
|
|
3
3
|
import android.os.Build
|
|
4
4
|
import com.facebook.react.bridge.*
|
|
5
|
+
import com.facebook.react.module.annotations.ReactModule
|
|
6
|
+
import com.facebook.react.module.model.ReactModuleInfo
|
|
5
7
|
import com.theoplayer.*
|
|
6
8
|
import com.theoplayer.abr.ABRConfigurationAdapter
|
|
7
9
|
import com.theoplayer.android.api.player.AspectRatio
|
|
@@ -17,14 +19,25 @@ import com.theoplayer.presentation.PipConfigAdapter
|
|
|
17
19
|
import com.theoplayer.track.TextTrackStyleAdapter
|
|
18
20
|
import com.theoplayer.util.ViewResolver
|
|
19
21
|
|
|
20
|
-
private const val TAG = "THEORCTPlayerModule"
|
|
21
|
-
|
|
22
22
|
@Suppress("unused")
|
|
23
|
+
@ReactModule(name = PlayerModule.NAME)
|
|
23
24
|
class PlayerModule(context: ReactApplicationContext) : ReactContextBaseJavaModule(context) {
|
|
25
|
+
companion object {
|
|
26
|
+
const val NAME = "THEORCTPlayerModule"
|
|
27
|
+
val INFO = ReactModuleInfo(
|
|
28
|
+
name = NAME,
|
|
29
|
+
className = NAME,
|
|
30
|
+
canOverrideExistingModule = false,
|
|
31
|
+
needsEagerInit = false,
|
|
32
|
+
isCxxModule = false,
|
|
33
|
+
isTurboModule = false,
|
|
34
|
+
)
|
|
35
|
+
}
|
|
36
|
+
|
|
24
37
|
private val viewResolver: ViewResolver = ViewResolver(context)
|
|
25
38
|
|
|
26
39
|
override fun getName(): String {
|
|
27
|
-
return
|
|
40
|
+
return NAME
|
|
28
41
|
}
|
|
29
42
|
|
|
30
43
|
// The native version string of the Android THEOplayer SDK.
|
|
@@ -240,7 +253,7 @@ class PlayerModule(context: ReactApplicationContext) : ReactContextBaseJavaModul
|
|
|
240
253
|
fun setTextTrackStyle(tag: Int, style: ReadableMap?) {
|
|
241
254
|
viewResolver.resolveViewByTag(tag) { view: ReactTHEOplayerView? ->
|
|
242
255
|
view?.player?.let { player ->
|
|
243
|
-
TextTrackStyleAdapter.applyTextTrackStyle(player.textTrackStyle, style)
|
|
256
|
+
TextTrackStyleAdapter.applyTextTrackStyle(player.textTrackStyle, reactApplicationContext, style)
|
|
244
257
|
}
|
|
245
258
|
}
|
|
246
259
|
}
|
|
@@ -22,6 +22,7 @@ import com.facebook.react.views.view.ReactViewGroup
|
|
|
22
22
|
import com.theoplayer.BuildConfig
|
|
23
23
|
import com.theoplayer.PlayerEventEmitter
|
|
24
24
|
import com.theoplayer.ReactTHEOplayerContext
|
|
25
|
+
import com.theoplayer.ReactTHEOplayerView
|
|
25
26
|
import com.theoplayer.android.api.error.ErrorCode
|
|
26
27
|
import com.theoplayer.android.api.error.THEOplayerException
|
|
27
28
|
import com.theoplayer.android.api.player.PresentationMode
|
|
@@ -111,9 +112,9 @@ class PresentationManager(
|
|
|
111
112
|
fun destroy() {
|
|
112
113
|
try {
|
|
113
114
|
reactContext.currentActivity?.let { activity ->
|
|
114
|
-
activity.unregisterReceiver(
|
|
115
|
-
(activity as? ComponentActivity)?.
|
|
116
|
-
activity.unregisterReceiver(
|
|
115
|
+
onUserLeaveHintReceiver?.let { activity.unregisterReceiver(it) }
|
|
116
|
+
(activity as? ComponentActivity)?.removeOnUserLeaveHintListener(onUserLeaveHintRunnable)
|
|
117
|
+
onPictureInPictureModeChanged?.let { activity.unregisterReceiver(it) }
|
|
117
118
|
}
|
|
118
119
|
|
|
119
120
|
fullScreenLayoutObserver.remove()
|
|
@@ -161,11 +162,18 @@ class PresentationManager(
|
|
|
161
162
|
}
|
|
162
163
|
}
|
|
163
164
|
|
|
165
|
+
private fun setPlayerSiblingsVisibility(visible: Boolean) = reactPlayerGroup?.children?.forEach {
|
|
166
|
+
if (it !is ReactTHEOplayerView) {
|
|
167
|
+
it.visibility = if (visible) View.VISIBLE else View.INVISIBLE
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
|
|
164
171
|
/**
|
|
165
172
|
* Called when the transition into PiP either starts (transitioningToPip = true)
|
|
166
173
|
* or after it ends (transitioningToPip = false)
|
|
167
174
|
*/
|
|
168
175
|
private fun onEnterPip(transitioningToPip: Boolean = false) {
|
|
176
|
+
setPlayerSiblingsVisibility(false)
|
|
169
177
|
if (BuildConfig.REPARENT_ON_PIP && !transitioningToPip && pipConfig.reparentPip == true) {
|
|
170
178
|
reparentPlayerToRoot()
|
|
171
179
|
}
|
|
@@ -181,6 +189,7 @@ class PresentationManager(
|
|
|
181
189
|
* Called when the PiP exit transition starts.
|
|
182
190
|
*/
|
|
183
191
|
private fun onExitPip() {
|
|
192
|
+
setPlayerSiblingsVisibility(true)
|
|
184
193
|
val pipCtx: PresentationModeChangePipContext =
|
|
185
194
|
if ((reactContext.currentActivity as? ComponentActivity)?.lifecycle?.currentState == Lifecycle.State.CREATED) {
|
|
186
195
|
PresentationModeChangePipContext.CLOSED
|
|
@@ -23,7 +23,6 @@ import com.theoplayer.android.api.ads.theoads.TheoAdsLayoutOverride
|
|
|
23
23
|
import com.theoplayer.android.api.cmcd.CMCDTransmissionMode
|
|
24
24
|
import com.theoplayer.android.api.error.ErrorCode
|
|
25
25
|
import com.theoplayer.android.api.source.AdIntegration
|
|
26
|
-
import com.theoplayer.android.api.source.PlaybackPipeline
|
|
27
26
|
import com.theoplayer.android.api.source.dash.DashPlaybackConfiguration
|
|
28
27
|
import com.theoplayer.android.api.theolive.TheoLiveSource
|
|
29
28
|
import com.theoplayer.cmcd.CmcdTransmissionMode
|
|
@@ -71,7 +70,6 @@ private const val PROP_RETRIEVE_POD_ID_URI = "retrievePodIdURI"
|
|
|
71
70
|
private const val PROP_INITIALIZATION_DELAY = "initializationDelay"
|
|
72
71
|
private const val PROP_SSE_ENDPOINT = "sseEndpoint"
|
|
73
72
|
private const val PROP_LATENCY_CONFIGURATION = "latencyConfiguration"
|
|
74
|
-
private const val PROP_PLAYBACK_PIPELINE = "playbackPipeline"
|
|
75
73
|
|
|
76
74
|
private const val ERROR_IMA_NOT_ENABLED = "Google IMA support not enabled."
|
|
77
75
|
private const val ERROR_THEOADS_NOT_ENABLED = "THEOads support not enabled."
|
|
@@ -82,7 +80,6 @@ private const val PROP_SSAI_INTEGRATION_GOOGLE_DAI = "google-dai"
|
|
|
82
80
|
|
|
83
81
|
private const val TYPE_THEOLIVE = "theolive"
|
|
84
82
|
private const val TYPE_MILLICAST = "millicast"
|
|
85
|
-
private const val PLAYBACK_PIPELINE_LEGACY = "legacy"
|
|
86
83
|
|
|
87
84
|
private const val PROP_CMCD = "cmcd"
|
|
88
85
|
private const val CMCD_TRANSMISSION_MODE = "transmissionMode"
|
|
@@ -239,12 +236,6 @@ class SourceAdapter {
|
|
|
239
236
|
tsBuilder.drm(drmConfig)
|
|
240
237
|
}
|
|
241
238
|
}
|
|
242
|
-
if (jsonTypedSource.has(PROP_PLAYBACK_PIPELINE)) {
|
|
243
|
-
tsBuilder.playbackPipeline(when(jsonTypedSource.getString(PROP_PLAYBACK_PIPELINE)) {
|
|
244
|
-
PLAYBACK_PIPELINE_LEGACY -> PlaybackPipeline.LEGACY
|
|
245
|
-
else -> PlaybackPipeline.MEDIA3
|
|
246
|
-
})
|
|
247
|
-
}
|
|
248
239
|
if (cmcdTransmissionMode != null) {
|
|
249
240
|
tsBuilder.cmcdTransmissionMode(cmcdTransmissionMode)
|
|
250
241
|
}
|
|
@@ -261,8 +252,7 @@ class SourceAdapter {
|
|
|
261
252
|
@Throws(THEOplayerException::class)
|
|
262
253
|
fun parseAdFromJS(map: ReadableMap): AdDescription? {
|
|
263
254
|
return try {
|
|
264
|
-
|
|
265
|
-
parseAdFromJS(jsonAdDescription)
|
|
255
|
+
parseAdFromJS(JSONObject(gson.toJson(map.toHashMap())))
|
|
266
256
|
} catch (e: JSONException) {
|
|
267
257
|
e.printStackTrace()
|
|
268
258
|
null
|
|
@@ -293,12 +283,8 @@ class SourceAdapter {
|
|
|
293
283
|
val integrationStr = jsonAdDescription.optString(PROP_INTEGRATION)
|
|
294
284
|
return if (!TextUtils.isEmpty(integrationStr)) {
|
|
295
285
|
when (integrationStr) {
|
|
296
|
-
AdIntegration.GOOGLE_IMA.adIntegration -> parseImaAdFromJS(
|
|
297
|
-
|
|
298
|
-
)
|
|
299
|
-
AdIntegration.THEO_ADS.adIntegration -> parseTheoAdFromJS(
|
|
300
|
-
jsonAdDescription
|
|
301
|
-
)
|
|
286
|
+
AdIntegration.GOOGLE_IMA.adIntegration -> parseImaAdFromJS(jsonAdDescription)
|
|
287
|
+
AdIntegration.THEO_ADS.adIntegration -> parseTheoAdFromJS(jsonAdDescription)
|
|
302
288
|
else -> {
|
|
303
289
|
throw THEOplayerException(
|
|
304
290
|
ErrorCode.AD_ERROR,
|
|
@@ -357,40 +343,33 @@ class SourceAdapter {
|
|
|
357
343
|
?.toMap() ?: emptyMap()
|
|
358
344
|
|
|
359
345
|
private fun parseOverrideLayout(override: String?): TheoAdsLayoutOverride? {
|
|
360
|
-
|
|
361
|
-
return
|
|
362
|
-
}
|
|
363
|
-
when (override) {
|
|
364
|
-
"single" -> return TheoAdsLayoutOverride.SINGLE
|
|
365
|
-
"single-if-mobile" -> return TheoAdsLayoutOverride.SINGLE
|
|
346
|
+
return when (override) {
|
|
347
|
+
"single", "single-if-mobile" -> return TheoAdsLayoutOverride.SINGLE
|
|
366
348
|
"l-shape" -> return TheoAdsLayoutOverride.LSHAPE
|
|
367
349
|
"double" -> return TheoAdsLayoutOverride.DOUBLE
|
|
350
|
+
else -> null
|
|
368
351
|
}
|
|
369
|
-
return null
|
|
370
352
|
}
|
|
371
353
|
|
|
372
354
|
@Throws(JSONException::class)
|
|
373
355
|
private fun parseTextTrackFromJS(jsonTextTrack: JSONObject): TextTrackDescription {
|
|
374
|
-
|
|
356
|
+
return TextTrackDescription.Builder(jsonTextTrack.optString(PROP_SRC))
|
|
375
357
|
.isDefault(jsonTextTrack.optBoolean(PROP_DEFAULT))
|
|
376
358
|
.label(jsonTextTrack.optString(PROP_LABEL))
|
|
377
359
|
.srclang(jsonTextTrack.optString(PROP_SRCLANG))
|
|
378
360
|
.kind(parseTextTrackKind(jsonTextTrack.optString(PROP_KIND))!!)
|
|
379
|
-
|
|
361
|
+
.build()
|
|
380
362
|
}
|
|
381
363
|
|
|
382
364
|
private fun parseTextTrackKind(kind: String?): TextTrackKind? {
|
|
383
|
-
|
|
384
|
-
return null
|
|
385
|
-
}
|
|
386
|
-
when (kind) {
|
|
365
|
+
return when (kind) {
|
|
387
366
|
"subtitles" -> return TextTrackKind.SUBTITLES
|
|
388
367
|
"metadata" -> return TextTrackKind.METADATA
|
|
389
368
|
"captions" -> return TextTrackKind.CAPTIONS
|
|
390
369
|
"chapters" -> return TextTrackKind.CHAPTERS
|
|
391
370
|
"descriptions" -> return TextTrackKind.DESCRIPTIONS
|
|
371
|
+
else -> null
|
|
392
372
|
}
|
|
393
|
-
return null
|
|
394
373
|
}
|
|
395
374
|
|
|
396
375
|
private fun parseMetadataDescription(metadataDescription: JSONObject): MetadataDescription {
|
|
@@ -404,7 +383,7 @@ class SourceAdapter {
|
|
|
404
383
|
} else {
|
|
405
384
|
metadata[key] = metadataDescription[key]
|
|
406
385
|
}
|
|
407
|
-
} catch (
|
|
386
|
+
} catch (_: JSONException) {
|
|
408
387
|
Log.w(TAG, "Failed to parse metadata key $key")
|
|
409
388
|
}
|
|
410
389
|
}
|
|
@@ -419,11 +398,11 @@ class SourceAdapter {
|
|
|
419
398
|
|
|
420
399
|
@Throws(JSONException::class)
|
|
421
400
|
private fun parseMetadataImages(metadataImages: JSONArray): List<ChromecastMetadataImage> {
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
401
|
+
return mutableListOf<ChromecastMetadataImage>().apply {
|
|
402
|
+
for (i in 0 until metadataImages.length()) {
|
|
403
|
+
add(parseMetadataImage(metadataImages.getJSONObject(i)))
|
|
404
|
+
}
|
|
425
405
|
}
|
|
426
|
-
return imageList
|
|
427
406
|
}
|
|
428
407
|
|
|
429
408
|
@Throws(JSONException::class)
|
|
@@ -448,7 +427,7 @@ class SourceAdapter {
|
|
|
448
427
|
private fun parseCmcdTransmissionMode(cmcdConfiguration : JSONObject) : CMCDTransmissionMode {
|
|
449
428
|
try {
|
|
450
429
|
val transmissionMode = cmcdConfiguration.optInt(CMCD_TRANSMISSION_MODE)
|
|
451
|
-
if (transmissionMode
|
|
430
|
+
if (transmissionMode == CmcdTransmissionMode.QUERY_ARGUMENT.ordinal) {
|
|
452
431
|
return CMCDTransmissionMode.QUERY_ARGUMENT
|
|
453
432
|
}
|
|
454
433
|
return CMCDTransmissionMode.HTTP_HEADER
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
package com.theoplayer.theoads
|
|
2
|
+
|
|
3
|
+
import com.facebook.react.bridge.Arguments
|
|
4
|
+
import com.facebook.react.bridge.WritableArray
|
|
5
|
+
import com.facebook.react.bridge.WritableMap
|
|
6
|
+
import com.theoplayer.ads.AdAdapter.fromAds
|
|
7
|
+
import com.theoplayer.android.api.ads.theoads.AdBreakInterstitial
|
|
8
|
+
import com.theoplayer.android.api.ads.theoads.Interstitial
|
|
9
|
+
import com.theoplayer.android.api.ads.theoads.InterstitialType
|
|
10
|
+
import com.theoplayer.android.api.ads.theoads.OverlayInterstitial
|
|
11
|
+
import com.theoplayer.android.api.ads.theoads.OverlayPosition
|
|
12
|
+
import com.theoplayer.android.api.ads.theoads.OverlaySize
|
|
13
|
+
import com.theoplayer.android.api.ads.theoads.TheoAdsLayout
|
|
14
|
+
|
|
15
|
+
private const val PROP_ID = "id"
|
|
16
|
+
private const val PROP_TYPE = "TYPE"
|
|
17
|
+
private const val PROP_START_TIME = "startTime"
|
|
18
|
+
private const val PROP_DURATION = "duration"
|
|
19
|
+
private const val PROP_BACKDROP_URI = "backdropUri"
|
|
20
|
+
private const val PROP_LAYOUT = "layout"
|
|
21
|
+
private const val PROP_ADS = "ads"
|
|
22
|
+
private const val PROP_IMAGE_URL = "imageUrl"
|
|
23
|
+
private const val PROP_CLICK_THROUGH = "clickThrough"
|
|
24
|
+
private const val PROP_POSITION = "position"
|
|
25
|
+
private const val PROP_SIZE = "size"
|
|
26
|
+
private const val PROP_TOP = "top"
|
|
27
|
+
private const val PROP_LEFT = "left"
|
|
28
|
+
private const val PROP_RIGHT = "right"
|
|
29
|
+
private const val PROP_BOTTOM = "bottom"
|
|
30
|
+
private const val PROP_WIDTH = "width"
|
|
31
|
+
private const val PROP_HEIGHT = "height"
|
|
32
|
+
|
|
33
|
+
object THEOadsAdapter {
|
|
34
|
+
|
|
35
|
+
fun fromInterstitialList(interstitial: List<Interstitial>?): WritableArray {
|
|
36
|
+
return Arguments.createArray().apply { interstitial?.forEach { pushMap(fromInterstitial(it)) } }
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
fun fromInterstitial(interstitial: Interstitial): WritableMap {
|
|
40
|
+
return Arguments.createMap().apply {
|
|
41
|
+
putString(PROP_ID, interstitial.id)
|
|
42
|
+
putString(PROP_TYPE, when (interstitial.type) {
|
|
43
|
+
InterstitialType.ADBREAK -> "adbreak"
|
|
44
|
+
InterstitialType.OVERLAY -> "overlay"
|
|
45
|
+
})
|
|
46
|
+
putDouble(PROP_START_TIME, interstitial.startTime)
|
|
47
|
+
interstitial.duration?.let { it -> putDouble(PROP_DURATION, it) }
|
|
48
|
+
|
|
49
|
+
(interstitial as? AdBreakInterstitial)?.let {
|
|
50
|
+
interstitial.backdropUri?.let { it -> putString(PROP_BACKDROP_URI, it) }
|
|
51
|
+
putString(PROP_LAYOUT, when (interstitial.layout) {
|
|
52
|
+
TheoAdsLayout.SINGLE -> "single"
|
|
53
|
+
TheoAdsLayout.L_SHAPE -> "l-shape"
|
|
54
|
+
else /*TheoAdsLayout.DOUBLE*/ -> "double"
|
|
55
|
+
})
|
|
56
|
+
putArray(PROP_ADS, fromAds(interstitial.ads))
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
(interstitial as? OverlayInterstitial)?.let {
|
|
60
|
+
interstitial.imageUrl?.let { it -> putString(PROP_IMAGE_URL, it) }
|
|
61
|
+
interstitial.clickThrough?.let { it -> putString(PROP_CLICK_THROUGH, it) }
|
|
62
|
+
putMap(PROP_POSITION, fromOverlayPosition(interstitial.position))
|
|
63
|
+
putMap(PROP_SIZE, fromOverlaySize(interstitial.size))
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
fun fromOverlayPosition(position: OverlayPosition): WritableMap {
|
|
69
|
+
return Arguments.createMap().apply {
|
|
70
|
+
putDouble(PROP_TOP, position.top)
|
|
71
|
+
putDouble(PROP_RIGHT, position.right)
|
|
72
|
+
putDouble(PROP_LEFT, position.left)
|
|
73
|
+
putDouble(PROP_BOTTOM, position.bottom)
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
fun fromOverlaySize(size: OverlaySize): WritableMap {
|
|
78
|
+
return Arguments.createMap().apply {
|
|
79
|
+
putDouble(PROP_WIDTH, size.width)
|
|
80
|
+
putDouble(PROP_HEIGHT, size.height)
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
package com.theoplayer.theoads
|
|
2
|
+
|
|
3
|
+
import com.facebook.react.bridge.Arguments
|
|
4
|
+
import com.facebook.react.bridge.WritableMap
|
|
5
|
+
import com.theoplayer.android.api.ads.theoads.TheoAdsIntegration
|
|
6
|
+
import com.theoplayer.android.api.ads.theoads.event.InterstitialErrorEvent
|
|
7
|
+
import com.theoplayer.android.api.ads.theoads.event.InterstitialEvent
|
|
8
|
+
import com.theoplayer.android.api.ads.theoads.event.TheoAdsErrorEvent
|
|
9
|
+
import com.theoplayer.android.api.ads.theoads.event.TheoAdsEvent
|
|
10
|
+
import com.theoplayer.android.api.ads.theoads.event.TheoAdsEventTypes
|
|
11
|
+
import com.theoplayer.android.api.event.EventListener
|
|
12
|
+
|
|
13
|
+
private const val EVENT_PROP_TYPE = "type"
|
|
14
|
+
private const val EVENT_PROP_INTERSTITIAL = "interstitial"
|
|
15
|
+
private const val EVENT_PROP_MESSAGE = "message"
|
|
16
|
+
|
|
17
|
+
private val FORWARDED_EVENTS = listOf(
|
|
18
|
+
TheoAdsEventTypes.ADD_INTERSTITIAL,
|
|
19
|
+
TheoAdsEventTypes.INTERSTITIAL_BEGIN,
|
|
20
|
+
TheoAdsEventTypes.INTERSTITIAL_END,
|
|
21
|
+
TheoAdsEventTypes.INTERSTITIAL_UPDATE,
|
|
22
|
+
TheoAdsEventTypes.INTERSTITIAL_ERROR,
|
|
23
|
+
TheoAdsEventTypes.THEOADS_ERROR
|
|
24
|
+
)
|
|
25
|
+
|
|
26
|
+
class THEOadsEventAdapter(private val api: TheoAdsIntegration, private val emitter: Emitter) {
|
|
27
|
+
interface Emitter {
|
|
28
|
+
fun emit(payload: WritableMap?)
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
private val onEvent = EventListener<TheoAdsEvent<*>> { handleEvent(it) }
|
|
32
|
+
|
|
33
|
+
init {
|
|
34
|
+
FORWARDED_EVENTS.forEach { api.addEventListener(it, onEvent) }
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
fun destroy() {
|
|
38
|
+
FORWARDED_EVENTS.forEach { api.removeEventListener(it, onEvent) }
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
private fun handleEvent(event: TheoAdsEvent<*>) {
|
|
42
|
+
emitter.emit(Arguments.createMap().apply {
|
|
43
|
+
putString(EVENT_PROP_TYPE, event.type.name)
|
|
44
|
+
(event as? InterstitialEvent)?.let {
|
|
45
|
+
putMap(EVENT_PROP_INTERSTITIAL, THEOadsAdapter.fromInterstitial(event.interstitial))
|
|
46
|
+
}
|
|
47
|
+
(event as? TheoAdsErrorEvent)?.let {
|
|
48
|
+
putString(EVENT_PROP_MESSAGE, event.message)
|
|
49
|
+
}
|
|
50
|
+
(event as? InterstitialErrorEvent)?.let {
|
|
51
|
+
putString(EVENT_PROP_MESSAGE, event.message)
|
|
52
|
+
}
|
|
53
|
+
})
|
|
54
|
+
}
|
|
55
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
package com.theoplayer.theoads
|
|
2
|
+
|
|
3
|
+
import com.facebook.react.bridge.*
|
|
4
|
+
import com.facebook.react.module.annotations.ReactModule
|
|
5
|
+
import com.facebook.react.module.model.ReactModuleInfo
|
|
6
|
+
import com.theoplayer.*
|
|
7
|
+
import com.theoplayer.android.api.ads.theoads.theoAds
|
|
8
|
+
import com.theoplayer.theoads.THEOadsAdapter.fromInterstitialList
|
|
9
|
+
import com.theoplayer.util.ViewResolver
|
|
10
|
+
|
|
11
|
+
@Suppress("unused")
|
|
12
|
+
@ReactModule(name = THEOadsModule.NAME)
|
|
13
|
+
class THEOadsModule(context: ReactApplicationContext) : ReactContextBaseJavaModule(context) {
|
|
14
|
+
companion object {
|
|
15
|
+
const val NAME = "THEORCTTHEOAdsModule"
|
|
16
|
+
val INFO = ReactModuleInfo(
|
|
17
|
+
name = NAME,
|
|
18
|
+
className = NAME,
|
|
19
|
+
canOverrideExistingModule = false,
|
|
20
|
+
needsEagerInit = false,
|
|
21
|
+
isCxxModule = false,
|
|
22
|
+
isTurboModule = false,
|
|
23
|
+
)
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
private val viewResolver: ViewResolver = ViewResolver(context)
|
|
27
|
+
|
|
28
|
+
override fun getName(): String {
|
|
29
|
+
return NAME
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
@ReactMethod
|
|
33
|
+
fun currentInterstitials(tag: Int, promise: Promise) {
|
|
34
|
+
viewResolver.resolveViewByTag(tag) { view: ReactTHEOplayerView? ->
|
|
35
|
+
if (BuildConfig.EXTENSION_THEOADS) {
|
|
36
|
+
promise.resolve(fromInterstitialList(view?.player?.theoAds?.currentInterstitials))
|
|
37
|
+
} else {
|
|
38
|
+
promise.resolve(Arguments.createArray())
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
@ReactMethod
|
|
44
|
+
fun scheduledInterstitials(tag: Int, promise: Promise) {
|
|
45
|
+
viewResolver.resolveViewByTag(tag) { view: ReactTHEOplayerView? ->
|
|
46
|
+
if (BuildConfig.EXTENSION_THEOADS) {
|
|
47
|
+
promise.resolve(fromInterstitialList(view?.player?.theoAds?.scheduledInterstitials))
|
|
48
|
+
} else {
|
|
49
|
+
promise.resolve(Arguments.createArray())
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
@ReactMethod
|
|
55
|
+
fun replaceAdTagParameters(tag: Int, adTagParameters: ReadableMap) {
|
|
56
|
+
viewResolver.resolveViewByTag(tag) { view: ReactTHEOplayerView? ->
|
|
57
|
+
if (BuildConfig.EXTENSION_THEOADS) {
|
|
58
|
+
view?.player?.theoAds?.replaceAdTagParameters(
|
|
59
|
+
adTagParameters.toHashMap().mapValues { it.value.toString() })
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|