Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for media3 v1.4 #93

Merged
merged 11 commits into from
Sep 18, 2024
69 changes: 59 additions & 10 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,32 @@ android {
flavorDimensions = ["media3"]
productFlavors {
At_latest { dimension "media3" }
// This module does not currently need different src sets for different media3 versions.
// We still need to declare different flavors so we can create version-specific variants
at_1_0 { dimension "media3" }
at_1_1 { dimension "media3" }
at_1_2 { dimension "media3" }
at_1_3 { dimension "media3" }
at_1_4 { dimension "media3" }
}

sourceSets {
At_latest {
java.srcDirs += "src/compatFrom1_0/java"
}
at_1_0 {
java.srcDirs += "src/compatFrom1_0/java"
}
at_1_1 {
java.srcDirs += "src/compatFrom1_0/java"
}
at_1_2 {
java.srcDirs += "src/compatFrom1_0/java"
}
at_1_3 {
java.srcDirs += "src/compatFrom1_3/java"
}
at_1_4 {
java.srcDirs += "src/compatFrom1_3/java"
}
}

buildTypes {
Expand Down Expand Up @@ -87,37 +107,66 @@ dependencies {
//noinspection GradleDependency
at_1_0Implementation "androidx.media3:media3-exoplayer-rtsp:1.0.0"

//noinspection GradleDependency
at_1_1Implementation "androidx.media3:media3-exoplayer:1.1.1"
//noinspection GradleDependency
at_1_1Implementation "androidx.media3:media3-session:1.1.1"
//noinspection GradleDependency
at_1_1Implementation "androidx.media3:media3-ui:1.1.1"
//noinspection GradleDependency
at_1_1Implementation "androidx.media3:media3-exoplayer-ima:1.1.1"
//noinspection GradleDependency
at_1_1Implementation "androidx.media3:media3-exoplayer-dash:1.1.1"
//noinspection GradleDependency
at_1_1Implementation "androidx.media3:media3-exoplayer-hls:1.1.1"
//noinspection GradleDependency
at_1_1Implementation "androidx.media3:media3-exoplayer-rtsp:1.1.1"

//noinspection GradleDependency
at_1_2Implementation "androidx.media3:media3-exoplayer:1.2.0"
//noinspection GradleDependency
at_1_2Implementation "androidx.media3:media3-session:1.2.0"
//noinspection GradleDependency
at_1_2Implementation "androidx.media3:media3-ui:1.2.0"
//noinspection GradleDependency
at_1_2Implementation "androidx.media3:media3-exoplayer-ima:1.2.0"
//noinspection GradleDependency
at_1_2Implementation "androidx.media3:media3-exoplayer-dash:1.2.0"
//noinspection GradleDependency
at_1_2Implementation "androidx.media3:media3-exoplayer-hls:1.2.0"
//noinspection GradleDependency
at_1_2Implementation "androidx.media3:media3-exoplayer-rtsp:1.2.0"


//noinspection GradleDependency
at_1_3Implementation "androidx.media3:media3-exoplayer:1.3.0"
//noinspection GradleDependency
at_1_3Implementation "androidx.media3:media3-session:1.3.0"
//noinspection GradleDependency
at_1_3Implementation "androidx.media3:media3-ui:1.3.0"
//noinspection GradleDependency
at_1_3Implementation "androidx.media3:media3-exoplayer-ima:1.3.0"
//noinspection GradleDependency
at_1_3Implementation "androidx.media3:media3-exoplayer-dash:1.3.0"
//noinspection GradleDependency
at_1_3Implementation "androidx.media3:media3-exoplayer-hls:1.3.0"
//noinspection GradleDependency
at_1_3Implementation "androidx.media3:media3-exoplayer-rtsp:1.3.0"

At_latestImplementation "androidx.media3:media3-exoplayer:1.3.1"
At_latestImplementation "androidx.media3:media3-session:1.3.1"
At_latestImplementation "androidx.media3:media3-ui:1.3.1"
At_latestImplementation "androidx.media3:media3-exoplayer-ima:1.3.1"
At_latestImplementation "androidx.media3:media3-exoplayer-dash:1.3.1"
At_latestImplementation "androidx.media3:media3-exoplayer-hls:1.3.1"
At_latestImplementation "androidx.media3:media3-exoplayer-rtsp:1.3.1"
at_1_4Implementation "androidx.media3:media3-exoplayer:1.4.1"
at_1_4Implementation "androidx.media3:media3-session:1.4.1"
at_1_4Implementation "androidx.media3:media3-ui:1.4.1"
at_1_4Implementation "androidx.media3:media3-exoplayer-ima:1.4.1"
at_1_4Implementation "androidx.media3:media3-exoplayer-dash:1.4.1"
at_1_4Implementation "androidx.media3:media3-exoplayer-hls:1.4.1"
at_1_4Implementation "androidx.media3:media3-exoplayer-rtsp:1.4.1"

At_latestImplementation "androidx.media3:media3-exoplayer:1.4.1"
At_latestImplementation "androidx.media3:media3-session:1.4.1"
At_latestImplementation "androidx.media3:media3-ui:1.4.1"
At_latestImplementation "androidx.media3:media3-exoplayer-ima:1.4.1"
At_latestImplementation "androidx.media3:media3-exoplayer-dash:1.4.1"
At_latestImplementation "androidx.media3:media3-exoplayer-hls:1.4.1"
At_latestImplementation "androidx.media3:media3-exoplayer-rtsp:1.4.1"

implementation 'androidx.core:core-ktx:1.12.0'
implementation 'androidx.appcompat:appcompat:1.6.1'
Expand Down
16 changes: 16 additions & 0 deletions app/src/compatFrom1_0/java/VersionCompat.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import android.os.Bundle
import androidx.media3.common.util.UnstableApi
import androidx.media3.exoplayer.ima.ImaServerSideAdInsertionMediaSource

/*
* VersionCompat.kt: Functions with different Variants for different media3
* versions. There are other version of this file for other variants. Look
* in the source set defs for more details
*/

object VersionCompat {
@androidx.annotation.OptIn(UnstableApi::class)
fun adsLoaderStateFromBundle(bundle: Bundle): ImaServerSideAdInsertionMediaSource.AdsLoader.State {
return ImaServerSideAdInsertionMediaSource.AdsLoader.State.CREATOR.fromBundle(bundle)
}
}
17 changes: 17 additions & 0 deletions app/src/compatFrom1_3/java/VersionCompat.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import android.os.Bundle
import androidx.media3.common.util.UnstableApi
import androidx.media3.exoplayer.ima.ImaServerSideAdInsertionMediaSource

/**
* Functions with different Variants for different media3 versions. There are other version of this
* file for other variants. See the sourceSet defs for more details
*
* Customers probably don't need a class like this. We have one because we support older versions of
* media3, so we need variants
*/
object VersionCompat {
@androidx.annotation.OptIn(UnstableApi::class)
fun adsLoaderStateFromBundle(bundle: Bundle): ImaServerSideAdInsertionMediaSource.AdsLoader.State {
return ImaServerSideAdInsertionMediaSource.AdsLoader.State.fromBundle(bundle)
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.mux.stats.muxdatasdkformedia3.examples.ima

import VersionCompat
import android.net.Uri
import android.os.Bundle
import android.os.PersistableBundle
Expand Down Expand Up @@ -60,7 +61,7 @@ class ImaServerAdsActivity : AppCompatActivity() {
window.addFlags(View.KEEP_SCREEN_ON)

adsLoaderState = savedInstanceState?.getBundle(EXTRA_ADS_LOADER_STATE)
?.let { AdsLoader.State.CREATOR.fromBundle(it) }
?.let { VersionCompat.adsLoaderStateFromBundle(it) }
}

override fun onResume() {
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ plugins {
id 'com.android.application' version '8.5.2' apply false
id 'com.android.library' version '8.5.2' apply false
id 'org.jetbrains.kotlin.android' version '1.9.24' apply false
id 'com.mux.gradle.android.mux-android-distribution' version '1.2.1' apply false
id 'com.mux.gradle.android.mux-android-distribution' version '1.3.0' apply false
id "org.jetbrains.dokka" version "1.6.10"
}

Expand Down
12 changes: 9 additions & 3 deletions library-exo/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ android {
at_1_1 { dimension "media3" }
at_1_2 { dimension "media3" }
at_1_3 { dimension "media3" }
at_1_4 { dimension "media3" }
}

buildTypes {
Expand Down Expand Up @@ -64,7 +65,7 @@ muxDistribution {
publicReleaseIf releaseIfCmdFlag("publicRelease")

// TODO: This is kinda clumsy, packageJavadocs should be a function not a property probably
packageJavadocs = releaseOnTag().call()
packageJavadocs = releaseIfCmdFlag("publicRelease").call()
publishIf { it.containsIgnoreCase("release") }
artifactoryConfig {
contextUrl = "https://muxinc.jfrog.io/artifactory/"
Expand Down Expand Up @@ -123,9 +124,14 @@ dependencies {
at_1_3CompileOnly "androidx.media3:media3-exoplayer-hls:1.3.0"

//noinspection GradleDependency
At_latestApi "androidx.media3:media3-exoplayer:1.3.0"
at_1_4Api "androidx.media3:media3-exoplayer:1.4.0"
//noinspection GradleDependency
At_latestCompileOnly "androidx.media3:media3-exoplayer-hls:1.3.0"
at_1_4CompileOnly "androidx.media3:media3-exoplayer-hls:1.4.0"

//noinspection GradleDependency
At_latestApi "androidx.media3:media3-exoplayer:1.4.0"
//noinspection GradleDependency
At_latestCompileOnly "androidx.media3:media3-exoplayer-hls:1.4.0"

testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.5'
Expand Down
13 changes: 9 additions & 4 deletions library-ima/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ android {
at_1_1 { dimension "media3" }
at_1_2 { dimension "media3" }
at_1_3 { dimension "media3" }
at_1_4 { dimension "media3" }
}

buildTypes {
Expand Down Expand Up @@ -64,7 +65,7 @@ muxDistribution {
publicReleaseIf releaseIfCmdFlag("publicRelease")

// TODO: This is kinda clumsy, packageJavadocs should be a function not a property probably
packageJavadocs = releaseOnTag().call()
packageJavadocs = releaseIfCmdFlag("publicRelease").call()
publishIf { it.containsIgnoreCase("release") }
artifactoryConfig {
contextUrl = "https://muxinc.jfrog.io/artifactory/"
Expand Down Expand Up @@ -100,7 +101,7 @@ dependencies {
debugImplementation project(':library')

// note- 3.30.0 and 3.30.1 are marked as broken by google, so don't use
// api 'com.google.ads.interactivemedia.v3:interactivemedia:3.29.0'
// api 'com.google.ads.interactivemedia.v3:interactivemedia:3.29.0'
// implementation is used so it doesn't pollute customers namespace
implementation "com.mux:utils-kt:$coreVersion"

Expand All @@ -119,8 +120,12 @@ dependencies {
at_1_3Api "androidx.media3:media3-exoplayer-ima:1.3.0"
//noinspection GradleDependency
at_1_3Api "androidx.media3:media3-exoplayer:1.3.0"
At_latestApi "androidx.media3:media3-exoplayer-ima:1.3.0"
At_latestApi "androidx.media3:media3-exoplayer:1.3.0"
//noinspection GradleDependency
at_1_4Api "androidx.media3:media3-exoplayer-ima:1.4.0"
//noinspection GradleDependency
at_1_4Api "androidx.media3:media3-exoplayer:1.4.0"
At_latestApi "androidx.media3:media3-exoplayer-ima:1.4.0"
At_latestApi "androidx.media3:media3-exoplayer:1.4.0"

implementation 'androidx.core:core-ktx:1.13.1'

Expand Down
11 changes: 9 additions & 2 deletions library/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ android {
dimension "media3"
buildConfigField "String", "MEDIA3_VERSION", "\"1.3.x\""
}
at_1_4 {
dimension "media3"
buildConfigField "String", "MEDIA3_VERSION", "\"1.4.x\""
}
}

buildTypes {
Expand Down Expand Up @@ -76,7 +80,7 @@ muxDistribution {
publicReleaseIf releaseIfCmdFlag("publicRelease")

// TODO: This is kinda clumsy, packageJavadocs should be a function not a property probably
packageJavadocs = releaseOnTag().call()
packageJavadocs = releaseIfCmdFlag("publicRelease").call()
publishIf { it.containsIgnoreCase("release") }
artifactoryConfig {
contextUrl = "https://muxinc.jfrog.io/artifactory/"
Expand Down Expand Up @@ -117,9 +121,12 @@ dependencies {
at_1_0Api "androidx.media3:media3-common:1.0.0"
//noinspection GradleDependency
at_1_1Api "androidx.media3:media3-common:1.1.0"
//noinspection GradleDependency
at_1_2Api "androidx.media3:media3-common:1.2.0"
//noinspection GradleDependency
at_1_3Api "androidx.media3:media3-common:1.3.0"
At_latestApi "androidx.media3:media3-common:1.3.0"
at_1_4Api "androidx.media3:media3-common:1.4.0"
At_latestApi "androidx.media3:media3-common:1.4.0"

implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.7.3"

Expand Down