react-native-theoplayer 10.0.0 → 10.2.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 +31 -0
- package/android/build.gradle +5 -6
- package/android/src/main/AndroidManifest.xml +1 -1
- package/android/src/main/java/com/theoplayer/PlayerEventEmitter.kt +21 -9
- package/android/src/main/java/com/theoplayer/cache/CacheModule.kt +8 -9
- package/android/src/main/java/com/theoplayer/cast/CastEventAdapter.kt +11 -7
- package/android/src/main/java/com/theoplayer/media/ConditionalMediaButtonReceiver.kt +38 -0
- package/android/src/main/java/com/theoplayer/player/PlayerModule.kt +1 -1
- package/android/src/main/java/com/theoplayer/source/SourceAdapter.kt +1 -1
- package/android/src/main/java/com/theoplayer/theoads/THEOadsAdapter.kt +10 -1
- package/android/src/main/java/com/theoplayer/theoads/THEOadsEventAdapter.kt +6 -3
- package/android/src/main/java/com/theoplayer/theoads/THEOadsModule.kt +14 -0
- package/android/src/main/java/com/theoplayer/theolive/THEOliveEventAdapter.kt +21 -8
- package/android/src/main/java/com/theoplayer/theolive/THEOliveModule.kt +1 -1
- 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 +8 -1
- package/ios/THEOplayerRCTMainEventHandler.swift +24 -21
- package/ios/THEOplayerRCTPlayerAPI.swift +9 -0
- package/ios/THEOplayerRCTView.swift +19 -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 +26 -8
- package/ios/theoAds/THEOplayerRCTTHEOAdsAPI.swift +19 -0
- package/ios/theoAds/THEOplayerRCTTHEOAdsEventAdapter.swift +4 -2
- package/lib/commonjs/api/cache/hooks/useCachingTaskList.js +1 -1
- package/lib/commonjs/api/cache/hooks/useCachingTaskList.js.map +1 -1
- package/lib/commonjs/api/cache/hooks/useCachingTaskProgress.js +1 -1
- package/lib/commonjs/api/cache/hooks/useCachingTaskProgress.js.map +1 -1
- package/lib/commonjs/api/cache/hooks/useCachingTaskStatus.js +1 -1
- package/lib/commonjs/api/cache/hooks/useCachingTaskStatus.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/player/PlayerEventMap.js +2 -0
- package/lib/commonjs/api/player/PlayerEventMap.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/internal/THEOplayerView.js +14 -4
- package/lib/commonjs/internal/THEOplayerView.js.map +1 -1
- package/lib/commonjs/internal/THEOplayerView.web.js +6 -7
- 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 +35 -9
- package/lib/commonjs/internal/adapter/THEOplayerAdapter.js.map +1 -1
- package/lib/commonjs/internal/adapter/THEOplayerWebAdapter.js +21 -1
- package/lib/commonjs/internal/adapter/THEOplayerWebAdapter.js.map +1 -1
- package/lib/commonjs/internal/adapter/WebEventForwarder.js +7 -0
- package/lib/commonjs/internal/adapter/WebEventForwarder.js.map +1 -1
- package/lib/commonjs/internal/adapter/event/PlayerEvents.js +21 -1
- package/lib/commonjs/internal/adapter/event/PlayerEvents.js.map +1 -1
- package/lib/commonjs/internal/adapter/event/native/NativeTheoAdsEvent.js +4 -3
- package/lib/commonjs/internal/adapter/event/native/NativeTheoAdsEvent.js.map +1 -1
- package/lib/commonjs/internal/adapter/theoads/NativeInterstitialAdapter.js +68 -0
- package/lib/commonjs/internal/adapter/theoads/NativeInterstitialAdapter.js.map +1 -0
- package/lib/commonjs/internal/adapter/theoads/THEOAdsNativeAdapter.js +11 -2
- package/lib/commonjs/internal/adapter/theoads/THEOAdsNativeAdapter.js.map +1 -1
- package/lib/commonjs/internal/adapter/theolive/TheoLiveNativeAdapter.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/cache/hooks/useCachingTaskList.js +1 -1
- package/lib/module/api/cache/hooks/useCachingTaskList.js.map +1 -1
- package/lib/module/api/cache/hooks/useCachingTaskProgress.js +1 -1
- package/lib/module/api/cache/hooks/useCachingTaskProgress.js.map +1 -1
- package/lib/module/api/cache/hooks/useCachingTaskStatus.js +1 -1
- package/lib/module/api/cache/hooks/useCachingTaskStatus.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/player/PlayerEventMap.js +2 -0
- package/lib/module/api/player/PlayerEventMap.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/internal/THEOplayerView.js +15 -5
- package/lib/module/internal/THEOplayerView.js.map +1 -1
- package/lib/module/internal/THEOplayerView.web.js +6 -7
- 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 +36 -10
- package/lib/module/internal/adapter/THEOplayerAdapter.js.map +1 -1
- package/lib/module/internal/adapter/THEOplayerWebAdapter.js +21 -1
- package/lib/module/internal/adapter/THEOplayerWebAdapter.js.map +1 -1
- package/lib/module/internal/adapter/WebEventForwarder.js +8 -1
- package/lib/module/internal/adapter/WebEventForwarder.js.map +1 -1
- package/lib/module/internal/adapter/event/PlayerEvents.js +18 -0
- package/lib/module/internal/adapter/event/PlayerEvents.js.map +1 -1
- package/lib/module/internal/adapter/event/native/NativeTheoAdsEvent.js +4 -3
- package/lib/module/internal/adapter/event/native/NativeTheoAdsEvent.js.map +1 -1
- package/lib/module/internal/adapter/theoads/NativeInterstitialAdapter.js +61 -0
- package/lib/module/internal/adapter/theoads/NativeInterstitialAdapter.js.map +1 -0
- package/lib/module/internal/adapter/theoads/THEOAdsNativeAdapter.js +11 -2
- package/lib/module/internal/adapter/theoads/THEOAdsNativeAdapter.js.map +1 -1
- package/lib/module/internal/adapter/theolive/TheoLiveNativeAdapter.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/event/PlayerEvent.d.ts +36 -0
- package/lib/typescript/api/event/PlayerEvent.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 +15 -1
- package/lib/typescript/api/player/THEOplayer.d.ts.map +1 -1
- package/lib/typescript/api/theoads/interstitial/Interstitial.d.ts +6 -0
- package/lib/typescript/api/theoads/interstitial/Interstitial.d.ts.map +1 -1
- package/lib/typescript/api/theolive/TheoLiveAPI.d.ts +1 -1
- package/lib/typescript/api/theolive/TheoLiveConfiguration.d.ts +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/internal/THEOplayerView.d.ts +2 -1
- package/lib/typescript/internal/THEOplayerView.d.ts.map +1 -1
- package/lib/typescript/internal/THEOplayerView.web.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 +7 -3
- package/lib/typescript/internal/adapter/THEOplayerAdapter.d.ts.map +1 -1
- package/lib/typescript/internal/adapter/THEOplayerWebAdapter.d.ts +6 -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 +14 -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 +1 -1
- package/lib/typescript/internal/adapter/event/native/NativeTheoAdsEvent.d.ts.map +1 -1
- package/lib/typescript/internal/adapter/theoads/NativeInterstitialAdapter.d.ts +31 -0
- package/lib/typescript/internal/adapter/theoads/NativeInterstitialAdapter.d.ts.map +1 -0
- package/lib/typescript/internal/adapter/theoads/THEOAdsNativeAdapter.d.ts +3 -1
- package/lib/typescript/internal/adapter/theoads/THEOAdsNativeAdapter.d.ts.map +1 -1
- package/lib/typescript/internal/adapter/theoads/THEOAdsWebAdapter.d.ts +1 -1
- package/lib/typescript/internal/adapter/theoads/THEOAdsWebAdapter.d.ts.map +1 -1
- package/lib/typescript/internal/adapter/theolive/TheoLiveNativeAdapter.d.ts +1 -1
- package/lib/typescript/internal/adapter/theolive/TheoLiveNativeAdapter.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 +2 -1
- package/react-native-theoplayer.podspec +7 -7
- package/src/api/cache/hooks/useCachingTaskList.ts +1 -1
- package/src/api/cache/hooks/useCachingTaskProgress.ts +1 -1
- package/src/api/cache/hooks/useCachingTaskStatus.ts +1 -1
- package/src/api/event/PlayerEvent.ts +40 -0
- package/src/api/player/PlayerEventMap.ts +19 -0
- package/src/api/player/THEOplayer.ts +18 -1
- package/src/api/theoads/interstitial/Interstitial.ts +7 -0
- package/src/api/theolive/TheoLiveAPI.ts +1 -1
- package/src/api/theolive/TheoLiveConfiguration.ts +1 -1
- package/src/api/track/Quality.ts +15 -0
- package/src/api/track/TextTrackStyle.ts +8 -0
- package/src/internal/THEOplayerView.tsx +21 -6
- package/src/internal/THEOplayerView.web.tsx +4 -5
- package/src/internal/adapter/DefaultNativePlayerState.ts +2 -0
- package/src/internal/adapter/NativePlayerState.ts +2 -0
- package/src/internal/adapter/THEOplayerAdapter.ts +53 -21
- package/src/internal/adapter/THEOplayerWebAdapter.ts +26 -2
- package/src/internal/adapter/WebEventForwarder.ts +10 -0
- package/src/internal/adapter/event/PlayerEvents.ts +23 -0
- package/src/internal/adapter/event/native/NativePlayerEvent.ts +13 -1
- package/src/internal/adapter/event/native/NativeTheoAdsEvent.ts +8 -3
- package/src/internal/adapter/theoads/NativeInterstitialAdapter.ts +93 -0
- package/src/internal/adapter/theoads/THEOAdsNativeAdapter.ts +14 -3
- package/src/internal/adapter/theoads/THEOAdsWebAdapter.ts +1 -1
- package/src/internal/adapter/theolive/TheoLiveNativeAdapter.ts +1 -1
- package/src/internal/adapter/track/TextTrackStyleAdapter.ts +12 -0
- package/src/internal/utils/TypeUtils.ts +6 -0
- package/src/manifest.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,37 @@ All notable changes to this project will be documented in this file.
|
|
|
5
5
|
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.1.0/)
|
|
6
6
|
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
+
## [10.2.0] - 25-10-20
|
|
9
|
+
|
|
10
|
+
### Fixed
|
|
11
|
+
|
|
12
|
+
- Fixed an issue on iOS where the player crashed when it was destroyed while in fullscreen.
|
|
13
|
+
- Fixed an issue on Android where creating a caching task with `MediaCache.createTask` would not return the created `task`.
|
|
14
|
+
- Fixed an issue where setting `player.theoLive.authToken = undefined` would cause a crash on Android.
|
|
15
|
+
|
|
16
|
+
### Changed
|
|
17
|
+
|
|
18
|
+
- Added `THEOplayer.theoLive` and deprecated `THEOplayer.theolive`, to be consistent with the THEOplayer SDKs for other platforms.
|
|
19
|
+
|
|
20
|
+
## [10.1.0] - 25-10-06
|
|
21
|
+
|
|
22
|
+
### Added
|
|
23
|
+
|
|
24
|
+
- Added an explicit clearing of the NowPlayingInfo on iOS, when the app receives a `willTerminateNotification`, to make sure all NowPlayingInfo is removed from the lock screen when an app is closed.
|
|
25
|
+
- Added `videoWidth` and `videoHeight` properties to `THEOplayer` containing the active video's resolution in pixels.
|
|
26
|
+
- Added `videoresize` player event enabling monitoring of video rendition resizes.
|
|
27
|
+
- Added `dimensionchange` player event enabling monitoring of player resizes. This event is set to replace the now deprecated `resize` player event.
|
|
28
|
+
- Added `fontPath` to `TextTrackStyle` to allow loading custom fonts from the Android assets folder.
|
|
29
|
+
|
|
30
|
+
### Fixed
|
|
31
|
+
|
|
32
|
+
- Fixed an issue on Android where play-out of Millicast sources in the example app would fail. The Android NDK version needs to be at least v28.
|
|
33
|
+
- Fixed an issue on Web where on older devices the `display: contents` style property is sometimes not supported.
|
|
34
|
+
- Fixed an issue on Android where the `MediaPlaybackService` could be restarted after the app was closed, in some cases causing a `ForegroundServiceDidNotStartInTimeException`. A conditional receiver makes sure the service is never restarted.
|
|
35
|
+
- Fixed an issue on iOS where a setup with multiple players could cause a view index NSInternalInconsistencyException after moving players in and out of fullscreen.
|
|
36
|
+
- Fixed an issue on Android where some event listeners were not properly disposed of after destroying the player.
|
|
37
|
+
- Fixed an issue on Web where the `width` and `height` properties on `THEOplayer` would show the active video rendition's resolution width and height instead of the width and height of the video element.
|
|
38
|
+
|
|
8
39
|
## [10.0.0] - 25-09-15
|
|
9
40
|
|
|
10
41
|
### Added
|
package/android/build.gradle
CHANGED
|
@@ -43,12 +43,12 @@ def enabledMediaSession = safeExtGet("THEOplayer_extensionMediaSession", 'true')
|
|
|
43
43
|
def enabledMillicast = safeExtGet("THEOplayer_extensionMillicast", 'false').toBoolean()
|
|
44
44
|
|
|
45
45
|
android {
|
|
46
|
-
compileSdk safeExtGet('THEOplayer_compileSdkVersion',
|
|
46
|
+
compileSdk safeExtGet('THEOplayer_compileSdkVersion', 36)
|
|
47
47
|
namespace "com.theoplayer"
|
|
48
48
|
|
|
49
49
|
defaultConfig {
|
|
50
50
|
minSdkVersion safeExtGet('THEOplayer_minSdkVersion', 23)
|
|
51
|
-
targetSdkVersion safeExtGet('THEOplayer_targetSdkVersion',
|
|
51
|
+
targetSdkVersion safeExtGet('THEOplayer_targetSdkVersion', 36)
|
|
52
52
|
versionCode 1
|
|
53
53
|
versionName "1.0"
|
|
54
54
|
|
|
@@ -124,8 +124,8 @@ repositories {
|
|
|
124
124
|
mavenLocal()
|
|
125
125
|
}
|
|
126
126
|
|
|
127
|
-
// The minimum supported THEOplayer version is
|
|
128
|
-
def theoVersion = safeExtGet('THEOplayer_sdk', '[
|
|
127
|
+
// The minimum supported THEOplayer version is 10.0.1
|
|
128
|
+
def theoVersion = safeExtGet('THEOplayer_sdk', '[10.0.1, 11.0.0)')
|
|
129
129
|
def theoMediaSessionVersion = safeExtGet('THEOplayer_mediasession', '[8.0.0, 11.0.0)')
|
|
130
130
|
def theoAdsWrapperVersion = "10.0.0"
|
|
131
131
|
def coroutinesVersion = safeExtGet('coroutinesVersion', '1.10.2')
|
|
@@ -133,7 +133,6 @@ def appcompatVersion = safeExtGet('appcompatVersion', '1.7.1')
|
|
|
133
133
|
def corektxVersion = safeExtGet('corektxVersion', '1.16.0')
|
|
134
134
|
def gsonVersion = safeExtGet('gsonVersion', '2.13.1')
|
|
135
135
|
def activityktxVersion = safeExtGet('activityktxVersion', '1.10.1')
|
|
136
|
-
def millicastVersion = safeExtGet('millicastVersion', '2.5.0')
|
|
137
136
|
|
|
138
137
|
dependencies {
|
|
139
138
|
def addOptiViewIntegration = { enabled, notation, additional = null ->
|
|
@@ -169,5 +168,5 @@ dependencies {
|
|
|
169
168
|
addOptiViewIntegration(enabledGoogleDAI || enabledTHEOads, 'integration-ads-dai')
|
|
170
169
|
addOptiViewIntegration(enabledTHEOads, 'integration-ads-theoads')
|
|
171
170
|
addOptiViewIntegration(enabledCast, 'integration-cast')
|
|
172
|
-
addOptiViewIntegration(enabledMillicast, 'integration-millicast'
|
|
171
|
+
addOptiViewIntegration(enabledMillicast, 'integration-millicast')
|
|
173
172
|
}
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
</intent-filter>
|
|
42
42
|
</service>
|
|
43
43
|
|
|
44
|
-
<receiver android:name="
|
|
44
|
+
<receiver android:name=".media.ConditionalMediaButtonReceiver"
|
|
45
45
|
android:exported="false">
|
|
46
46
|
<intent-filter>
|
|
47
47
|
<action android:name="android.intent.action.MEDIA_BUTTON" />
|
|
@@ -82,7 +82,8 @@ private const val EVENT_THEOLIVE_EVENT = "onNativeTHEOliveEvent"
|
|
|
82
82
|
private const val EVENT_THEOADS_EVENT = "onNativeTHEOadsEvent"
|
|
83
83
|
private const val EVENT_PRESENTATIONMODECHANGE = "onNativePresentationModeChange"
|
|
84
84
|
private const val EVENT_VOLUMECHANGE = "onNativeVolumeChange"
|
|
85
|
-
private const val
|
|
85
|
+
private const val EVENT_DIMENSIONCHANGE = "onNativeDimensionChange"
|
|
86
|
+
private const val EVENT_VIDEORESIZE = "onNativeVideoResize"
|
|
86
87
|
|
|
87
88
|
private const val EVENT_PROP_TYPE = "type"
|
|
88
89
|
private const val EVENT_PROP_STATE = "state"
|
|
@@ -126,7 +127,8 @@ class PlayerEventEmitter internal constructor(
|
|
|
126
127
|
EVENT_THEOADS_EVENT,
|
|
127
128
|
EVENT_PRESENTATIONMODECHANGE,
|
|
128
129
|
EVENT_VOLUMECHANGE,
|
|
129
|
-
|
|
130
|
+
EVENT_DIMENSIONCHANGE,
|
|
131
|
+
EVENT_VIDEORESIZE
|
|
130
132
|
)
|
|
131
133
|
annotation class VideoEvents
|
|
132
134
|
|
|
@@ -162,7 +164,8 @@ class PlayerEventEmitter internal constructor(
|
|
|
162
164
|
EVENT_THEOADS_EVENT,
|
|
163
165
|
EVENT_PRESENTATIONMODECHANGE,
|
|
164
166
|
EVENT_VOLUMECHANGE,
|
|
165
|
-
|
|
167
|
+
EVENT_DIMENSIONCHANGE,
|
|
168
|
+
EVENT_VIDEORESIZE
|
|
166
169
|
)
|
|
167
170
|
}
|
|
168
171
|
|
|
@@ -177,9 +180,9 @@ class PlayerEventEmitter internal constructor(
|
|
|
177
180
|
private var theoAdsEventAdapter: THEOadsEventAdapter? = null
|
|
178
181
|
private var lastTimeUpdate: Long = 0
|
|
179
182
|
private var lastCurrentTime = 0.0
|
|
180
|
-
private var
|
|
183
|
+
private var dimensionChangeListener = View.OnLayoutChangeListener { v, _, _, _, _, oldLeft, oldTop, oldRight, oldBottom ->
|
|
181
184
|
if (v.width != oldRight - oldLeft || v.height != oldBottom - oldTop) {
|
|
182
|
-
|
|
185
|
+
onDimensionChange(v.width, v.height)
|
|
183
186
|
}
|
|
184
187
|
}
|
|
185
188
|
|
|
@@ -233,6 +236,8 @@ class PlayerEventEmitter internal constructor(
|
|
|
233
236
|
EventListener { event: PresentationModeChange -> onPresentationModeChange(event) }
|
|
234
237
|
playerListeners[PlayerEventTypes.VOLUMECHANGE] =
|
|
235
238
|
EventListener { event: VolumeChangeEvent -> onVolumeChange(event) }
|
|
239
|
+
playerListeners[PlayerEventTypes.RESIZE] =
|
|
240
|
+
EventListener { event: ResizeEvent -> onResize(event) }
|
|
236
241
|
textTrackListeners[TextTrackListEventTypes.ADDTRACK] =
|
|
237
242
|
EventListener { event: AddTrackEvent -> onTextTrackAdd(event) }
|
|
238
243
|
textTrackListeners[TextTrackListEventTypes.REMOVETRACK] =
|
|
@@ -438,13 +443,20 @@ class PlayerEventEmitter internal constructor(
|
|
|
438
443
|
)
|
|
439
444
|
}
|
|
440
445
|
|
|
441
|
-
private fun
|
|
446
|
+
private fun onDimensionChange(width: Int, height: Int) {
|
|
442
447
|
receiveEvent(
|
|
443
|
-
|
|
448
|
+
EVENT_DIMENSIONCHANGE,
|
|
444
449
|
PayloadBuilder().size(width, height).build()
|
|
445
450
|
)
|
|
446
451
|
}
|
|
447
452
|
|
|
453
|
+
private fun onResize(event: ResizeEvent) {
|
|
454
|
+
receiveEvent(
|
|
455
|
+
EVENT_VIDEORESIZE,
|
|
456
|
+
PayloadBuilder().videoSize(event.width, event.height).build()
|
|
457
|
+
)
|
|
458
|
+
}
|
|
459
|
+
|
|
448
460
|
private val onTextTrackAddCue = EventListener<AddCueEvent> { event ->
|
|
449
461
|
val payload = PayloadBuilder().textTrackCue(event.cue, event.track).build().apply {
|
|
450
462
|
putInt(EVENT_PROP_TYPE, TextTrackCueEventType.ADD_CUE.type)
|
|
@@ -700,7 +712,7 @@ class PlayerEventEmitter internal constructor(
|
|
|
700
712
|
}
|
|
701
713
|
|
|
702
714
|
// Attach view size listener
|
|
703
|
-
playerView.addOnLayoutChangeListener(
|
|
715
|
+
playerView.addOnLayoutChangeListener(dimensionChangeListener)
|
|
704
716
|
}
|
|
705
717
|
|
|
706
718
|
fun removeListeners(player: Player?) {
|
|
@@ -737,7 +749,7 @@ class PlayerEventEmitter internal constructor(
|
|
|
737
749
|
}
|
|
738
750
|
|
|
739
751
|
// Remove view size listener
|
|
740
|
-
playerView.removeOnLayoutChangeListener(
|
|
752
|
+
playerView.removeOnLayoutChangeListener(dimensionChangeListener)
|
|
741
753
|
|
|
742
754
|
castEventAdapter?.destroy()
|
|
743
755
|
adEventAdapter?.destroy()
|
|
@@ -14,7 +14,6 @@ import com.facebook.react.module.annotations.ReactModule
|
|
|
14
14
|
import com.facebook.react.module.model.ReactModuleInfo
|
|
15
15
|
import com.facebook.react.modules.core.DeviceEventManagerModule
|
|
16
16
|
import com.google.gson.Gson
|
|
17
|
-
import com.theoplayer.ads.AdsModule
|
|
18
17
|
import com.theoplayer.util.ViewResolver
|
|
19
18
|
import com.theoplayer.android.api.THEOplayerGlobal
|
|
20
19
|
import com.theoplayer.android.api.cache.Cache
|
|
@@ -26,6 +25,7 @@ import com.theoplayer.android.api.event.cache.task.CachingTaskEventTypes
|
|
|
26
25
|
import com.theoplayer.android.api.event.cache.task.CachingTaskProgressEvent
|
|
27
26
|
import com.theoplayer.android.api.event.cache.task.CachingTaskStateChangeEvent
|
|
28
27
|
import com.theoplayer.android.api.event.cache.tasklist.CachingTaskListEventTypes
|
|
28
|
+
import com.theoplayer.cache.CacheAdapter.fromCachingTask
|
|
29
29
|
import com.theoplayer.drm.ContentProtectionAdapter
|
|
30
30
|
import com.theoplayer.source.SourceAdapter
|
|
31
31
|
import org.json.JSONException
|
|
@@ -78,7 +78,7 @@ class CacheModule(private val context: ReactApplicationContext) :
|
|
|
78
78
|
event.task?.let { task ->
|
|
79
79
|
// Notify AddCachingTaskEvent event
|
|
80
80
|
emit("onAddCachingTaskEvent", Arguments.createMap().apply {
|
|
81
|
-
putMap(PROP_TASK,
|
|
81
|
+
putMap(PROP_TASK, fromCachingTask(task))
|
|
82
82
|
})
|
|
83
83
|
// Add CachingTask listeners
|
|
84
84
|
addCachingTaskListeners(task)
|
|
@@ -90,7 +90,7 @@ class CacheModule(private val context: ReactApplicationContext) :
|
|
|
90
90
|
event.task?.let { task ->
|
|
91
91
|
// Notify RemoveCachingTaskEvent event
|
|
92
92
|
emit("onRemoveCachingTaskEvent", Arguments.createMap().apply {
|
|
93
|
-
putMap(PROP_TASK,
|
|
93
|
+
putMap(PROP_TASK, fromCachingTask(event.task))
|
|
94
94
|
})
|
|
95
95
|
// Remove CachingTask listeners
|
|
96
96
|
removeCachingTaskListeners(task)
|
|
@@ -184,16 +184,15 @@ class CacheModule(private val context: ReactApplicationContext) :
|
|
|
184
184
|
}
|
|
185
185
|
|
|
186
186
|
@ReactMethod
|
|
187
|
-
fun createTask(source: ReadableMap, parameters: ReadableMap) {
|
|
188
|
-
|
|
189
|
-
if (sourceDescription != null) {
|
|
187
|
+
fun createTask(source: ReadableMap, parameters: ReadableMap, promise: Promise) {
|
|
188
|
+
sourceAdapter.parseSourceFromJS(source)?.let { sourceDescription ->
|
|
190
189
|
handler.post {
|
|
191
|
-
cache.createTask(
|
|
190
|
+
promise.resolve(fromCachingTask(cache.createTask(
|
|
192
191
|
sourceDescription,
|
|
193
192
|
CacheAdapter.parseCachingParameters(parameters)
|
|
194
|
-
)
|
|
193
|
+
)))
|
|
195
194
|
}
|
|
196
|
-
}
|
|
195
|
+
} ?: promise.resolve(null)
|
|
197
196
|
}
|
|
198
197
|
|
|
199
198
|
@ReactMethod
|
|
@@ -6,6 +6,7 @@ import com.theoplayer.android.api.cast.Cast
|
|
|
6
6
|
import com.theoplayer.android.api.cast.chromecast.CastError
|
|
7
7
|
import com.theoplayer.android.api.cast.chromecast.ErrorCode
|
|
8
8
|
import com.theoplayer.android.api.cast.chromecast.PlayerCastState
|
|
9
|
+
import com.theoplayer.android.api.event.EventListener
|
|
9
10
|
import com.theoplayer.android.api.event.chromecast.CastErrorEvent
|
|
10
11
|
import com.theoplayer.android.api.event.chromecast.CastStateChangeEvent
|
|
11
12
|
import com.theoplayer.android.api.event.chromecast.ChromecastEventTypes
|
|
@@ -22,24 +23,27 @@ class CastEventAdapter(private val castApi: Cast, private val emitter: Emitter)
|
|
|
22
23
|
fun emit(payload: WritableMap?)
|
|
23
24
|
}
|
|
24
25
|
|
|
26
|
+
private val onCastError = EventListener<CastErrorEvent> { handleCastError(it) }
|
|
27
|
+
private val onStateChange = EventListener<CastStateChangeEvent> { handleStateChange(it) }
|
|
28
|
+
|
|
25
29
|
init {
|
|
26
|
-
castApi.chromecast.addEventListener(ChromecastEventTypes.ERROR,
|
|
27
|
-
castApi.chromecast.addEventListener(ChromecastEventTypes.STATECHANGE,
|
|
30
|
+
castApi.chromecast.addEventListener(ChromecastEventTypes.ERROR, onCastError)
|
|
31
|
+
castApi.chromecast.addEventListener(ChromecastEventTypes.STATECHANGE, onStateChange)
|
|
28
32
|
}
|
|
29
33
|
|
|
30
34
|
fun destroy() {
|
|
31
|
-
castApi.chromecast.removeEventListener(ChromecastEventTypes.ERROR,
|
|
32
|
-
castApi.chromecast.removeEventListener(ChromecastEventTypes.STATECHANGE,
|
|
35
|
+
castApi.chromecast.removeEventListener(ChromecastEventTypes.ERROR, onCastError)
|
|
36
|
+
castApi.chromecast.removeEventListener(ChromecastEventTypes.STATECHANGE, onStateChange)
|
|
33
37
|
}
|
|
34
38
|
|
|
35
|
-
private fun
|
|
39
|
+
private fun handleCastError(event: CastErrorEvent) {
|
|
36
40
|
val payload = Arguments.createMap()
|
|
37
41
|
payload.putString(EVENT_PROP_TYPE, "chromecasterror")
|
|
38
42
|
payload.putMap(EVENT_PROP_ERROR, serializeError(event.error))
|
|
39
43
|
emitter.emit(payload)
|
|
40
44
|
}
|
|
41
45
|
|
|
42
|
-
private fun serializeError(error: CastError): WritableMap
|
|
46
|
+
private fun serializeError(error: CastError): WritableMap {
|
|
43
47
|
val errorPayload = Arguments.createMap()
|
|
44
48
|
@Suppress("SENSELESS_NULL_IN_WHEN")
|
|
45
49
|
errorPayload.putString(
|
|
@@ -62,7 +66,7 @@ class CastEventAdapter(private val castApi: Cast, private val emitter: Emitter)
|
|
|
62
66
|
return errorPayload
|
|
63
67
|
}
|
|
64
68
|
|
|
65
|
-
private fun
|
|
69
|
+
private fun handleStateChange(event: CastStateChangeEvent) {
|
|
66
70
|
val payload = Arguments.createMap()
|
|
67
71
|
payload.putString(EVENT_PROP_TYPE, "chromecaststatechange")
|
|
68
72
|
if (event.state != null) {
|
|
@@ -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
|
+
}
|
|
@@ -253,7 +253,7 @@ class PlayerModule(context: ReactApplicationContext) : ReactContextBaseJavaModul
|
|
|
253
253
|
fun setTextTrackStyle(tag: Int, style: ReadableMap?) {
|
|
254
254
|
viewResolver.resolveViewByTag(tag) { view: ReactTHEOplayerView? ->
|
|
255
255
|
view?.player?.let { player ->
|
|
256
|
-
TextTrackStyleAdapter.applyTextTrackStyle(player.textTrackStyle, style)
|
|
256
|
+
TextTrackStyleAdapter.applyTextTrackStyle(player.textTrackStyle, reactApplicationContext, style)
|
|
257
257
|
}
|
|
258
258
|
}
|
|
259
259
|
}
|
|
@@ -427,7 +427,7 @@ class SourceAdapter {
|
|
|
427
427
|
private fun parseCmcdTransmissionMode(cmcdConfiguration : JSONObject) : CMCDTransmissionMode {
|
|
428
428
|
try {
|
|
429
429
|
val transmissionMode = cmcdConfiguration.optInt(CMCD_TRANSMISSION_MODE)
|
|
430
|
-
if (transmissionMode
|
|
430
|
+
if (transmissionMode == CmcdTransmissionMode.QUERY_ARGUMENT.ordinal) {
|
|
431
431
|
return CMCDTransmissionMode.QUERY_ARGUMENT
|
|
432
432
|
}
|
|
433
433
|
return CMCDTransmissionMode.HTTP_HEADER
|
|
@@ -13,9 +13,10 @@ import com.theoplayer.android.api.ads.theoads.OverlaySize
|
|
|
13
13
|
import com.theoplayer.android.api.ads.theoads.TheoAdsLayout
|
|
14
14
|
|
|
15
15
|
private const val PROP_ID = "id"
|
|
16
|
-
private const val PROP_TYPE = "
|
|
16
|
+
private const val PROP_TYPE = "type"
|
|
17
17
|
private const val PROP_START_TIME = "startTime"
|
|
18
18
|
private const val PROP_DURATION = "duration"
|
|
19
|
+
private const val PROP_AD_TAG_PARAMETERS = "adTagParameters"
|
|
19
20
|
private const val PROP_BACKDROP_URI = "backdropUri"
|
|
20
21
|
private const val PROP_LAYOUT = "layout"
|
|
21
22
|
private const val PROP_ADS = "ads"
|
|
@@ -62,6 +63,14 @@ object THEOadsAdapter {
|
|
|
62
63
|
putMap(PROP_POSITION, fromOverlayPosition(interstitial.position))
|
|
63
64
|
putMap(PROP_SIZE, fromOverlaySize(interstitial.size))
|
|
64
65
|
}
|
|
66
|
+
|
|
67
|
+
putMap(PROP_AD_TAG_PARAMETERS, fromAdTagParameters(interstitial.adTagParameters))
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
fun fromAdTagParameters(adTagParameters: Map<String, String>): WritableMap {
|
|
72
|
+
return Arguments.createMap().apply {
|
|
73
|
+
adTagParameters.forEach { (key, value) -> putString(key, value) }
|
|
65
74
|
}
|
|
66
75
|
}
|
|
67
76
|
|
|
@@ -8,6 +8,7 @@ import com.theoplayer.android.api.ads.theoads.event.InterstitialEvent
|
|
|
8
8
|
import com.theoplayer.android.api.ads.theoads.event.TheoAdsErrorEvent
|
|
9
9
|
import com.theoplayer.android.api.ads.theoads.event.TheoAdsEvent
|
|
10
10
|
import com.theoplayer.android.api.ads.theoads.event.TheoAdsEventTypes
|
|
11
|
+
import com.theoplayer.android.api.event.EventListener
|
|
11
12
|
|
|
12
13
|
private const val EVENT_PROP_TYPE = "type"
|
|
13
14
|
private const val EVENT_PROP_INTERSTITIAL = "interstitial"
|
|
@@ -27,15 +28,17 @@ class THEOadsEventAdapter(private val api: TheoAdsIntegration, private val emitt
|
|
|
27
28
|
fun emit(payload: WritableMap?)
|
|
28
29
|
}
|
|
29
30
|
|
|
31
|
+
private val onEvent = EventListener<TheoAdsEvent<*>> { handleEvent(it) }
|
|
32
|
+
|
|
30
33
|
init {
|
|
31
|
-
FORWARDED_EVENTS.forEach { api.addEventListener(it,
|
|
34
|
+
FORWARDED_EVENTS.forEach { api.addEventListener(it, onEvent) }
|
|
32
35
|
}
|
|
33
36
|
|
|
34
37
|
fun destroy() {
|
|
35
|
-
FORWARDED_EVENTS.forEach { api.removeEventListener(it,
|
|
38
|
+
FORWARDED_EVENTS.forEach { api.removeEventListener(it, onEvent) }
|
|
36
39
|
}
|
|
37
40
|
|
|
38
|
-
private fun
|
|
41
|
+
private fun handleEvent(event: TheoAdsEvent<*>) {
|
|
39
42
|
emitter.emit(Arguments.createMap().apply {
|
|
40
43
|
putString(EVENT_PROP_TYPE, event.type.name)
|
|
41
44
|
(event as? InterstitialEvent)?.let {
|
|
@@ -60,4 +60,18 @@ class THEOadsModule(context: ReactApplicationContext) : ReactContextBaseJavaModu
|
|
|
60
60
|
}
|
|
61
61
|
}
|
|
62
62
|
}
|
|
63
|
+
|
|
64
|
+
@ReactMethod
|
|
65
|
+
fun setAdTagParameters(tag: Int, id: String, adTagParameters: ReadableMap) {
|
|
66
|
+
viewResolver.resolveViewByTag(tag) { view: ReactTHEOplayerView? ->
|
|
67
|
+
if (BuildConfig.EXTENSION_THEOADS) {
|
|
68
|
+
view?.player?.theoAds?.let { theoads ->
|
|
69
|
+
val interstitials = theoads.currentInterstitials + theoads.scheduledInterstitials
|
|
70
|
+
interstitials.find { it.id == id }?.let { interstitial ->
|
|
71
|
+
interstitial.adTagParameters = adTagParameters.toHashMap().mapValues { it.value.toString() }
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
63
77
|
}
|
|
@@ -2,6 +2,7 @@ package com.theoplayer.theolive
|
|
|
2
2
|
|
|
3
3
|
import com.facebook.react.bridge.Arguments
|
|
4
4
|
import com.facebook.react.bridge.WritableMap
|
|
5
|
+
import com.theoplayer.android.api.event.EventListener
|
|
5
6
|
import com.theoplayer.android.api.event.player.theolive.DistributionLoadStartEvent
|
|
6
7
|
import com.theoplayer.android.api.event.player.theolive.DistributionOfflineEvent
|
|
7
8
|
import com.theoplayer.android.api.event.player.theolive.EndpointLoadedEvent
|
|
@@ -21,18 +22,30 @@ class THEOliveEventAdapter(private val theoLiveApi: TheoLive, private val emitte
|
|
|
21
22
|
fun emit(payload: WritableMap?)
|
|
22
23
|
}
|
|
23
24
|
|
|
25
|
+
private val onDistributionLoadStart =
|
|
26
|
+
EventListener<DistributionLoadStartEvent> { onDistributionLoadStart(it) }
|
|
27
|
+
private val onDistributionOffline =
|
|
28
|
+
EventListener<DistributionOfflineEvent> { onDistributionOffline(it) }
|
|
29
|
+
private val onEndPointLoaded =
|
|
30
|
+
EventListener<EndpointLoadedEvent> { onEndPointLoaded(it) }
|
|
31
|
+
private val onIntentOfFallback =
|
|
32
|
+
EventListener<IntentToFallbackEvent> { onIntentOfFallback(it) }
|
|
33
|
+
|
|
24
34
|
init {
|
|
25
|
-
theoLiveApi.addEventListener(TheoLiveEventTypes.DISTRIBUTIONLOADSTART,
|
|
26
|
-
theoLiveApi.addEventListener(TheoLiveEventTypes.DISTRIBUTIONOFFLINE,
|
|
27
|
-
theoLiveApi.addEventListener(TheoLiveEventTypes.ENDPOINTLOADED,
|
|
28
|
-
theoLiveApi.addEventListener(TheoLiveEventTypes.INTENTTOFALLBACK,
|
|
35
|
+
theoLiveApi.addEventListener(TheoLiveEventTypes.DISTRIBUTIONLOADSTART, onDistributionLoadStart)
|
|
36
|
+
theoLiveApi.addEventListener(TheoLiveEventTypes.DISTRIBUTIONOFFLINE, onDistributionOffline)
|
|
37
|
+
theoLiveApi.addEventListener(TheoLiveEventTypes.ENDPOINTLOADED, onEndPointLoaded)
|
|
38
|
+
theoLiveApi.addEventListener(TheoLiveEventTypes.INTENTTOFALLBACK, onIntentOfFallback)
|
|
29
39
|
}
|
|
30
40
|
|
|
31
41
|
fun destroy() {
|
|
32
|
-
theoLiveApi.removeEventListener(
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
42
|
+
theoLiveApi.removeEventListener(
|
|
43
|
+
TheoLiveEventTypes.DISTRIBUTIONLOADSTART,
|
|
44
|
+
onDistributionLoadStart
|
|
45
|
+
)
|
|
46
|
+
theoLiveApi.removeEventListener(TheoLiveEventTypes.DISTRIBUTIONOFFLINE, onDistributionOffline)
|
|
47
|
+
theoLiveApi.removeEventListener(TheoLiveEventTypes.ENDPOINTLOADED, onEndPointLoaded)
|
|
48
|
+
theoLiveApi.removeEventListener(TheoLiveEventTypes.INTENTTOFALLBACK, onIntentOfFallback)
|
|
36
49
|
}
|
|
37
50
|
|
|
38
51
|
private fun onDistributionLoadStart(event: DistributionLoadStartEvent) {
|
|
@@ -54,7 +54,7 @@ class THEOliveModule(context: ReactApplicationContext) : ReactContextBaseJavaMod
|
|
|
54
54
|
}
|
|
55
55
|
|
|
56
56
|
@ReactMethod
|
|
57
|
-
fun setAuthToken(tag: Int, token: String) {
|
|
57
|
+
fun setAuthToken(tag: Int, token: String?) {
|
|
58
58
|
viewResolver.resolveViewByTag(tag) { view: ReactTHEOplayerView? ->
|
|
59
59
|
view?.player?.theoLive?.authToken = token
|
|
60
60
|
}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
package com.theoplayer.track
|
|
2
2
|
|
|
3
3
|
import android.graphics.Color
|
|
4
|
+
import android.graphics.Typeface
|
|
5
|
+
import com.facebook.react.bridge.ReactApplicationContext
|
|
4
6
|
import com.facebook.react.bridge.ReadableMap
|
|
5
7
|
import com.theoplayer.android.api.player.track.texttrack.TextTrackStyle
|
|
6
8
|
|
|
@@ -10,6 +12,7 @@ private const val PROP_EDGE_COLOR = "edgeColor"
|
|
|
10
12
|
private const val PROP_FONT_COLOR = "fontColor"
|
|
11
13
|
private const val PROP_FONT_FAMILY = "fontFamily"
|
|
12
14
|
private const val PROP_FONT_SIZE = "fontSize"
|
|
15
|
+
private const val PROP_FONT_PATH = "fontPath"
|
|
13
16
|
private const val PROP_WINDOW_COLOR = "windowColor"
|
|
14
17
|
private const val PROP_MARGIN_LEFT = "marginLeft"
|
|
15
18
|
private const val PROP_MARGIN_RIGHT = "marginRight"
|
|
@@ -22,7 +25,7 @@ private const val PROP_COLOR_A = "a"
|
|
|
22
25
|
|
|
23
26
|
object TextTrackStyleAdapter {
|
|
24
27
|
|
|
25
|
-
fun applyTextTrackStyle(style: TextTrackStyle, props: ReadableMap?) {
|
|
28
|
+
fun applyTextTrackStyle(style: TextTrackStyle, context: ReactApplicationContext, props: ReadableMap?) {
|
|
26
29
|
if (props == null) {
|
|
27
30
|
return
|
|
28
31
|
}
|
|
@@ -65,6 +68,10 @@ object TextTrackStyleAdapter {
|
|
|
65
68
|
if (props.hasKey(PROP_MARGIN_RIGHT)) {
|
|
66
69
|
style.marginRight = props.getInt(PROP_MARGIN_RIGHT)
|
|
67
70
|
}
|
|
71
|
+
if (props.hasKey(PROP_FONT_PATH)) {
|
|
72
|
+
val font = Typeface.createFromAsset(context.assets, props.getString(PROP_FONT_PATH))
|
|
73
|
+
style.font = font
|
|
74
|
+
}
|
|
68
75
|
}
|
|
69
76
|
|
|
70
77
|
private fun edgeStyleFromProps(style: String?): TextTrackStyle.EdgeType {
|
|
@@ -57,6 +57,9 @@ private const val EVENT_PROP_MUTED = "muted"
|
|
|
57
57
|
private const val EVENT_PROP_WIDTH = "width"
|
|
58
58
|
private const val EVENT_PROP_HEIGHT = "height"
|
|
59
59
|
|
|
60
|
+
private const val EVENT_PROP_VIDEO_WIDTH = "videoWidth"
|
|
61
|
+
private const val EVENT_PROP_VIDEO_HEIGHT = "videoHeight"
|
|
62
|
+
|
|
60
63
|
class PayloadBuilder {
|
|
61
64
|
private val payload: WritableMap = Arguments.createMap()
|
|
62
65
|
|
|
@@ -138,6 +141,11 @@ class PayloadBuilder {
|
|
|
138
141
|
payload.putInt(EVENT_PROP_WIDTH, width)
|
|
139
142
|
payload.putInt(EVENT_PROP_HEIGHT, height)
|
|
140
143
|
}
|
|
144
|
+
|
|
145
|
+
fun videoSize(videoWidth: Int, videoHeight: Int) = apply {
|
|
146
|
+
payload.putInt(EVENT_PROP_VIDEO_WIDTH, videoWidth)
|
|
147
|
+
payload.putInt(EVENT_PROP_VIDEO_HEIGHT, videoHeight)
|
|
148
|
+
}
|
|
141
149
|
fun seekable(ranges: TimeRanges?) = apply {
|
|
142
150
|
payload.putArray(EVENT_PROP_SEEKABLE, fromTimeRanges(ranges))
|
|
143
151
|
}
|
|
@@ -46,7 +46,8 @@ RCT_EXPORT_VIEW_PROPERTY(onNativeMediaTrackEvent, RCTDirectEventBlock);
|
|
|
46
46
|
RCT_EXPORT_VIEW_PROPERTY(onNativeDeviceOrientationChanged, RCTDirectEventBlock);
|
|
47
47
|
RCT_EXPORT_VIEW_PROPERTY(onNativePlayerReady, RCTDirectEventBlock);
|
|
48
48
|
RCT_EXPORT_VIEW_PROPERTY(onNativePresentationModeChange, RCTDirectEventBlock);
|
|
49
|
-
RCT_EXPORT_VIEW_PROPERTY(
|
|
49
|
+
RCT_EXPORT_VIEW_PROPERTY(onNativeDimensionChange, RCTDirectEventBlock);
|
|
50
|
+
RCT_EXPORT_VIEW_PROPERTY(onNativeVideoResize, RCTDirectEventBlock);
|
|
50
51
|
RCT_EXPORT_VIEW_PROPERTY(onNativeAdEvent, RCTDirectEventBlock);
|
|
51
52
|
RCT_EXPORT_VIEW_PROPERTY(onNativeTHEOliveEvent, RCTDirectEventBlock);
|
|
52
53
|
RCT_EXPORT_VIEW_PROPERTY(onNativeTHEOadsEvent, RCTDirectEventBlock);
|
|
@@ -119,6 +120,8 @@ RCT_EXTERN_METHOD(setTextTrackStyle:(nonnull NSNumber *)node
|
|
|
119
120
|
RCT_EXTERN_METHOD(setKeepScreenOn:(nonnull NSNumber *)node
|
|
120
121
|
keepScreenOn:(BOOL)keepScreenOn)
|
|
121
122
|
|
|
123
|
+
RCT_EXTERN_METHOD(willUnmount:(nonnull NSNumber *)node)
|
|
124
|
+
|
|
122
125
|
RCT_EXTERN__BLOCKING_SYNCHRONOUS_METHOD(getUsableScreenDimensions)
|
|
123
126
|
|
|
124
127
|
@end
|
|
@@ -302,5 +305,9 @@ RCT_EXTERN_METHOD(scheduledInterstitials:(nonnull NSNumber *)node
|
|
|
302
305
|
RCT_EXTERN_METHOD(replaceAdTagParameters:(nonnull NSNumber *)node
|
|
303
306
|
adTagParameters:(nullable NSDictionary *)adTagParameters)
|
|
304
307
|
|
|
308
|
+
RCT_EXTERN_METHOD(setAdTagParameters:(nonnull NSNumber *)node
|
|
309
|
+
id:(nonnull NSString *)id
|
|
310
|
+
adTagParameters:(nullable NSDictionary *)adTagParameters)
|
|
311
|
+
|
|
305
312
|
@end
|
|
306
313
|
|
|
@@ -29,7 +29,8 @@ public class THEOplayerRCTMainEventHandler {
|
|
|
29
29
|
var onNativeRateChange: RCTDirectEventBlock?
|
|
30
30
|
var onNativeWaiting: RCTDirectEventBlock?
|
|
31
31
|
var onNativeCanPlay: RCTDirectEventBlock?
|
|
32
|
-
var
|
|
32
|
+
var onNativeDimensionChange: RCTDirectEventBlock?
|
|
33
|
+
var onNativeVideoResize: RCTDirectEventBlock?
|
|
33
34
|
|
|
34
35
|
// MARK: player Listeners
|
|
35
36
|
private var playListener: EventListener?
|
|
@@ -51,11 +52,10 @@ public class THEOplayerRCTMainEventHandler {
|
|
|
51
52
|
private var rateChangeListener: EventListener?
|
|
52
53
|
private var waitingListener: EventListener?
|
|
53
54
|
private var canPlayListener: EventListener?
|
|
54
|
-
private var
|
|
55
|
-
private var presentationModeChangeListener: EventListener?
|
|
55
|
+
private var videoResizeListener: EventListener?
|
|
56
56
|
|
|
57
57
|
// MARK: player observer
|
|
58
|
-
private var
|
|
58
|
+
private var dimensionChangeObserver: NSKeyValueObservation?
|
|
59
59
|
|
|
60
60
|
// MARK: - destruction
|
|
61
61
|
func destroy() {
|
|
@@ -310,27 +310,27 @@ public class THEOplayerRCTMainEventHandler {
|
|
|
310
310
|
}
|
|
311
311
|
if DEBUG_EVENTHANDLER { PrintUtils.printLog(logText: "[NATIVE] CanPlay listener attached to THEOplayer") }
|
|
312
312
|
|
|
313
|
-
// RESIZE
|
|
314
|
-
|
|
313
|
+
// RESIZE
|
|
314
|
+
self.videoResizeListener = player.addEventListener(type: PlayerEventTypes.RESIZE) { [weak self, weak player] event in
|
|
315
315
|
if DEBUG_THEOPLAYER_EVENTS { PrintUtils.printLog(logText: "[NATIVE] Received RESIZE event from THEOplayer") }
|
|
316
316
|
if let wplayer = player,
|
|
317
|
-
let
|
|
318
|
-
|
|
317
|
+
let forwardedVideoResizeEvent = self?.onNativeVideoResize {
|
|
318
|
+
forwardedVideoResizeEvent(
|
|
319
319
|
[
|
|
320
|
-
"
|
|
321
|
-
"
|
|
320
|
+
"videoWidth": wplayer.videoWidth,
|
|
321
|
+
"videoHeight": wplayer.videoHeight,
|
|
322
322
|
]
|
|
323
323
|
)
|
|
324
324
|
}
|
|
325
325
|
}
|
|
326
|
-
if DEBUG_EVENTHANDLER { PrintUtils.printLog(logText: "[NATIVE] Resize listener attached to THEOplayer") }
|
|
326
|
+
if DEBUG_EVENTHANDLER { PrintUtils.printLog(logText: "[NATIVE] Resize listener attached to THEOplayer") }
|
|
327
327
|
|
|
328
|
-
//
|
|
329
|
-
self.
|
|
328
|
+
// DIMENSION CHANGE: implemented using videoRect Observation
|
|
329
|
+
self.dimensionChangeObserver = player.observe(\.videoRect, options: [.new]) { [weak self, weak player] view, change in
|
|
330
330
|
if DEBUG_THEOPLAYER_EVENTS { PrintUtils.printLog(logText: "[NATIVE] Observed videoRect change on THEOplayer") }
|
|
331
331
|
if let wplayer = player,
|
|
332
|
-
let
|
|
333
|
-
|
|
332
|
+
let forwardedDimensionChangeEvent = self?.onNativeDimensionChange {
|
|
333
|
+
forwardedDimensionChangeEvent(
|
|
334
334
|
[
|
|
335
335
|
"width": wplayer.frame.width,
|
|
336
336
|
"height": wplayer.frame.height,
|
|
@@ -453,12 +453,15 @@ public class THEOplayerRCTMainEventHandler {
|
|
|
453
453
|
if DEBUG_EVENTHANDLER { PrintUtils.printLog(logText: "[NATIVE] CanPlay listener dettached from THEOplayer") }
|
|
454
454
|
}
|
|
455
455
|
|
|
456
|
+
// DIMENSION CHANGE
|
|
457
|
+
if DEBUG_EVENTHANDLER { PrintUtils.printLog(logText: "[NATIVE] Invalidate dimensionChangeObserver from THEOplayer") }
|
|
458
|
+
self.dimensionChangeObserver?.invalidate()
|
|
459
|
+
self.dimensionChangeObserver = nil
|
|
460
|
+
|
|
456
461
|
// RESIZE
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
}
|
|
461
|
-
self.videoRectObserver?.invalidate()
|
|
462
|
-
self.videoRectObserver = nil
|
|
462
|
+
if let videoResizeListener = self.videoResizeListener {
|
|
463
|
+
player.removeEventListener(type: PlayerEventTypes.RESIZE, listener: videoResizeListener)
|
|
464
|
+
if DEBUG_EVENTHANDLER { PrintUtils.printLog(logText: "[NATIVE] Resize listener dettached from THEOplayer") }
|
|
465
|
+
}
|
|
463
466
|
}
|
|
464
467
|
}
|