Skip to content

Commit

Permalink
Add sourceSets to support breaking ima change
Browse files Browse the repository at this point in the history
  • Loading branch information
daytime-em committed Sep 17, 2024
1 parent 4161496 commit 17bd877
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 1 deletion.
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)
}
}
16 changes: 16 additions & 0 deletions app/src/compatFrom1_3/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.
* See the sourceSet defs for more details
*/

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.fromBundle(it) }
?.let { VersionCompat.adsLoaderStateFromBundle(it) }
}

override fun onResume() {
Expand Down

0 comments on commit 17bd877

Please sign in to comment.