From 931faee3758a71ebfb7b3a12f61206f6280610ba Mon Sep 17 00:00:00 2001 From: OlegRyz Date: Thu, 2 Apr 2026 16:16:34 +0200 Subject: [PATCH 1/2] Remove theoplayer connector dependencies from common module --- .../optiviewads/OptiviewAdsSourceManager.kt | 24 ++++++++++++++ .../sample/ads/optiviewads/PlayerActivity.kt | 2 +- common/build.gradle.kts | 2 -- .../theoplayer/sample/common/SourceManager.kt | 32 ++----------------- .../millicast/MillicastSourceManager.kt | 17 ++++++++++ .../streaming/millicast/PlayerActivity.kt | 2 +- 6 files changed, 45 insertions(+), 34 deletions(-) create mode 100644 advertising-optiview-ads/src/main/java/com/theoplayer/sample/ads/optiviewads/OptiviewAdsSourceManager.kt create mode 100644 streaming-millicast/src/main/java/com/theoplayer/sample/streaming/millicast/MillicastSourceManager.kt diff --git a/advertising-optiview-ads/src/main/java/com/theoplayer/sample/ads/optiviewads/OptiviewAdsSourceManager.kt b/advertising-optiview-ads/src/main/java/com/theoplayer/sample/ads/optiviewads/OptiviewAdsSourceManager.kt new file mode 100644 index 0000000..cf1de5c --- /dev/null +++ b/advertising-optiview-ads/src/main/java/com/theoplayer/sample/ads/optiviewads/OptiviewAdsSourceManager.kt @@ -0,0 +1,24 @@ +package com.theoplayer.sample.ads.optiviewads + +import com.theoplayer.android.api.ads.theoads.TheoAdDescription +import com.theoplayer.android.api.source.SourceDescription +import com.theoplayer.android.api.source.SourceType +import com.theoplayer.android.api.source.TypedSource + +object OptiviewAdsSourceManager { + val THEOADS: SourceDescription by lazy { + SourceDescription.Builder( + TypedSource.Builder("https://example.com/manifest.m3u8") + .type(SourceType.HLS) + .hlsDateRange(true) // The flag needs to be set to `true` as the ad markers are done using `EXT-X-DATERANGE` tags. + .build() + ).ads( + TheoAdDescription( + networkCode = "network-code-here", + customAssetKey = "asset-key-here", + backdropDoubleBox = "https://example.com/double.box.svg", + backdropLShape = "https://example.com/L-shape.svg" + ) + ).build() + } +} \ No newline at end of file diff --git a/advertising-optiview-ads/src/main/java/com/theoplayer/sample/ads/optiviewads/PlayerActivity.kt b/advertising-optiview-ads/src/main/java/com/theoplayer/sample/ads/optiviewads/PlayerActivity.kt index 474f574..7941207 100644 --- a/advertising-optiview-ads/src/main/java/com/theoplayer/sample/ads/optiviewads/PlayerActivity.kt +++ b/advertising-optiview-ads/src/main/java/com/theoplayer/sample/ads/optiviewads/PlayerActivity.kt @@ -52,7 +52,7 @@ class PlayerActivity : ComponentActivity() { LaunchedEffect(player) { // Configuring the player with a SourceDescription object. - theoPlayer.source = SourceManager.THEOADS + theoPlayer.source = OptiviewAdsSourceManager.THEOADS // Set autoplay to start video whenever player is visible. theoPlayer.isAutoplay = true diff --git a/common/build.gradle.kts b/common/build.gradle.kts index cdc6f2f..a2e30bd 100644 --- a/common/build.gradle.kts +++ b/common/build.gradle.kts @@ -41,6 +41,4 @@ dependencies { implementation(libs.material3) implementation(libs.ui) api(libs.theoplayer) - api(libs.theoplayer.connector.theoads) - api(libs.theoplayer.connector.millicast) } diff --git a/common/src/main/java/com/theoplayer/sample/common/SourceManager.kt b/common/src/main/java/com/theoplayer/sample/common/SourceManager.kt index 06b3cb2..04a3f63 100644 --- a/common/src/main/java/com/theoplayer/sample/common/SourceManager.kt +++ b/common/src/main/java/com/theoplayer/sample/common/SourceManager.kt @@ -1,7 +1,5 @@ package com.theoplayer.sample.common -import com.theoplayer.android.api.ads.theoads.TheoAdDescription -import com.theoplayer.android.api.millicast.MillicastSource import com.theoplayer.android.api.source.GoogleDaiTypedSource import com.theoplayer.android.api.source.SourceDescription import com.theoplayer.android.api.source.SourceType @@ -18,8 +16,7 @@ import com.theoplayer.android.api.theolive.TheoLiveSource import java.util.Collections -class SourceManager private constructor() { - companion object { +object SourceManager { val BIP_BOP_HLS: SourceDescription by lazy { SourceDescription .Builder( @@ -269,21 +266,7 @@ class SourceManager private constructor() { .build() ).build() } - val THEOADS: SourceDescription by lazy { - SourceDescription.Builder( - TypedSource.Builder("https://example.com/manifest.m3u8") - .type(SourceType.HLS) - .hlsDateRange(true) // The flag needs to be set to `true` as the ad markers are done using `EXT-X-DATERANGE` tags. - .build() - ).ads( - TheoAdDescription( - networkCode = "network-code-here", - customAssetKey = "asset-key-here", - backdropDoubleBox = "https://example.com/double.box.svg", - backdropLShape = "https://example.com/L-shape.svg" - ) - ).build() - } + val THEOLIVE: SourceDescription by lazy { SourceDescription.Builder( TheoLiveSource( @@ -291,15 +274,4 @@ class SourceManager private constructor() { ) ).build() } - val MILLICAST: SourceDescription by lazy { - SourceDescription.Builder( - MillicastSource( - src = "multiview", - streamAccountId = "k9Mwad", - apiUrl = "https://director.millicast.com/api/director/subscribe", -// subscriberToken = "" // This is only required for subscribing to secure streams and should be omitted otherwise. - ) - ).build() - } - } } \ No newline at end of file diff --git a/streaming-millicast/src/main/java/com/theoplayer/sample/streaming/millicast/MillicastSourceManager.kt b/streaming-millicast/src/main/java/com/theoplayer/sample/streaming/millicast/MillicastSourceManager.kt new file mode 100644 index 0000000..890f29e --- /dev/null +++ b/streaming-millicast/src/main/java/com/theoplayer/sample/streaming/millicast/MillicastSourceManager.kt @@ -0,0 +1,17 @@ +package com.theoplayer.sample.streaming.millicast + +import com.theoplayer.android.api.millicast.MillicastSource +import com.theoplayer.android.api.source.SourceDescription + +object MillicastSourceManager { + val MILLICAST: SourceDescription by lazy { + SourceDescription.Builder( + MillicastSource( + src = "multiview", + streamAccountId = "k9Mwad", + apiUrl = "https://director.millicast.com/api/director/subscribe", +// subscriberToken = "" // This is only required for subscribing to secure streams and should be omitted otherwise. + ) + ).build() + } +} \ No newline at end of file diff --git a/streaming-millicast/src/main/java/com/theoplayer/sample/streaming/millicast/PlayerActivity.kt b/streaming-millicast/src/main/java/com/theoplayer/sample/streaming/millicast/PlayerActivity.kt index cd47518..6972b80 100644 --- a/streaming-millicast/src/main/java/com/theoplayer/sample/streaming/millicast/PlayerActivity.kt +++ b/streaming-millicast/src/main/java/com/theoplayer/sample/streaming/millicast/PlayerActivity.kt @@ -57,7 +57,7 @@ class PlayerActivity : ComponentActivity() { theoplayerView.settings.setAllowBackgroundPlayback(true) // Configuring the player with a SourceDescription object. - theoPlayer.source = SourceManager.MILLICAST + theoPlayer.source = MillicastSourceManager.MILLICAST // Set autoplay to start video whenever player is visible. theoPlayer.isAutoplay = true From 018f172c69e4fe2fad305efd3eb2bacf0d673a08 Mon Sep 17 00:00:00 2001 From: OlegRyz Date: Thu, 2 Apr 2026 16:17:43 +0200 Subject: [PATCH 2/2] Add desugaring required by IMA library --- advertising-optiview-ads/build.gradle.kts | 2 ++ google-dai/build.gradle.kts | 2 ++ google-ima/build.gradle.kts | 2 ++ gradle/libs.versions.toml | 2 ++ 4 files changed, 8 insertions(+) diff --git a/advertising-optiview-ads/build.gradle.kts b/advertising-optiview-ads/build.gradle.kts index 30de672..426d6ec 100644 --- a/advertising-optiview-ads/build.gradle.kts +++ b/advertising-optiview-ads/build.gradle.kts @@ -34,6 +34,7 @@ android { compileOptions { sourceCompatibility = JavaVersion.VERSION_17 targetCompatibility = JavaVersion.VERSION_17 + isCoreLibraryDesugaringEnabled = true } } @@ -45,6 +46,7 @@ kotlin { } dependencies { + coreLibraryDesugaring(libs.desugar.jdk.libs) implementation(project(":common")) implementation(libs.compose.runtime) implementation(platform(libs.compose.bom)) diff --git a/google-dai/build.gradle.kts b/google-dai/build.gradle.kts index 38c6e39..6b7e931 100644 --- a/google-dai/build.gradle.kts +++ b/google-dai/build.gradle.kts @@ -34,6 +34,7 @@ android { compileOptions { sourceCompatibility = JavaVersion.VERSION_17 targetCompatibility = JavaVersion.VERSION_17 + isCoreLibraryDesugaringEnabled = true } } @@ -45,6 +46,7 @@ kotlin { } dependencies { + coreLibraryDesugaring(libs.desugar.jdk.libs) implementation(project(":common")) implementation(libs.compose.runtime) implementation(platform(libs.compose.bom)) diff --git a/google-ima/build.gradle.kts b/google-ima/build.gradle.kts index 60310f2..6355265 100644 --- a/google-ima/build.gradle.kts +++ b/google-ima/build.gradle.kts @@ -34,6 +34,7 @@ android { compileOptions { sourceCompatibility = JavaVersion.VERSION_17 targetCompatibility = JavaVersion.VERSION_17 + isCoreLibraryDesugaringEnabled = true } } @@ -45,6 +46,7 @@ kotlin { } dependencies { + coreLibraryDesugaring(libs.desugar.jdk.libs) implementation(project(":common")) implementation(libs.compose.runtime) implementation(platform(libs.compose.bom)) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index e952d59..ee201e1 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -1,6 +1,7 @@ [versions] appcompat = "1.7.1" constraintlayout = "2.2.1" +desugarJdkLibs = "2.1.5" gson = "2.13.2" media = "1.7.1" recyclerview = "1.4.0" @@ -26,6 +27,7 @@ serialization = "1.10.0" [libraries] appcompat = { module = "androidx.appcompat:appcompat", version.ref = "appcompat" } constraintlayout = { module = "androidx.constraintlayout:constraintlayout", version.ref = "constraintlayout" } +desugar-jdk-libs = { module = "com.android.tools:desugar_jdk_libs", version.ref = "desugarJdkLibs" } gradle-plugin = { group = "com.android.tools.build", name = "gradle", version.ref = "gradle" } gson = { module = "com.google.code.gson:gson", version.ref = "gson" } kotlin = { group = "org.jetbrains.kotlin", name = "kotlin-gradle-plugin", version.ref = "kotlin" }