react-native-theoplayer 1.7.1 → 1.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -0
- package/android/src/main/java/com/theoplayer/PlayerConfigAdapter.kt +115 -0
- package/android/src/main/java/com/theoplayer/PlayerEventEmitter.kt +648 -0
- package/android/src/main/java/com/theoplayer/ReactTHEOplayerPackage.kt +23 -0
- package/android/src/main/java/com/theoplayer/ReactTHEOplayerView.kt +446 -0
- package/android/src/main/java/com/theoplayer/ReactTHEOplayerViewManager.kt +117 -0
- package/android/src/main/java/com/theoplayer/{TimeUpdateRate.java → TimeUpdateRate.kt} +2 -2
- package/android/src/main/java/com/theoplayer/ads/AdAdapter.kt +161 -0
- package/android/src/main/java/com/theoplayer/ads/AdEventAdapter.kt +90 -0
- package/android/src/main/java/com/theoplayer/ads/AdsModule.kt +140 -0
- package/android/src/main/java/com/theoplayer/cast/CastEventAdapter.kt +81 -0
- package/android/src/main/java/com/theoplayer/cast/CastModule.kt +75 -0
- package/android/src/main/java/com/theoplayer/drm/ContentProtectionAdapter.kt +2 -2
- package/android/src/main/java/com/theoplayer/drm/ContentProtectionModule.kt +1 -2
- package/android/src/main/java/com/theoplayer/drm/ProxyContentProtectionIntegration.kt +1 -2
- package/android/src/main/java/com/theoplayer/drm/ProxyContentProtectionIntegrationFactory.kt +3 -5
- package/android/src/main/java/com/theoplayer/source/SourceAdapter.kt +402 -0
- package/android/src/main/java/com/theoplayer/track/MediaTrackEventType.kt +6 -0
- package/android/src/main/java/com/theoplayer/track/MediaTrackType.kt +6 -0
- package/android/src/main/java/com/theoplayer/track/QualityListAdapter.kt +43 -0
- package/android/src/main/java/com/theoplayer/track/QualityListFilter.kt +28 -0
- package/android/src/main/java/com/theoplayer/track/TextTrackCueEventType.kt +10 -0
- package/android/src/main/java/com/theoplayer/track/TrackEventType.kt +7 -0
- package/android/src/main/java/com/theoplayer/track/TrackListAdapter.kt +219 -0
- package/android/src/main/java/com/theoplayer/util/ViewResolver.kt +19 -0
- package/ios/THEOplayerRCTAdAggregator.swift +15 -6
- package/ios/THEOplayerRCTAdsAPI.swift +39 -40
- package/ios/THEOplayerRCTBridge.m +54 -1
- package/ios/THEOplayerRCTCastAPI.swift +275 -0
- package/ios/THEOplayerRCTDebug.swift +3 -0
- package/ios/THEOplayerRCTSourceDescriptionBuilder.swift +91 -19
- package/ios/THEOplayerRCTTrackEventTypes.swift +17 -0
- package/ios/{THEOplayerRCTMetadataAggregator.swift → THEOplayerRCTTrackMetadataAggregator.swift} +69 -55
- package/ios/THEOplayerRCTView.swift +126 -22
- package/ios/THEOplayerRCTViewAdEventHandler.swift +7 -5
- package/ios/THEOplayerRCTViewCastEventHandler.swift +124 -0
- package/ios/THEOplayerRCTViewMainEventHandler.swift +1 -1
- package/ios/THEOplayerRCTViewMediaTrackEventHandler.swift +185 -0
- package/ios/THEOplayerRCTViewTextTrackEventHandler.swift +30 -13
- package/ios/custom/Frameworks/ios/put_custom_ios_xcframework_here.txt +1 -1
- package/ios/custom/Frameworks/tvos/put_custom_tvos_xcframework_here.txt +2 -0
- package/ios/custom/react-native-theoplayer_custom.podspec +46 -0
- package/lib/commonjs/api/THEOplayerView.js.map +1 -1
- package/lib/commonjs/api/barrel.js +21 -8
- package/lib/commonjs/api/barrel.js.map +1 -1
- package/lib/commonjs/api/cast/Airplay.js +6 -0
- package/lib/commonjs/api/cast/Airplay.js.map +1 -0
- package/lib/commonjs/api/cast/CastAPI.js +6 -0
- package/lib/commonjs/api/cast/CastAPI.js.map +1 -0
- package/lib/commonjs/api/cast/CastConfiguration.js +2 -0
- package/lib/commonjs/api/cast/CastConfiguration.js.map +1 -0
- package/lib/commonjs/api/cast/CastState.js +2 -0
- package/lib/commonjs/api/cast/CastState.js.map +1 -0
- package/lib/commonjs/api/cast/Chromecast.js +6 -0
- package/lib/commonjs/api/cast/Chromecast.js.map +1 -0
- package/lib/commonjs/api/cast/barrel.js +71 -0
- package/lib/commonjs/api/cast/barrel.js.map +1 -0
- package/lib/commonjs/api/config/PlayerConfiguration.js.map +1 -1
- package/lib/commonjs/api/error/ChromecastError.js +2 -0
- package/lib/commonjs/api/error/ChromecastError.js.map +1 -0
- package/lib/commonjs/api/error/barrel.js +13 -0
- package/lib/commonjs/api/error/barrel.js.map +1 -1
- package/lib/commonjs/api/event/CastEvent.js +21 -0
- package/lib/commonjs/api/event/CastEvent.js.map +1 -0
- package/lib/commonjs/api/event/TrackEvent.js +17 -1
- package/lib/commonjs/api/event/TrackEvent.js.map +1 -1
- package/lib/commonjs/api/event/barrel.js +25 -12
- package/lib/commonjs/api/event/barrel.js.map +1 -1
- package/lib/commonjs/api/source/SourceDescription.js.map +1 -1
- package/lib/commonjs/api/source/barrel.js +13 -0
- package/lib/commonjs/api/source/barrel.js.map +1 -1
- package/lib/commonjs/api/source/metadata/MetadataDescription.js +2 -0
- package/lib/commonjs/api/source/metadata/MetadataDescription.js.map +1 -0
- package/lib/commonjs/api/source/metadata/barrel.js +19 -0
- package/lib/commonjs/api/source/metadata/barrel.js.map +1 -0
- package/lib/commonjs/internal/THEOplayerView.js +30 -0
- package/lib/commonjs/internal/THEOplayerView.js.map +1 -1
- package/lib/commonjs/internal/THEOplayerView.web.js +80 -20
- package/lib/commonjs/internal/THEOplayerView.web.js.map +1 -1
- package/lib/commonjs/internal/cast/THEOplayerNativeAirplay.js +34 -0
- package/lib/commonjs/internal/cast/THEOplayerNativeAirplay.js.map +1 -0
- package/lib/commonjs/internal/cast/THEOplayerNativeCastApi.js +46 -0
- package/lib/commonjs/internal/cast/THEOplayerNativeCastApi.js.map +1 -0
- package/lib/commonjs/internal/cast/THEOplayerNativeChromecast.js +42 -0
- package/lib/commonjs/internal/cast/THEOplayerNativeChromecast.js.map +1 -0
- package/lib/commonjs/internal/cast/THEOplayerWebCastApi.js +31 -0
- package/lib/commonjs/internal/cast/THEOplayerWebCastApi.js.map +1 -0
- package/lib/commonjs/internal/web/stub/CastButtonStub.js +16 -0
- package/lib/commonjs/internal/web/stub/CastButtonStub.js.map +1 -0
- package/lib/module/api/THEOplayerView.js.map +1 -1
- package/lib/module/api/barrel.js +1 -0
- package/lib/module/api/barrel.js.map +1 -1
- package/lib/module/api/cast/Airplay.js +2 -0
- package/lib/module/api/cast/Airplay.js.map +1 -0
- package/lib/module/api/cast/CastAPI.js +2 -0
- package/lib/module/api/cast/CastAPI.js.map +1 -0
- package/lib/module/api/cast/CastConfiguration.js +2 -0
- package/lib/module/api/cast/CastConfiguration.js.map +1 -0
- package/lib/module/api/cast/CastState.js +2 -0
- package/lib/module/api/cast/CastState.js.map +1 -0
- package/lib/module/api/cast/Chromecast.js +2 -0
- package/lib/module/api/cast/Chromecast.js.map +1 -0
- package/lib/module/api/cast/barrel.js +6 -0
- package/lib/module/api/cast/barrel.js.map +1 -0
- package/lib/module/api/config/PlayerConfiguration.js.map +1 -1
- package/lib/module/api/error/ChromecastError.js +2 -0
- package/lib/module/api/error/ChromecastError.js.map +1 -0
- package/lib/module/api/error/barrel.js +1 -0
- package/lib/module/api/error/barrel.js.map +1 -1
- package/lib/module/api/event/CastEvent.js +14 -0
- package/lib/module/api/event/CastEvent.js.map +1 -0
- package/lib/module/api/event/TrackEvent.js +14 -0
- package/lib/module/api/event/TrackEvent.js.map +1 -1
- package/lib/module/api/event/barrel.js +2 -1
- package/lib/module/api/event/barrel.js.map +1 -1
- package/lib/module/api/source/SourceDescription.js.map +1 -1
- package/lib/module/api/source/barrel.js +1 -0
- package/lib/module/api/source/barrel.js.map +1 -1
- package/lib/module/api/source/metadata/MetadataDescription.js +2 -0
- package/lib/module/api/source/metadata/MetadataDescription.js.map +1 -0
- package/lib/module/api/source/metadata/barrel.js +2 -0
- package/lib/module/api/source/metadata/barrel.js.map +1 -0
- package/lib/module/internal/THEOplayerView.js +29 -0
- package/lib/module/internal/THEOplayerView.js.map +1 -1
- package/lib/module/internal/THEOplayerView.web.js +80 -21
- package/lib/module/internal/THEOplayerView.web.js.map +1 -1
- package/lib/module/internal/cast/THEOplayerNativeAirplay.js +24 -0
- package/lib/module/internal/cast/THEOplayerNativeAirplay.js.map +1 -0
- package/lib/module/internal/cast/THEOplayerNativeCastApi.js +34 -0
- package/lib/module/internal/cast/THEOplayerNativeCastApi.js.map +1 -0
- package/lib/module/internal/cast/THEOplayerNativeChromecast.js +32 -0
- package/lib/module/internal/cast/THEOplayerNativeChromecast.js.map +1 -0
- package/lib/module/internal/cast/THEOplayerWebCastApi.js +22 -0
- package/lib/module/internal/cast/THEOplayerWebCastApi.js.map +1 -0
- package/lib/module/internal/web/stub/CastButtonStub.js +6 -0
- package/lib/module/internal/web/stub/CastButtonStub.js.map +1 -0
- package/lib/typescript/lib/commonjs/api/cast/Airplay.d.ts +1 -0
- package/lib/typescript/lib/commonjs/api/cast/CastAPI.d.ts +1 -0
- package/lib/typescript/lib/commonjs/api/cast/CastConfiguration.d.ts +0 -0
- package/lib/typescript/lib/commonjs/api/cast/CastState.d.ts +0 -0
- package/lib/typescript/lib/commonjs/api/cast/Chromecast.d.ts +1 -0
- package/lib/typescript/lib/commonjs/api/cast/barrel.d.ts +1 -0
- package/lib/typescript/lib/commonjs/api/error/ChromecastError.d.ts +0 -0
- package/lib/typescript/lib/commonjs/api/event/CastEvent.d.ts +2 -0
- package/lib/typescript/lib/commonjs/api/event/TrackEvent.d.ts +4 -0
- package/lib/typescript/lib/commonjs/api/source/metadata/MetadataDescription.d.ts +0 -0
- package/lib/typescript/lib/commonjs/api/source/metadata/barrel.d.ts +1 -0
- package/lib/typescript/lib/commonjs/internal/THEOplayerView.d.ts +3 -0
- package/lib/typescript/lib/commonjs/internal/THEOplayerView.web.d.ts +3 -0
- package/lib/typescript/lib/commonjs/internal/cast/THEOplayerNativeAirplay.d.ts +9 -0
- package/lib/typescript/lib/commonjs/internal/cast/THEOplayerNativeCastApi.d.ts +12 -0
- package/lib/typescript/lib/commonjs/internal/cast/THEOplayerNativeChromecast.d.ts +11 -0
- package/lib/typescript/lib/commonjs/internal/cast/THEOplayerWebCastApi.d.ts +8 -0
- package/lib/typescript/lib/commonjs/internal/web/stub/CastButtonStub.d.ts +2 -0
- package/lib/typescript/lib/module/api/barrel.d.ts +1 -0
- package/lib/typescript/lib/module/api/cast/Airplay.d.ts +1 -0
- package/lib/typescript/lib/module/api/cast/CastAPI.d.ts +1 -0
- package/lib/typescript/lib/module/api/cast/CastConfiguration.d.ts +0 -0
- package/lib/typescript/lib/module/api/cast/CastState.d.ts +0 -0
- package/lib/typescript/lib/module/api/cast/Chromecast.d.ts +1 -0
- package/lib/typescript/lib/module/api/cast/barrel.d.ts +3 -0
- package/lib/typescript/lib/module/api/error/ChromecastError.d.ts +0 -0
- package/lib/typescript/lib/module/api/event/CastEvent.d.ts +1 -0
- package/lib/typescript/lib/module/api/event/TrackEvent.d.ts +2 -0
- package/lib/typescript/lib/module/api/event/barrel.d.ts +2 -1
- package/lib/typescript/lib/module/api/source/barrel.d.ts +1 -0
- package/lib/typescript/lib/module/api/source/metadata/MetadataDescription.d.ts +0 -0
- package/lib/typescript/lib/module/api/source/metadata/barrel.d.ts +1 -0
- package/lib/typescript/lib/module/internal/THEOplayerView.d.ts +3 -0
- package/lib/typescript/lib/module/internal/THEOplayerView.web.d.ts +3 -0
- package/lib/typescript/lib/module/internal/cast/THEOplayerNativeAirplay.d.ts +8 -0
- package/lib/typescript/lib/module/internal/cast/THEOplayerNativeCastApi.d.ts +11 -0
- package/lib/typescript/lib/module/internal/cast/THEOplayerNativeChromecast.d.ts +10 -0
- package/lib/typescript/lib/module/internal/cast/THEOplayerWebCastApi.d.ts +7 -0
- package/lib/typescript/lib/module/internal/web/stub/CastButtonStub.d.ts +2 -0
- package/lib/typescript/src/api/THEOplayerView.d.ts +21 -3
- package/lib/typescript/src/api/barrel.d.ts +1 -0
- package/lib/typescript/src/api/cast/Airplay.d.ts +27 -0
- package/lib/typescript/src/api/cast/CastAPI.d.ts +25 -0
- package/lib/typescript/src/api/cast/CastConfiguration.d.ts +41 -0
- package/lib/typescript/src/api/cast/CastState.d.ts +10 -0
- package/lib/typescript/src/api/cast/Chromecast.d.ts +39 -0
- package/lib/typescript/src/api/cast/barrel.d.ts +5 -0
- package/lib/typescript/src/api/config/PlayerConfiguration.d.ts +6 -1
- package/lib/typescript/src/api/error/ChromecastError.d.ts +34 -0
- package/lib/typescript/src/api/error/barrel.d.ts +1 -0
- package/lib/typescript/src/api/event/CastEvent.d.ts +21 -0
- package/lib/typescript/src/api/event/TrackEvent.d.ts +49 -3
- package/lib/typescript/src/api/event/barrel.d.ts +2 -1
- package/lib/typescript/src/api/source/SourceDescription.d.ts +7 -0
- package/lib/typescript/src/api/source/barrel.d.ts +1 -0
- package/lib/typescript/src/api/source/metadata/MetadataDescription.d.ts +12 -0
- package/lib/typescript/src/api/source/metadata/barrel.d.ts +1 -0
- package/lib/typescript/src/internal/THEOplayerView.d.ts +9 -1
- package/lib/typescript/src/internal/THEOplayerView.web.d.ts +7 -2
- package/lib/typescript/src/internal/cast/THEOplayerNativeAirplay.d.ts +9 -0
- package/lib/typescript/src/internal/cast/THEOplayerNativeCastApi.d.ts +10 -0
- package/lib/typescript/src/internal/cast/THEOplayerNativeChromecast.d.ts +11 -0
- package/lib/typescript/src/internal/cast/THEOplayerWebCastApi.d.ts +9 -0
- package/lib/typescript/src/internal/web/stub/CastButtonStub.d.ts +3 -0
- package/package.json +2 -2
- package/react-native-theoplayer.podspec +2 -2
- package/src/api/THEOplayerView.ts +25 -3
- package/src/api/barrel.ts +1 -0
- package/src/api/cast/Airplay.ts +31 -0
- package/src/api/cast/CastAPI.ts +30 -0
- package/src/api/cast/CastConfiguration.ts +44 -0
- package/src/api/cast/CastState.ts +10 -0
- package/src/api/cast/Chromecast.ts +45 -0
- package/src/api/cast/barrel.ts +5 -0
- package/src/api/config/PlayerConfiguration.ts +7 -1
- package/src/api/error/ChromecastError.ts +46 -0
- package/src/api/error/barrel.ts +1 -0
- package/src/api/event/CastEvent.ts +45 -0
- package/src/api/event/TrackEvent.ts +58 -2
- package/src/api/event/barrel.ts +2 -1
- package/src/api/source/SourceDescription.ts +8 -0
- package/src/api/source/barrel.ts +1 -0
- package/src/api/source/metadata/MetadataDescription.ts +13 -0
- package/src/api/source/metadata/barrel.ts +1 -0
- package/src/internal/THEOplayerView.tsx +35 -0
- package/src/internal/THEOplayerView.web.tsx +87 -19
- package/src/internal/cast/THEOplayerNativeAirplay.ts +22 -0
- package/src/internal/cast/THEOplayerNativeCastApi.ts +28 -0
- package/src/internal/cast/THEOplayerNativeChromecast.ts +30 -0
- package/src/internal/cast/THEOplayerWebCastApi.ts +21 -0
- package/src/internal/web/stub/CastButtonStub.tsx +7 -0
- package/android/src/main/java/com/theoplayer/PlayerConfigHelper.java +0 -70
- package/android/src/main/java/com/theoplayer/ReactTHEOplayerPackage.java +0 -32
- package/android/src/main/java/com/theoplayer/ReactTHEOplayerView.java +0 -525
- package/android/src/main/java/com/theoplayer/ReactTHEOplayerViewManager.java +0 -127
- package/android/src/main/java/com/theoplayer/SourceHelper.java +0 -362
- package/android/src/main/java/com/theoplayer/VideoEventEmitter.java +0 -442
- package/android/src/main/java/com/theoplayer/ads/AdEventAdapter.java +0 -92
- package/android/src/main/java/com/theoplayer/ads/AdInfo.java +0 -168
- package/android/src/main/java/com/theoplayer/ads/AdsModule.java +0 -152
- package/android/src/main/java/com/theoplayer/track/QualityListAdapter.java +0 -54
- package/android/src/main/java/com/theoplayer/track/QualityListFilter.java +0 -40
- package/android/src/main/java/com/theoplayer/track/TextTrackCueEventType.java +0 -11
- package/android/src/main/java/com/theoplayer/track/TrackEventType.java +0 -11
- package/android/src/main/java/com/theoplayer/track/TrackListInfo.java +0 -212
- package/android/src/main/java/com/theoplayer/util/ViewResolver.java +0 -42
- package/ios/custom/react-native-theoplayer_custom_ios.podspec +0 -36
|
@@ -0,0 +1,402 @@
|
|
|
1
|
+
package com.theoplayer.source
|
|
2
|
+
|
|
3
|
+
import android.text.TextUtils
|
|
4
|
+
import android.util.Log
|
|
5
|
+
import com.google.gson.Gson
|
|
6
|
+
import com.theoplayer.android.api.error.THEOplayerException
|
|
7
|
+
import com.facebook.react.bridge.ReadableMap
|
|
8
|
+
import com.theoplayer.android.api.source.SourceDescription
|
|
9
|
+
import com.theoplayer.android.api.source.TypedSource
|
|
10
|
+
import com.theoplayer.android.api.source.metadata.MetadataDescription
|
|
11
|
+
import com.theoplayer.android.api.source.addescription.AdDescription
|
|
12
|
+
import com.theoplayer.android.api.source.TextTrackDescription
|
|
13
|
+
import com.theoplayer.android.api.source.SourceType
|
|
14
|
+
import com.theoplayer.android.api.source.ssai.SsaiIntegration
|
|
15
|
+
import com.theoplayer.android.api.source.GoogleDaiTypedSource
|
|
16
|
+
import com.theoplayer.android.api.source.ssai.dai.GoogleDaiVodConfiguration
|
|
17
|
+
import com.theoplayer.android.api.source.ssai.dai.GoogleDaiLiveConfiguration
|
|
18
|
+
import com.theoplayer.android.api.source.ssai.YoSpaceDescription
|
|
19
|
+
import com.theoplayer.android.api.source.hls.HlsPlaybackConfiguration
|
|
20
|
+
import com.theoplayer.android.api.event.ads.AdIntegrationKind
|
|
21
|
+
import com.theoplayer.android.api.source.addescription.GoogleImaAdDescription
|
|
22
|
+
import com.theoplayer.android.api.player.track.texttrack.TextTrackKind
|
|
23
|
+
import com.theoplayer.android.api.source.metadata.ChromecastMetadataImage
|
|
24
|
+
import com.facebook.react.bridge.ReadableArray
|
|
25
|
+
import com.theoplayer.BuildConfig
|
|
26
|
+
import com.theoplayer.android.api.error.ErrorCode
|
|
27
|
+
import com.theoplayer.drm.ContentProtectionAdapter
|
|
28
|
+
import org.json.JSONArray
|
|
29
|
+
import org.json.JSONException
|
|
30
|
+
import org.json.JSONObject
|
|
31
|
+
import java.util.ArrayList
|
|
32
|
+
import java.util.HashMap
|
|
33
|
+
|
|
34
|
+
private const val TAG = "SourceAdapter"
|
|
35
|
+
private const val PROP_CONTENT_PROTECTION = "contentProtection"
|
|
36
|
+
private const val PROP_LIVE_OFFSET = "liveOffset"
|
|
37
|
+
private const val PROP_HLS_DATERANGE = "hlsDateRange"
|
|
38
|
+
private const val PROP_HLS_PLAYBACK_CONFIG = "hls"
|
|
39
|
+
private const val PROP_TIME_SERVER = "timeServer"
|
|
40
|
+
private const val PROP_METADATA = "metadata"
|
|
41
|
+
private const val PROP_SSAI = "ssai"
|
|
42
|
+
private const val PROP_TYPE = "type"
|
|
43
|
+
private const val PROP_SRC = "src"
|
|
44
|
+
private const val PROP_SOURCES = "sources"
|
|
45
|
+
private const val PROP_DEFAULT = "default"
|
|
46
|
+
private const val PROP_LABEL = "label"
|
|
47
|
+
private const val PROP_KIND = "kind"
|
|
48
|
+
private const val PROP_TIME_OFFSET = "timeOffset"
|
|
49
|
+
private const val PROP_INTEGRATION = "integration"
|
|
50
|
+
private const val PROP_TEXT_TRACKS = "textTracks"
|
|
51
|
+
private const val PROP_POSTER = "poster"
|
|
52
|
+
private const val PROP_ADS = "ads"
|
|
53
|
+
private const val PROP_AVAILABILITY_TYPE = "availabilityType"
|
|
54
|
+
private const val ERROR_DAI_NOT_ENABLED = "Google DAI support not enabled."
|
|
55
|
+
private const val ERROR_UNSUPPORTED_SSAI_INTEGRATION = "Unsupported SSAI integration"
|
|
56
|
+
private const val ERROR_MISSING_SSAI_INTEGRATION = "Missing SSAI integration"
|
|
57
|
+
private const val ERROR_IMA_NOT_ENABLED = "Google IMA support not enabled."
|
|
58
|
+
private const val ERROR_UNSUPPORTED_CSAI_INTEGRATION = "Unsupported CSAI integration"
|
|
59
|
+
private const val ERROR_MISSING_CSAI_INTEGRATION = "Missing CSAI integration"
|
|
60
|
+
|
|
61
|
+
class SourceAdapter {
|
|
62
|
+
private val gson = Gson()
|
|
63
|
+
|
|
64
|
+
@Throws(THEOplayerException::class)
|
|
65
|
+
fun parseSourceFromJS(source: ReadableMap): SourceDescription? {
|
|
66
|
+
val hashmap = eliminateReadables(source)
|
|
67
|
+
try {
|
|
68
|
+
val json = gson.toJson(hashmap)
|
|
69
|
+
val jsonSourceObject = JSONObject(json)
|
|
70
|
+
|
|
71
|
+
// typed sources
|
|
72
|
+
val typedSources = ArrayList<TypedSource>()
|
|
73
|
+
|
|
74
|
+
// sources can be an array or single object
|
|
75
|
+
val jsonSources = jsonSourceObject.optJSONArray(PROP_SOURCES)
|
|
76
|
+
if (jsonSources != null) {
|
|
77
|
+
for (i in 0 until jsonSources.length()) {
|
|
78
|
+
val typedSource = parseTypedSource(jsonSources[i] as JSONObject)
|
|
79
|
+
if (typedSource != null) {
|
|
80
|
+
typedSources.add(typedSource)
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
} else {
|
|
84
|
+
val typedSource = parseTypedSource(jsonSourceObject.getJSONObject(PROP_SOURCES))
|
|
85
|
+
if (typedSource != null) {
|
|
86
|
+
typedSources.add(typedSource)
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
// poster
|
|
91
|
+
val poster = jsonSourceObject.optString(PROP_POSTER)
|
|
92
|
+
|
|
93
|
+
// metadata
|
|
94
|
+
var metadataDescription: MetadataDescription? = null
|
|
95
|
+
val jsonMetadata = jsonSourceObject.optJSONObject(PROP_METADATA)
|
|
96
|
+
if (jsonMetadata != null) {
|
|
97
|
+
metadataDescription = parseMetadataDescription(jsonMetadata)
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
// ads
|
|
101
|
+
val jsonAds = jsonSourceObject.optJSONArray(PROP_ADS)
|
|
102
|
+
val ads = ArrayList<AdDescription>()
|
|
103
|
+
if (jsonAds != null) {
|
|
104
|
+
for (i in 0 until jsonAds.length()) {
|
|
105
|
+
val jsonAdDescription = jsonAds[i] as JSONObject
|
|
106
|
+
|
|
107
|
+
// Currently only ima-ads are supported.
|
|
108
|
+
ads.add(parseAdFromJS(jsonAdDescription))
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
// Side-loaded text tracks
|
|
113
|
+
val textTracks = jsonSourceObject.optJSONArray(PROP_TEXT_TRACKS)
|
|
114
|
+
val sideLoadedTextTracks = ArrayList<TextTrackDescription>()
|
|
115
|
+
if (textTracks != null) {
|
|
116
|
+
for (i in 0 until textTracks.length()) {
|
|
117
|
+
val jsonTextTrack = textTracks[i] as JSONObject
|
|
118
|
+
sideLoadedTextTracks.add(parseTextTrackFromJS(jsonTextTrack))
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
val builder = SourceDescription.Builder(*typedSources.toTypedArray())
|
|
122
|
+
.poster(poster)
|
|
123
|
+
.ads(*ads.toTypedArray())
|
|
124
|
+
.textTracks(*sideLoadedTextTracks.toTypedArray())
|
|
125
|
+
if (metadataDescription != null) {
|
|
126
|
+
builder.metadata(metadataDescription)
|
|
127
|
+
}
|
|
128
|
+
return builder.build()
|
|
129
|
+
} catch (e: JSONException) {
|
|
130
|
+
e.printStackTrace()
|
|
131
|
+
}
|
|
132
|
+
return null
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
@Throws(THEOplayerException::class)
|
|
136
|
+
private fun parseTypedSource(jsonTypedSource: JSONObject): TypedSource? {
|
|
137
|
+
try {
|
|
138
|
+
var tsBuilder = TypedSource.Builder(jsonTypedSource.optString(PROP_SRC))
|
|
139
|
+
val sourceType = parseSourceType(jsonTypedSource)
|
|
140
|
+
if (jsonTypedSource.has(PROP_SSAI)) {
|
|
141
|
+
val ssaiJson = jsonTypedSource.getJSONObject(PROP_SSAI)
|
|
142
|
+
|
|
143
|
+
// Check for valid SsaiIntegration
|
|
144
|
+
val ssaiIntegrationStr = ssaiJson.optString(PROP_INTEGRATION)
|
|
145
|
+
if (!TextUtils.isEmpty(ssaiIntegrationStr)) {
|
|
146
|
+
val ssaiIntegration = SsaiIntegration.from(ssaiIntegrationStr)
|
|
147
|
+
?: throw THEOplayerException(
|
|
148
|
+
ErrorCode.AD_ERROR,
|
|
149
|
+
"$ERROR_UNSUPPORTED_SSAI_INTEGRATION: $ssaiIntegrationStr"
|
|
150
|
+
)
|
|
151
|
+
when (ssaiIntegration) {
|
|
152
|
+
SsaiIntegration.GOOGLE_DAI -> {
|
|
153
|
+
if (!BuildConfig.EXTENSION_GOOGLE_DAI) {
|
|
154
|
+
throw THEOplayerException(ErrorCode.AD_ERROR, ERROR_DAI_NOT_ENABLED)
|
|
155
|
+
}
|
|
156
|
+
tsBuilder = if (ssaiJson.optString(PROP_AVAILABILITY_TYPE) == "vod") {
|
|
157
|
+
GoogleDaiTypedSource.Builder(
|
|
158
|
+
gson.fromJson(ssaiJson.toString(), GoogleDaiVodConfiguration::class.java)
|
|
159
|
+
)
|
|
160
|
+
} else {
|
|
161
|
+
GoogleDaiTypedSource.Builder(
|
|
162
|
+
gson.fromJson(ssaiJson.toString(), GoogleDaiLiveConfiguration::class.java)
|
|
163
|
+
)
|
|
164
|
+
}
|
|
165
|
+
// Prefer DASH if not SSAI type specified
|
|
166
|
+
if (sourceType == null) {
|
|
167
|
+
tsBuilder.type(SourceType.DASH)
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
SsaiIntegration.YOSPACE -> tsBuilder.ssai(
|
|
171
|
+
gson.fromJson(ssaiJson.toString(), YoSpaceDescription::class.java)
|
|
172
|
+
)
|
|
173
|
+
else -> throw THEOplayerException(
|
|
174
|
+
ErrorCode.AD_ERROR,
|
|
175
|
+
"$ERROR_UNSUPPORTED_SSAI_INTEGRATION: $ssaiIntegrationStr"
|
|
176
|
+
)
|
|
177
|
+
}
|
|
178
|
+
} else {
|
|
179
|
+
throw THEOplayerException(ErrorCode.AD_ERROR, ERROR_MISSING_SSAI_INTEGRATION)
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
if (sourceType != null) {
|
|
183
|
+
tsBuilder.type(sourceType)
|
|
184
|
+
}
|
|
185
|
+
if (jsonTypedSource.has(PROP_LIVE_OFFSET)) {
|
|
186
|
+
tsBuilder.liveOffset(jsonTypedSource.getDouble(PROP_LIVE_OFFSET))
|
|
187
|
+
}
|
|
188
|
+
if (jsonTypedSource.has(PROP_HLS_DATERANGE)) {
|
|
189
|
+
tsBuilder.hlsDateRange(jsonTypedSource.getBoolean(PROP_HLS_DATERANGE))
|
|
190
|
+
}
|
|
191
|
+
if (jsonTypedSource.has(PROP_HLS_PLAYBACK_CONFIG)) {
|
|
192
|
+
val hlsConfig = gson.fromJson(
|
|
193
|
+
jsonTypedSource[PROP_HLS_PLAYBACK_CONFIG].toString(),
|
|
194
|
+
HlsPlaybackConfiguration::class.java
|
|
195
|
+
)
|
|
196
|
+
tsBuilder.hls(hlsConfig)
|
|
197
|
+
}
|
|
198
|
+
if (jsonTypedSource.has(PROP_TIME_SERVER)) {
|
|
199
|
+
tsBuilder.timeServer(jsonTypedSource.getString(PROP_TIME_SERVER))
|
|
200
|
+
}
|
|
201
|
+
if (jsonTypedSource.has(PROP_CONTENT_PROTECTION)) {
|
|
202
|
+
val drmConfig = ContentProtectionAdapter.drmConfigurationFromJson(
|
|
203
|
+
jsonTypedSource.getJSONObject(PROP_CONTENT_PROTECTION)
|
|
204
|
+
)
|
|
205
|
+
if (drmConfig != null) {
|
|
206
|
+
tsBuilder.drm(drmConfig)
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
return tsBuilder.build()
|
|
210
|
+
} catch (e: JSONException) {
|
|
211
|
+
e.printStackTrace()
|
|
212
|
+
}
|
|
213
|
+
return null
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
@Throws(THEOplayerException::class)
|
|
217
|
+
fun parseAdFromJS(map: ReadableMap): AdDescription? {
|
|
218
|
+
val hashmap = eliminateReadables(map)
|
|
219
|
+
return try {
|
|
220
|
+
val jsonAdDescription = JSONObject(gson.toJson(hashmap))
|
|
221
|
+
parseAdFromJS(jsonAdDescription)
|
|
222
|
+
} catch (e: JSONException) {
|
|
223
|
+
e.printStackTrace()
|
|
224
|
+
null
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
private fun parseSourceType(jsonTypedSource: JSONObject): SourceType? {
|
|
229
|
+
val type = jsonTypedSource.optString(PROP_TYPE)
|
|
230
|
+
if (type.isNotEmpty()) {
|
|
231
|
+
if ("application/dash+xml" == type) {
|
|
232
|
+
return SourceType.DASH
|
|
233
|
+
}
|
|
234
|
+
if ("application/x-mpegurl" == type) {
|
|
235
|
+
return SourceType.HLSX
|
|
236
|
+
}
|
|
237
|
+
if ("application/vnd.theo.hesp+json" == type) {
|
|
238
|
+
return SourceType.HESP
|
|
239
|
+
}
|
|
240
|
+
if ("application/vnd.apple.mpegurl" == type) {
|
|
241
|
+
return SourceType.HLS
|
|
242
|
+
}
|
|
243
|
+
if ("video/mp4" == type) {
|
|
244
|
+
return SourceType.MP4
|
|
245
|
+
}
|
|
246
|
+
if ("audio/mpeg" == type) {
|
|
247
|
+
return SourceType.MP3
|
|
248
|
+
}
|
|
249
|
+
} else {
|
|
250
|
+
// No type given, check for known extension.
|
|
251
|
+
val src = jsonTypedSource.optString(PROP_SRC)
|
|
252
|
+
if (src.endsWith(".mpd")) {
|
|
253
|
+
return SourceType.DASH
|
|
254
|
+
}
|
|
255
|
+
if (src.endsWith(".m3u8")) {
|
|
256
|
+
return SourceType.HLSX
|
|
257
|
+
}
|
|
258
|
+
if (src.endsWith(".mp4")) {
|
|
259
|
+
return SourceType.MP4
|
|
260
|
+
}
|
|
261
|
+
if (src.endsWith(".mp3")) {
|
|
262
|
+
return SourceType.MP3
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
return null
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
@Throws(JSONException::class, THEOplayerException::class)
|
|
269
|
+
fun parseAdFromJS(jsonAdDescription: JSONObject): AdDescription {
|
|
270
|
+
val integrationKindStr = jsonAdDescription.optString(PROP_INTEGRATION)
|
|
271
|
+
return if (!TextUtils.isEmpty(integrationKindStr)) {
|
|
272
|
+
when (AdIntegrationKind.from(integrationKindStr)) {
|
|
273
|
+
AdIntegrationKind.GOOGLE_IMA -> parseImaAdFromJS(
|
|
274
|
+
jsonAdDescription
|
|
275
|
+
)
|
|
276
|
+
AdIntegrationKind.DEFAULT, AdIntegrationKind.THEO, AdIntegrationKind.FREEWHEEL, AdIntegrationKind.SPOTX -> {
|
|
277
|
+
throw THEOplayerException(
|
|
278
|
+
ErrorCode.AD_ERROR,
|
|
279
|
+
"$ERROR_UNSUPPORTED_CSAI_INTEGRATION: $integrationKindStr"
|
|
280
|
+
)
|
|
281
|
+
}
|
|
282
|
+
else -> {
|
|
283
|
+
throw THEOplayerException(
|
|
284
|
+
ErrorCode.AD_ERROR,
|
|
285
|
+
"$ERROR_UNSUPPORTED_CSAI_INTEGRATION: $integrationKindStr"
|
|
286
|
+
)
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
} else {
|
|
290
|
+
throw THEOplayerException(
|
|
291
|
+
ErrorCode.AD_ERROR,
|
|
292
|
+
"$ERROR_MISSING_CSAI_INTEGRATION: $integrationKindStr"
|
|
293
|
+
)
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
|
|
298
|
+
@Throws(THEOplayerException::class)
|
|
299
|
+
private fun parseImaAdFromJS(jsonAdDescription: JSONObject): GoogleImaAdDescription {
|
|
300
|
+
if (!BuildConfig.EXTENSION_GOOGLE_IMA) {
|
|
301
|
+
throw THEOplayerException(ErrorCode.AD_ERROR, ERROR_IMA_NOT_ENABLED)
|
|
302
|
+
}
|
|
303
|
+
val source: String
|
|
304
|
+
// Property `sources` is of type string | AdSource.
|
|
305
|
+
val sourceObj = jsonAdDescription.optJSONObject(PROP_SOURCES)
|
|
306
|
+
source = if (sourceObj != null) {
|
|
307
|
+
sourceObj.optString(PROP_SRC)
|
|
308
|
+
} else {
|
|
309
|
+
jsonAdDescription.optString(PROP_SOURCES)
|
|
310
|
+
}
|
|
311
|
+
return GoogleImaAdDescription.Builder(source)
|
|
312
|
+
.timeOffset(jsonAdDescription.optString(PROP_TIME_OFFSET))
|
|
313
|
+
.build()
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
@Throws(JSONException::class)
|
|
317
|
+
private fun parseTextTrackFromJS(jsonTextTrack: JSONObject): TextTrackDescription {
|
|
318
|
+
val builder = TextTrackDescription.Builder(jsonTextTrack.optString(PROP_SRC))
|
|
319
|
+
.isDefault(jsonTextTrack.optBoolean(PROP_DEFAULT))
|
|
320
|
+
.label(jsonTextTrack.optString(PROP_LABEL))
|
|
321
|
+
.kind(parseTextTrackKind(jsonTextTrack.optString(PROP_KIND))!!)
|
|
322
|
+
return builder.build()
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
private fun parseTextTrackKind(kind: String?): TextTrackKind? {
|
|
326
|
+
if (kind == null) {
|
|
327
|
+
return null
|
|
328
|
+
}
|
|
329
|
+
when (kind) {
|
|
330
|
+
"subtitles" -> return TextTrackKind.SUBTITLES
|
|
331
|
+
"metadata" -> return TextTrackKind.METADATA
|
|
332
|
+
"captions" -> return TextTrackKind.CAPTIONS
|
|
333
|
+
"chapters" -> return TextTrackKind.CHAPTERS
|
|
334
|
+
"descriptions" -> return TextTrackKind.DESCRIPTIONS
|
|
335
|
+
}
|
|
336
|
+
return null
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
private fun parseMetadataDescription(metadataDescription: JSONObject): MetadataDescription {
|
|
340
|
+
val metadata = HashMap<String, Any>()
|
|
341
|
+
val keys = metadataDescription.keys()
|
|
342
|
+
while (keys.hasNext()) {
|
|
343
|
+
val key = keys.next()
|
|
344
|
+
try {
|
|
345
|
+
if (key == "images") {
|
|
346
|
+
metadata[key] = parseMetadataImages(metadataDescription.getJSONArray(key))
|
|
347
|
+
} else {
|
|
348
|
+
metadata[key] = metadataDescription[key]
|
|
349
|
+
}
|
|
350
|
+
} catch (e: JSONException) {
|
|
351
|
+
Log.w(TAG, "Failed to parse metadata key $key")
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
return MetadataDescription(metadata)
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
@Throws(JSONException::class)
|
|
358
|
+
private fun parseMetadataImages(metadataImages: JSONArray): List<ChromecastMetadataImage> {
|
|
359
|
+
val imageList: MutableList<ChromecastMetadataImage> = ArrayList()
|
|
360
|
+
for (i in 0 until metadataImages.length()) {
|
|
361
|
+
imageList.add(parseMetadataImage(metadataImages.getJSONObject(i)))
|
|
362
|
+
}
|
|
363
|
+
return imageList
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
@Throws(JSONException::class)
|
|
367
|
+
private fun parseMetadataImage(metadataImage: JSONObject): ChromecastMetadataImage {
|
|
368
|
+
val width = if (metadataImage.has("width")) metadataImage.getInt("width") else null
|
|
369
|
+
val height = if (metadataImage.has("height")) metadataImage.getInt("height") else null
|
|
370
|
+
return ChromecastMetadataImage(metadataImage.optString("src"), width, height)
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
private fun eliminateReadables(readableMap: ReadableMap): HashMap<String, Any> {
|
|
374
|
+
val hashMap = readableMap.toHashMap()
|
|
375
|
+
val eliminatedHashMap = HashMap<String, Any>()
|
|
376
|
+
for (entry in hashMap.entries) {
|
|
377
|
+
var value = entry.value
|
|
378
|
+
if (value is ReadableMap) {
|
|
379
|
+
value = eliminateReadables(value)
|
|
380
|
+
} else if (value is ReadableArray) {
|
|
381
|
+
value = eliminateReadables(value)
|
|
382
|
+
}
|
|
383
|
+
eliminatedHashMap[entry.key] = value
|
|
384
|
+
}
|
|
385
|
+
return eliminatedHashMap
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
private fun eliminateReadables(readableArray: ReadableArray): ArrayList<Any> {
|
|
389
|
+
val arrayList = readableArray.toArrayList()
|
|
390
|
+
val eliminatedArrayList = ArrayList<Any>()
|
|
391
|
+
for (o in arrayList) {
|
|
392
|
+
var value = o
|
|
393
|
+
if (value is ReadableMap) {
|
|
394
|
+
value = eliminateReadables(value)
|
|
395
|
+
} else if (value is ReadableArray) {
|
|
396
|
+
value = eliminateReadables(value)
|
|
397
|
+
}
|
|
398
|
+
eliminatedArrayList.add(value)
|
|
399
|
+
}
|
|
400
|
+
return eliminatedArrayList
|
|
401
|
+
}
|
|
402
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
package com.theoplayer.track
|
|
2
|
+
|
|
3
|
+
import com.theoplayer.android.api.player.track.mediatrack.quality.Quality
|
|
4
|
+
import com.theoplayer.android.api.player.track.mediatrack.quality.QualityList
|
|
5
|
+
import java.util.*
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Adapts an Android List to a QualityList.
|
|
9
|
+
*/
|
|
10
|
+
class QualityListAdapter<Q : Quality> : QualityList<Q> {
|
|
11
|
+
private var qualities: MutableList<Q>
|
|
12
|
+
|
|
13
|
+
constructor(qualities: MutableList<Q>) {
|
|
14
|
+
this.qualities = qualities
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
constructor(qualities: QualityList<Q>) {
|
|
18
|
+
this.qualities = ArrayList()
|
|
19
|
+
for (quality in qualities) {
|
|
20
|
+
this.qualities.add(quality)
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
override fun length(): Int {
|
|
25
|
+
return qualities.size
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
override fun getItem(i: Int): Q? {
|
|
29
|
+
return if (i >= 0 && i < length()) qualities[i] else null
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
override fun iterator(): MutableIterator<Q?> {
|
|
33
|
+
return qualities.iterator()
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
fun asList(): List<Q> {
|
|
37
|
+
return qualities
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
fun sort(comparator: Comparator<Q>) {
|
|
41
|
+
Collections.sort(qualities, comparator)
|
|
42
|
+
}
|
|
43
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
package com.theoplayer.track
|
|
2
|
+
|
|
3
|
+
import com.theoplayer.android.api.player.track.mediatrack.quality.Quality
|
|
4
|
+
import com.theoplayer.android.api.player.track.mediatrack.quality.QualityList
|
|
5
|
+
import com.facebook.react.bridge.ReadableArray
|
|
6
|
+
import java.util.ArrayList
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* QualityListFilter allows filtering a QualityList.
|
|
10
|
+
*/
|
|
11
|
+
class QualityListFilter<Q : Quality>(private val qualities: QualityList<Q>) {
|
|
12
|
+
|
|
13
|
+
fun filterQualityList(uids: ReadableArray): QualityList<Q> {
|
|
14
|
+
return QualityListAdapter(filterList(uids))
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
private fun filterList(uids: ReadableArray): MutableList<Q> {
|
|
18
|
+
val filteredQualities: MutableList<Q> = ArrayList()
|
|
19
|
+
for (q in 0 until uids.size()) {
|
|
20
|
+
for (quality in qualities) {
|
|
21
|
+
if (uids.getInt(q) == quality.uid) {
|
|
22
|
+
filteredQualities.add(quality)
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
return filteredQualities
|
|
27
|
+
}
|
|
28
|
+
}
|