react-native-theoplayer 2.6.0 → 2.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/CHANGELOG.md +37 -0
- package/android/build.gradle +1 -1
- package/android/local/com/theoplayer/android-connector/mediasession/5.2.0-local/mediasession-5.2.0-local.aar +0 -0
- package/android/local/com/theoplayer/android-connector/mediasession/{4.12.0-local/mediasession-4.12.0-local.pom → 5.2.0-local/mediasession-5.2.0-local.pom} +1 -1
- package/android/local/com/theoplayer/android-connector/mediasession/maven-metadata-local.xml +4 -4
- package/android/src/main/AndroidManifest.xml +2 -2
- package/android/src/main/java/com/theoplayer/PlayerEventEmitter.kt +1 -1
- package/android/src/main/java/com/theoplayer/ReactTHEOplayerContext.kt +36 -20
- package/android/src/main/java/com/theoplayer/media/CustomMediaButtonReceiver.kt +25 -0
- package/android/src/main/java/com/theoplayer/{audio → media}/MediaNotificationBuilder.kt +1 -1
- package/android/src/main/java/com/theoplayer/{audio → media}/MediaPlaybackService.kt +8 -3
- package/android/src/main/java/com/theoplayer/source/SourceAdapter.kt +12 -0
- package/android/src/main/java/com/theoplayer/track/TrackListAdapter.kt +17 -13
- package/android/src/main/java/com/theoplayer/util/ViewResolver.kt +9 -1
- package/ios/THEOplayerRCTDebug.swift +3 -3
- package/ios/THEOplayerRCTMainEventHandler.swift +59 -59
- package/ios/THEOplayerRCTMediaTrackEventHandler.swift +18 -18
- package/ios/THEOplayerRCTNetworkUtils.swift +1 -1
- package/ios/THEOplayerRCTPlayerAPI.swift +14 -14
- package/ios/THEOplayerRCTPrintUtils.swift +16 -0
- package/ios/THEOplayerRCTSourceDescriptionBuilder.swift +6 -6
- package/ios/THEOplayerRCTTextTrackEventHandler.swift +21 -21
- package/ios/THEOplayerRCTView.swift +29 -29
- package/ios/ads/THEOplayerRCTAdsAPI+DAI.swift +6 -6
- package/ios/ads/THEOplayerRCTAdsAPI.swift +13 -13
- package/ios/ads/THEOplayerRCTAdsEventHandler.swift +27 -27
- package/ios/ads/THEOplayerRCTSourceDescriptionBuilder+Ads.swift +5 -5
- package/ios/backgroundAudio/THEOplayerRCTNowPlayingManager.swift +16 -15
- package/ios/backgroundAudio/THEOplayerRCTRemoteCommandsManager.swift +16 -16
- package/ios/casting/THEOplayerRCTCastAPI+Airplay.swift +6 -6
- package/ios/casting/THEOplayerRCTCastAPI+Chromecast.swift +10 -10
- package/ios/casting/THEOplayerRCTCastAPI.swift +1 -1
- package/ios/casting/THEOplayerRCTCastEventHandler.swift +11 -11
- package/ios/contentprotection/THEOplayerRCTContentProtectionAPI.swift +1 -1
- package/ios/pip/THEOplayerRCTPipControlsManager.swift +1 -1
- package/lib/commonjs/api/source/dash/DashPlaybackConfiguration.js.map +1 -1
- package/lib/commonjs/api/track/TextTrack.js.map +1 -1
- package/lib/commonjs/internal/adapter/THEOplayerAdapter.js +58 -10
- package/lib/commonjs/internal/adapter/THEOplayerAdapter.js.map +1 -1
- package/lib/commonjs/internal/adapter/web/FullscreenAPI.js +41 -0
- package/lib/commonjs/internal/adapter/web/FullscreenAPI.js.map +1 -0
- package/lib/commonjs/internal/adapter/web/WebPresentationModeManager.js +45 -39
- package/lib/commonjs/internal/adapter/web/WebPresentationModeManager.js.map +1 -1
- package/lib/commonjs/internal/utils/CommonUtils.js +10 -0
- package/lib/commonjs/internal/utils/CommonUtils.js.map +1 -0
- package/lib/commonjs/ui/components/seekbar/thumbnail/Urlpolyfill.web.js +4 -11
- package/lib/commonjs/ui/components/seekbar/thumbnail/Urlpolyfill.web.js.map +1 -1
- package/lib/module/api/source/dash/DashPlaybackConfiguration.js.map +1 -1
- package/lib/module/api/track/TextTrack.js.map +1 -1
- package/lib/module/internal/adapter/THEOplayerAdapter.js +59 -11
- package/lib/module/internal/adapter/THEOplayerAdapter.js.map +1 -1
- package/lib/module/internal/adapter/web/FullscreenAPI.js +34 -0
- package/lib/module/internal/adapter/web/FullscreenAPI.js.map +1 -0
- package/lib/module/internal/adapter/web/WebPresentationModeManager.js +45 -39
- package/lib/module/internal/adapter/web/WebPresentationModeManager.js.map +1 -1
- package/lib/module/internal/utils/CommonUtils.js +4 -0
- package/lib/module/internal/utils/CommonUtils.js.map +1 -0
- package/lib/module/ui/components/seekbar/thumbnail/Urlpolyfill.web.js +3 -2
- package/lib/module/ui/components/seekbar/thumbnail/Urlpolyfill.web.js.map +1 -1
- package/lib/typescript/api/source/dash/DashPlaybackConfiguration.d.ts +52 -0
- package/lib/typescript/api/track/TextTrack.d.ts +2 -2
- package/lib/typescript/internal/adapter/THEOplayerAdapter.d.ts +3 -0
- package/lib/typescript/internal/adapter/web/FullscreenAPI.d.ts +9 -0
- package/lib/typescript/internal/utils/CommonUtils.d.ts +1 -0
- package/lib/typescript/ui/components/seekbar/thumbnail/Urlpolyfill.web.d.ts +8 -1
- package/package.json +1 -1
- package/src/api/source/dash/DashPlaybackConfiguration.ts +56 -0
- package/src/api/track/TextTrack.ts +2 -2
- package/src/internal/adapter/THEOplayerAdapter.ts +63 -10
- package/src/internal/adapter/web/FullscreenAPI.ts +59 -0
- package/src/internal/adapter/web/WebPresentationModeManager.ts +29 -22
- package/src/internal/utils/CommonUtils.ts +3 -0
- package/src/ui/components/seekbar/thumbnail/Urlpolyfill.web.ts +3 -2
- package/android/local/com/theoplayer/android-connector/mediasession/4.12.0-local/mediasession-4.12.0-local.aar +0 -0
- package/lib/commonjs/web/platform/BrowserDetection.js +0 -34
- package/lib/commonjs/web/platform/BrowserDetection.js.map +0 -1
- package/lib/module/web/platform/BrowserDetection.js +0 -27
- package/lib/module/web/platform/BrowserDetection.js.map +0 -1
- package/lib/typescript/web/platform/BrowserDetection.d.ts +0 -23
- package/src/web/platform/BrowserDetection.ts +0 -38
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,43 @@ 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.0.0/)
|
|
6
6
|
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
+
## [2.8.0] - 23-06-01
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
|
|
12
|
+
- Added `ignoreAvailabilityWindow` property to `SourceDescription.dash` for Android and Web.
|
|
13
|
+
- Added `needsTimescaleShifting`, `desiredTimescale` and `forceSeekToSynchronize` properties to `SourceDescription.dash` for Web.
|
|
14
|
+
|
|
15
|
+
### Fixed
|
|
16
|
+
|
|
17
|
+
- Fixed an issue where text track cue changes were not applied to the TextTrack's `cue` property.
|
|
18
|
+
- Fixed an issue on Android where play-out of an MP4 stream would sometimes crash the player.
|
|
19
|
+
- Fixed an issue on Android where a `pause` event would not be dispatched while pausing during play-out of an ad.
|
|
20
|
+
- Fixed an issue on Android where hardware buttons, such as `play` and `pause`, were not handled anymore after toggling background audio support.
|
|
21
|
+
- Fixed an issue on Android where the app would crash when toggling background playback while multiple `MediaBrowserServiceCompat` instances are registered.
|
|
22
|
+
|
|
23
|
+
### Changed
|
|
24
|
+
|
|
25
|
+
- Improved fullscreen support to use non-native fullscreen on Safari for iPad and Mac.
|
|
26
|
+
- Limited the set of available media session actions on Android when an ad or live stream is playing.
|
|
27
|
+
- Removed pausing the stream when disabling background playback on Android.
|
|
28
|
+
|
|
29
|
+
## [2.7.0] - 23-05-15
|
|
30
|
+
|
|
31
|
+
### Changed
|
|
32
|
+
|
|
33
|
+
- Approved player behaviour on iOS and Android when doing player operations such as `play` and `pause` in case no source was set.
|
|
34
|
+
|
|
35
|
+
### Fixed
|
|
36
|
+
|
|
37
|
+
- Fixed an issue on Android where if an invalid view tag is passed to the native bridge, it would crash the player.
|
|
38
|
+
- Fixed an issue on Web where preview thumbnails would fail to load.
|
|
39
|
+
|
|
40
|
+
### Added
|
|
41
|
+
|
|
42
|
+
- Updated UI documentation with necessary dependencies.
|
|
43
|
+
- Added improved debug logging on iOS.
|
|
44
|
+
|
|
8
45
|
## [2.6.0] - 23-05-05
|
|
9
46
|
|
|
10
47
|
### Fixed
|
package/android/build.gradle
CHANGED
|
@@ -109,7 +109,7 @@ dependencies {
|
|
|
109
109
|
def theoplayer_sdk_version = safeExtGet('THEOplayer_sdk', '[5.0.1,)')
|
|
110
110
|
|
|
111
111
|
// def theoplayer_mediasession_version = safeExtGet('THEOplayer_mediasession', theoplayer_sdk_version)
|
|
112
|
-
def theoplayer_mediasession_version = "
|
|
112
|
+
def theoplayer_mediasession_version = "5.2.0-local"
|
|
113
113
|
def enabledV4 = theoplayer_sdk_version.toString().startsWith("4.")
|
|
114
114
|
def core_prefix = enabledV4 ? 'unified' : 'core'
|
|
115
115
|
def integration_prefix = enabledV4 ? 'unified' : 'integration'
|
|
Binary file
|
package/android/local/com/theoplayer/android-connector/mediasession/maven-metadata-local.xml
CHANGED
|
@@ -3,11 +3,11 @@
|
|
|
3
3
|
<groupId>com.theoplayer.android-connector</groupId>
|
|
4
4
|
<artifactId>mediasession</artifactId>
|
|
5
5
|
<versioning>
|
|
6
|
-
<latest>
|
|
7
|
-
<release>
|
|
6
|
+
<latest>5.2.0-local</latest>
|
|
7
|
+
<release>5.2.0-local</release>
|
|
8
8
|
<versions>
|
|
9
|
-
<version>
|
|
9
|
+
<version>5.2.0-local</version>
|
|
10
10
|
</versions>
|
|
11
|
-
<lastUpdated>
|
|
11
|
+
<lastUpdated>20230531125422</lastUpdated>
|
|
12
12
|
</versioning>
|
|
13
13
|
</metadata>
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
|
|
30
30
|
<!-- Allow background audio playback by registering this service. -->
|
|
31
31
|
<service
|
|
32
|
-
android:name="com.theoplayer.
|
|
32
|
+
android:name="com.theoplayer.media.MediaPlaybackService"
|
|
33
33
|
android:description="@string/background_playback_service_description"
|
|
34
34
|
android:exported="false"
|
|
35
35
|
android:enabled="false"
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
</intent-filter>
|
|
41
41
|
</service>
|
|
42
42
|
|
|
43
|
-
<receiver android:name="
|
|
43
|
+
<receiver android:name="com.theoplayer.media.CustomMediaButtonReceiver"
|
|
44
44
|
android:exported="false">
|
|
45
45
|
<intent-filter>
|
|
46
46
|
<action android:name="android.intent.action.MEDIA_BUTTON" />
|
|
@@ -346,7 +346,7 @@ class PlayerEventEmitter internal constructor(
|
|
|
346
346
|
private fun onPause() {
|
|
347
347
|
val player = playerView.player
|
|
348
348
|
// Do not forward the pause event in case the content player is paused because the ad player starts.
|
|
349
|
-
if (player != null && !playerView.adsApi.isPlaying) {
|
|
349
|
+
if (player != null && (!playerView.adsApi.isPlaying || player.isPaused)) {
|
|
350
350
|
receiveEvent(EVENT_PAUSE, null)
|
|
351
351
|
}
|
|
352
352
|
}
|
|
@@ -26,11 +26,20 @@ import com.theoplayer.android.api.event.player.*
|
|
|
26
26
|
import com.theoplayer.android.api.player.Player
|
|
27
27
|
import com.theoplayer.android.connector.mediasession.MediaSessionConnector
|
|
28
28
|
import com.theoplayer.audio.BackgroundAudioConfig
|
|
29
|
-
import com.theoplayer.
|
|
29
|
+
import com.theoplayer.media.MediaPlaybackService
|
|
30
30
|
import java.util.concurrent.atomic.AtomicBoolean
|
|
31
31
|
|
|
32
32
|
private const val TAG = "ReactTHEOplayerContext"
|
|
33
33
|
|
|
34
|
+
private const val ALLOWED_PLAYBACK_ACTIONS = (
|
|
35
|
+
PlaybackStateCompat.ACTION_PLAY_PAUSE or
|
|
36
|
+
PlaybackStateCompat.ACTION_PLAY or
|
|
37
|
+
PlaybackStateCompat.ACTION_PAUSE or
|
|
38
|
+
PlaybackStateCompat.ACTION_SEEK_TO or
|
|
39
|
+
PlaybackStateCompat.ACTION_FAST_FORWARD or
|
|
40
|
+
PlaybackStateCompat.ACTION_REWIND or
|
|
41
|
+
PlaybackStateCompat.ACTION_SET_PLAYBACK_SPEED)
|
|
42
|
+
|
|
34
43
|
class ReactTHEOplayerContext private constructor(
|
|
35
44
|
private val reactContext: ThemedReactContext
|
|
36
45
|
) {
|
|
@@ -59,8 +68,6 @@ class ReactTHEOplayerContext private constructor(
|
|
|
59
68
|
get() = backgroundAudioConfig.enabled
|
|
60
69
|
|
|
61
70
|
companion object {
|
|
62
|
-
private var mediaControlledInstance: ReactTHEOplayerContext? = null
|
|
63
|
-
|
|
64
71
|
fun create(
|
|
65
72
|
reactContext: ThemedReactContext,
|
|
66
73
|
playerConfig: THEOplayerConfig
|
|
@@ -75,9 +82,6 @@ class ReactTHEOplayerContext private constructor(
|
|
|
75
82
|
override fun onServiceConnected(className: ComponentName, service: IBinder) {
|
|
76
83
|
binder = service as MediaPlaybackService.MediaPlaybackBinder
|
|
77
84
|
|
|
78
|
-
// Clean-up any existing media session connector
|
|
79
|
-
mediaSessionConnector?.destroy()
|
|
80
|
-
|
|
81
85
|
// Get media session connector from service
|
|
82
86
|
mediaSessionConnector = binder?.mediaSessionConnector
|
|
83
87
|
mediaSessionConnector?.player = player
|
|
@@ -128,12 +132,26 @@ class ReactTHEOplayerContext private constructor(
|
|
|
128
132
|
}
|
|
129
133
|
}
|
|
130
134
|
|
|
135
|
+
private fun applyAllowedMediaControls() {
|
|
136
|
+
// Reduce allowed set of remote control playback actions for ads & live streams.
|
|
137
|
+
val isLive = player.duration.isInfinite()
|
|
138
|
+
val isInAd = player.ads.isPlaying
|
|
139
|
+
mediaSessionConnector?.enabledPlaybackActions = if (isInAd || isLive) {
|
|
140
|
+
0
|
|
141
|
+
} else {
|
|
142
|
+
ALLOWED_PLAYBACK_ACTIONS
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
|
|
131
146
|
private fun bindMediaPlaybackService() {
|
|
132
147
|
// Bind to an existing service, if available
|
|
133
148
|
// A bound service runs only as long as another application component is bound to it.
|
|
134
149
|
// Multiple components can bind to the service at once, but when all of them unbind, the
|
|
135
150
|
// service is destroyed.
|
|
136
151
|
if (!isBound.get()) {
|
|
152
|
+
// Clean-up any existing media session connector
|
|
153
|
+
mediaSessionConnector?.destroy()
|
|
154
|
+
|
|
137
155
|
isBound.set(
|
|
138
156
|
reactContext.bindService(
|
|
139
157
|
Intent(reactContext, MediaPlaybackService::class.java),
|
|
@@ -179,11 +197,8 @@ class ReactTHEOplayerContext private constructor(
|
|
|
179
197
|
addIntegrations(playerConfig)
|
|
180
198
|
addListeners()
|
|
181
199
|
|
|
182
|
-
if (
|
|
183
|
-
|
|
184
|
-
if (!BuildConfig.USE_PLAYBACK_SERVICE || !isBackgroundAudioEnabled) {
|
|
185
|
-
initDefaultMediaSession()
|
|
186
|
-
}
|
|
200
|
+
if (!BuildConfig.USE_PLAYBACK_SERVICE || !isBackgroundAudioEnabled) {
|
|
201
|
+
initDefaultMediaSession()
|
|
187
202
|
}
|
|
188
203
|
|
|
189
204
|
// Apply initial backgroundPlayback config
|
|
@@ -243,10 +258,12 @@ class ReactTHEOplayerContext private constructor(
|
|
|
243
258
|
private val onSourceChange = EventListener<SourceChangeEvent> {
|
|
244
259
|
mediaSessionConnector?.setMediaSessionMetadata(player.source)
|
|
245
260
|
binder?.updateNotification()
|
|
261
|
+
applyAllowedMediaControls()
|
|
246
262
|
}
|
|
247
263
|
|
|
248
264
|
private val onLoadedMetadata = EventListener<LoadedMetadataEvent> {
|
|
249
265
|
binder?.updateNotification()
|
|
266
|
+
applyAllowedMediaControls()
|
|
250
267
|
}
|
|
251
268
|
|
|
252
269
|
private val onPlay = EventListener<PlayEvent> {
|
|
@@ -254,10 +271,12 @@ class ReactTHEOplayerContext private constructor(
|
|
|
254
271
|
bindMediaPlaybackService()
|
|
255
272
|
}
|
|
256
273
|
binder?.updateNotification(PlaybackStateCompat.STATE_PLAYING)
|
|
274
|
+
applyAllowedMediaControls()
|
|
257
275
|
}
|
|
258
276
|
|
|
259
277
|
private val onPause = EventListener<PauseEvent> {
|
|
260
278
|
binder?.updateNotification(PlaybackStateCompat.STATE_PAUSED)
|
|
279
|
+
applyAllowedMediaControls()
|
|
261
280
|
}
|
|
262
281
|
|
|
263
282
|
private fun addListeners() {
|
|
@@ -310,17 +329,14 @@ class ReactTHEOplayerContext private constructor(
|
|
|
310
329
|
}
|
|
311
330
|
|
|
312
331
|
fun destroy() {
|
|
313
|
-
if (
|
|
314
|
-
|
|
315
|
-
removeListeners()
|
|
332
|
+
if (BuildConfig.USE_PLAYBACK_SERVICE) {
|
|
333
|
+
removeListeners()
|
|
316
334
|
|
|
317
|
-
|
|
318
|
-
|
|
335
|
+
// Remove service from foreground
|
|
336
|
+
binder?.stopForegroundService()
|
|
319
337
|
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
}
|
|
323
|
-
mediaControlledInstance = null
|
|
338
|
+
// Unbind client from background service so it can stop
|
|
339
|
+
unbindMediaPlaybackService()
|
|
324
340
|
}
|
|
325
341
|
mediaSessionConnector?.destroy()
|
|
326
342
|
playerView.onDestroy()
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
package com.theoplayer.media
|
|
2
|
+
|
|
3
|
+
import android.content.Context
|
|
4
|
+
import android.content.Intent
|
|
5
|
+
import android.util.Log
|
|
6
|
+
import androidx.media.session.MediaButtonReceiver
|
|
7
|
+
|
|
8
|
+
private const val TAG = "MediaButtonReceiver"
|
|
9
|
+
|
|
10
|
+
class CustomMediaButtonReceiver : MediaButtonReceiver() {
|
|
11
|
+
|
|
12
|
+
override fun onReceive(context: Context?, intent: Intent?) {
|
|
13
|
+
// MediaButtonReceiver will throw an IllegalStateException in case there are
|
|
14
|
+
// none, or more than one MediaBrowserServiceCompat instances registered.
|
|
15
|
+
// Handle and ignore the exception here.
|
|
16
|
+
try {
|
|
17
|
+
super.onReceive(context, intent)
|
|
18
|
+
} catch (e: IllegalStateException) {
|
|
19
|
+
Log.e(
|
|
20
|
+
TAG,
|
|
21
|
+
e.message ?: "Failed to handle media playback button action."
|
|
22
|
+
)
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
package com.theoplayer.
|
|
1
|
+
package com.theoplayer.media
|
|
2
2
|
|
|
3
3
|
import android.app.NotificationManager
|
|
4
4
|
import android.app.PendingIntent
|
|
@@ -98,6 +98,9 @@ class MediaPlaybackService : MediaBrowserServiceCompat() {
|
|
|
98
98
|
}
|
|
99
99
|
|
|
100
100
|
override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int {
|
|
101
|
+
// This ensures that the correct callbacks to MediaSessionCompat.Callback will be triggered
|
|
102
|
+
// based on the incoming KeyEvent.
|
|
103
|
+
// https://developer.android.com/reference/androidx/media/session/MediaButtonReceiver
|
|
101
104
|
MediaButtonReceiver.handleIntent(mediaSession, intent)
|
|
102
105
|
return super.onStartCommand(intent, flags, startId)
|
|
103
106
|
}
|
|
@@ -155,17 +158,19 @@ class MediaPlaybackService : MediaBrowserServiceCompat() {
|
|
|
155
158
|
setMediaButtonReceiver(mediaButtonPendingIntent)
|
|
156
159
|
}
|
|
157
160
|
|
|
158
|
-
// Create a MediaSessionConnector
|
|
161
|
+
// Create a MediaSessionConnector.
|
|
159
162
|
mediaSessionConnector = MediaSessionConnector(mediaSession).apply {
|
|
160
163
|
debug = BuildConfig.LOG_MEDIASESSION_EVENTS
|
|
161
164
|
|
|
162
165
|
// Set mediaSession active
|
|
163
166
|
setActive(true)
|
|
164
167
|
}
|
|
168
|
+
|
|
169
|
+
// Set the MediaBrowserServiceCompat's media session.
|
|
170
|
+
sessionToken = mediaSession.sessionToken
|
|
165
171
|
}
|
|
166
172
|
|
|
167
173
|
private fun stopForegroundService() {
|
|
168
|
-
player?.pause()
|
|
169
174
|
updateNotification(PlaybackStateCompat.STATE_STOPPED)
|
|
170
175
|
stopSelf()
|
|
171
176
|
}
|
|
@@ -24,6 +24,7 @@ import com.theoplayer.android.api.source.metadata.ChromecastMetadataImage
|
|
|
24
24
|
import com.facebook.react.bridge.ReadableArray
|
|
25
25
|
import com.theoplayer.BuildConfig
|
|
26
26
|
import com.theoplayer.android.api.error.ErrorCode
|
|
27
|
+
import com.theoplayer.android.api.source.dash.DashPlaybackConfiguration
|
|
27
28
|
import com.theoplayer.drm.ContentProtectionAdapter
|
|
28
29
|
import org.json.JSONArray
|
|
29
30
|
import org.json.JSONException
|
|
@@ -51,6 +52,8 @@ private const val PROP_TEXT_TRACKS = "textTracks"
|
|
|
51
52
|
private const val PROP_POSTER = "poster"
|
|
52
53
|
private const val PROP_ADS = "ads"
|
|
53
54
|
private const val PROP_AVAILABILITY_TYPE = "availabilityType"
|
|
55
|
+
private const val PROP_DASH = "dash"
|
|
56
|
+
private const val PROP_DASH_IGNORE_AVAILABILITYWINDOW = "ignoreAvailabilityWindow"
|
|
54
57
|
private const val ERROR_DAI_NOT_ENABLED = "Google DAI support not enabled."
|
|
55
58
|
private const val ERROR_UNSUPPORTED_SSAI_INTEGRATION = "Unsupported SSAI integration"
|
|
56
59
|
private const val ERROR_MISSING_SSAI_INTEGRATION = "Missing SSAI integration"
|
|
@@ -186,6 +189,9 @@ class SourceAdapter {
|
|
|
186
189
|
if (sourceType != null) {
|
|
187
190
|
tsBuilder.type(sourceType)
|
|
188
191
|
}
|
|
192
|
+
if (jsonTypedSource.has(PROP_DASH)) {
|
|
193
|
+
tsBuilder.dash(parseDashConfig(jsonTypedSource.getJSONObject(PROP_DASH)))
|
|
194
|
+
}
|
|
189
195
|
if (jsonTypedSource.has(PROP_LIVE_OFFSET)) {
|
|
190
196
|
tsBuilder.liveOffset(jsonTypedSource.getDouble(PROP_LIVE_OFFSET))
|
|
191
197
|
}
|
|
@@ -358,6 +364,12 @@ class SourceAdapter {
|
|
|
358
364
|
return MetadataDescription(metadata)
|
|
359
365
|
}
|
|
360
366
|
|
|
367
|
+
private fun parseDashConfig(dashConfig: JSONObject): DashPlaybackConfiguration {
|
|
368
|
+
return DashPlaybackConfiguration.Builder()
|
|
369
|
+
.ignoreAvailabilityWindow(dashConfig.optBoolean(PROP_DASH_IGNORE_AVAILABILITYWINDOW))
|
|
370
|
+
.build()
|
|
371
|
+
}
|
|
372
|
+
|
|
361
373
|
@Throws(JSONException::class)
|
|
362
374
|
private fun parseMetadataImages(metadataImages: JSONArray): List<ChromecastMetadataImage> {
|
|
363
375
|
val imageList: MutableList<ChromecastMetadataImage> = ArrayList()
|
|
@@ -124,9 +124,11 @@ object TrackListAdapter {
|
|
|
124
124
|
audioTrackPayload.putString(PROP_LANGUAGE, audioTrack.language)
|
|
125
125
|
val qualityList = audioTrack.qualities
|
|
126
126
|
val qualities = Arguments.createArray()
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
127
|
+
try {
|
|
128
|
+
qualityList?.forEach { quality ->
|
|
129
|
+
qualities.pushMap(fromAudioQuality(quality))
|
|
130
|
+
}
|
|
131
|
+
} catch (ignore: NullPointerException) {}
|
|
130
132
|
audioTrackPayload.putArray(PROP_QUALITIES, qualities)
|
|
131
133
|
val activeQuality = audioTrack.activeQuality
|
|
132
134
|
if (activeQuality != null) {
|
|
@@ -163,18 +165,20 @@ object TrackListAdapter {
|
|
|
163
165
|
videoTrackPayload.putString(PROP_KIND, videoTrack.kind)
|
|
164
166
|
videoTrackPayload.putString(PROP_LABEL, videoTrack.label)
|
|
165
167
|
videoTrackPayload.putString(PROP_LANGUAGE, videoTrack.language)
|
|
166
|
-
val qualityList = videoTrack.qualities
|
|
167
168
|
val qualities = Arguments.createArray()
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
169
|
+
try {
|
|
170
|
+
val qualityList = videoTrack.qualities
|
|
171
|
+
if (qualityList != null) {
|
|
172
|
+
// Sort qualities according to (height, bandwidth)
|
|
173
|
+
val sortedQualityList = QualityListAdapter(qualityList)
|
|
174
|
+
sortedQualityList.sort { o: VideoQuality, t1: VideoQuality ->
|
|
175
|
+
if (o.height == t1.height) t1.bandwidth.compareTo(o.bandwidth) else t1.height.compareTo(o.height)
|
|
176
|
+
}
|
|
177
|
+
for (quality in sortedQualityList) {
|
|
178
|
+
qualities.pushMap(fromVideoQuality(quality as VideoQuality))
|
|
179
|
+
}
|
|
173
180
|
}
|
|
174
|
-
|
|
175
|
-
qualities.pushMap(fromVideoQuality(quality as VideoQuality))
|
|
176
|
-
}
|
|
177
|
-
}
|
|
181
|
+
} catch (ignore: java.lang.NullPointerException) {}
|
|
178
182
|
videoTrackPayload.putArray(PROP_QUALITIES, qualities)
|
|
179
183
|
val activeQuality = videoTrack.activeQuality
|
|
180
184
|
if (activeQuality != null) {
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
package com.theoplayer.util
|
|
2
2
|
|
|
3
|
+
import android.util.Log
|
|
3
4
|
import com.facebook.react.bridge.ReactApplicationContext
|
|
4
5
|
import com.facebook.react.uimanager.UIManagerModule
|
|
5
6
|
import com.theoplayer.ReactTHEOplayerView
|
|
6
7
|
|
|
8
|
+
private const val TAG = "ViewResolver"
|
|
9
|
+
|
|
7
10
|
class ViewResolver(private val reactContext: ReactApplicationContext) {
|
|
8
11
|
private var uiManager: UIManagerModule? = null
|
|
9
12
|
|
|
@@ -12,7 +15,12 @@ class ViewResolver(private val reactContext: ReactApplicationContext) {
|
|
|
12
15
|
uiManager = reactContext.getNativeModule(UIManagerModule::class.java)
|
|
13
16
|
}
|
|
14
17
|
uiManager?.addUIBlock {
|
|
15
|
-
|
|
18
|
+
try {
|
|
19
|
+
onResolved(it.resolveView(tag) as ReactTHEOplayerView)
|
|
20
|
+
} catch (ignore: Exception) {
|
|
21
|
+
// The ReactTHEOplayerView instance could not be resolved: log but do not forward exception.
|
|
22
|
+
Log.w(TAG, "Failed to resolve ReactTHEOplayerView tag $tag")
|
|
23
|
+
}
|
|
16
24
|
}
|
|
17
25
|
}
|
|
18
26
|
}
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
// THEOplayerRCTDebug.swift
|
|
2
2
|
|
|
3
3
|
// General debug flag, if set to false none of the debug prints will appear
|
|
4
|
-
let DEBUG =
|
|
4
|
+
let DEBUG = true
|
|
5
5
|
|
|
6
6
|
// Debug flag to monitor incoming Theoplayer events
|
|
7
|
-
let DEBUG_THEOPLAYER_EVENTS = DEBUG &&
|
|
7
|
+
let DEBUG_THEOPLAYER_EVENTS = DEBUG && true
|
|
8
8
|
|
|
9
9
|
// Debug flag to monitor eventhandler setup and breakdown
|
|
10
10
|
let DEBUG_EVENTHANDLER = DEBUG && false
|
|
11
11
|
|
|
12
12
|
// Debug flag to monitor the interactions for each view with its underlying theoplayer instance
|
|
13
|
-
let DEBUG_THEOPLAYER_INTERACTION = DEBUG &&
|
|
13
|
+
let DEBUG_THEOPLAYER_INTERACTION = DEBUG && true
|
|
14
14
|
|
|
15
15
|
// Debug flag to monitor contentProtection integration handling
|
|
16
16
|
let DEBUG_CONTENT_PROTECTION_API = DEBUG && false
|