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

Releases/v1.6.0 #100

Merged
merged 8 commits into from
Oct 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,6 @@ object Constants {
const val VOD_TEST_URL_BIG_BUCK_BUNNY = "https://test-streams.mux.dev/x36xhzz/x36xhzz.m3u8"
const val AD_TAG_SIMPLE_W_MID_ROLL = "https://pubads.g.doubleclick.net/gampad/ads?iu=/21775744923/external/vmap_ad_samples&sz=640x480&cust_params=sample_ar%3Dpremidpostoptimizedpod&ciu_szs=300x250&gdfp_req=1&ad_rule=1&output=vmap&unviewed_position_start=1&env=vp&impl=s&cmsid=496&vid=short_onecue&correlator="
const val AD_TAG_COMPLEX = "https://pubads.g.doubleclick.net/gampad/ads?iu=/21775744923/external/vmap_ad_samples&sz=640x480&cust_params=sample_ar%3Dpremidpostlongpod&ciu_szs=300x250&gdfp_req=1&ad_rule=1&output=vmap&unviewed_position_start=1&env=vp&impl=s&cmsid=496&vid=short_onecue&correlator="
const val AD_TAG_BROKEN_REDIRECT = "https://pubads.g.doubleclick.net/gampad/ads?iu=/21775744923/external/single_ad_samples&sz=640x480&cust_params=sample_ct%3Dredirecterror&ciu_szs=300x250%2C728x90&gdfp_req=1&output=vast&unviewed_position_start=1&env=vp&impl=s&correlator="
const val SSAI_ASSET_TAG_BUCK = "c-rArva4ShKVIAkNfy6HUQ"
}
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ class ImaClientAdsActivity : AppCompatActivity() {
val customerData = CustomerData(
CustomerPlayerData().apply { },
CustomerVideoData().apply {
title = "Mux Data SDK for Media3 Demo"
videoTitle = "Mux Data for Media3 - CSAI Ads"
},
CustomerViewData().apply { }
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ class ImaServerAdsActivity : AppCompatActivity() {
val customerData = CustomerData(
CustomerPlayerData().apply { },
CustomerVideoData().apply {
title = "Mux Data SDK for Media3 Demo"
videoTitle = "Mux Data SDK for Media3 - Server Ads"
},
CustomerViewData().apply { }
)
Expand Down
6 changes: 3 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import org.jetbrains.dokka.gradle.DokkaTaskPartial
plugins {
id 'com.android.application' version '8.5.2' apply false
id 'com.android.library' version '8.5.2' apply false
id 'com.android.application' version '8.6.0' apply false
id 'com.android.library' version '8.6.0' apply false
id 'org.jetbrains.kotlin.android' version '1.9.24' apply false
id 'com.mux.gradle.android.mux-android-distribution' version '1.3.0' apply false
id "org.jetbrains.dokka" version "1.6.10"
}

allprojects {
project.ext {
coreVersion = '1.4.0'
coreVersion = '1.4.2'
}

tasks.withType(DokkaTaskPartial.class) {
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Fri Nov 18 08:57:39 PST 2022
distributionBase=GRADLE_USER_HOME
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-bin.zip
distributionPath=wrapper/dists
zipStorePath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,15 @@ import androidx.media3.common.util.UnstableApi
import androidx.media3.exoplayer.ima.ImaAdsLoader
import com.google.ads.interactivemedia.v3.api.AdErrorEvent.AdErrorListener
import com.google.ads.interactivemedia.v3.api.AdEvent.AdEventListener
import com.google.ads.interactivemedia.v3.api.player.VideoAdPlayer.VideoAdPlayerCallback
import com.mux.stats.sdk.muxstats.MuxStatsSdkMedia3

/**
* Monitors the [ImaAdsLoader] created by the given [ImaAdsLoader.Builder].
*
* Mux must take ownership of the [AdErrorListener] and [AdEventListener] for this ads loader, but
* you can provide your own listeners and logic using the provided optional params
* Mux must take ownership of the [AdErrorListener], [AdEventListener], and [VideoAdPlayerCallback]
* for this ads loader, but you can provide your own listeners and logic using the provided optional
* params.
*
* @param muxStats The [MuxStatsSdkMedia3] instance monitoring your player
* @param customerAdEventListener Optional. An [AdEventListener] with your apps custom ad-event handling
Expand All @@ -23,15 +25,18 @@ fun ImaAdsLoader.Builder.monitorWith(
muxStats: MuxStatsSdkMedia3<*>,
customerAdEventListener: AdEventListener = AdEventListener { },
customerAdErrorListener: AdErrorListener = AdErrorListener { },
customerAdPlayerAdCallback: VideoAdPlayerCallback? = null
): ImaAdsLoader.Builder {
val adsListener = MuxImaAdsListener.newListener(
{ muxStats },
muxStats,
customerAdEventListener,
customerAdErrorListener
customerAdErrorListener,
customerAdPlayerAdCallback,
)

setAdEventListener(adsListener)
setAdErrorListener(adsListener)
setVideoAdPlayerCallback(adsListener)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍


return this
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ import com.google.ads.interactivemedia.v3.api.AdErrorEvent
import com.google.ads.interactivemedia.v3.api.AdErrorEvent.AdErrorListener
import com.google.ads.interactivemedia.v3.api.AdEvent
import com.google.ads.interactivemedia.v3.api.AdEvent.AdEventListener
import com.google.ads.interactivemedia.v3.api.player.AdMediaInfo
import com.google.ads.interactivemedia.v3.api.player.VideoAdPlayer.VideoAdPlayerCallback
import com.google.ads.interactivemedia.v3.api.player.VideoProgressUpdate
import com.mux.android.util.oneOf
import com.mux.stats.sdk.core.events.playback.*
import com.mux.stats.sdk.core.model.AdData
Expand All @@ -24,7 +27,8 @@ class MuxImaAdsListener private constructor(
private val provider: Provider,
private val customerAdEventListener: AdEventListener = AdEventListener { },
private val customerAdErrorListener: AdErrorListener = AdErrorListener { },
) : AdErrorListener, AdEventListener {
private val customerVideoAdPlayerCallback: VideoAdPlayerCallback? = null,
) : AdErrorListener, AdEventListener, VideoAdPlayerCallback {

/** The ExoPlayer that is playing the ads */
private val exoPlayer: Player? get() = provider.boundPlayer
Expand Down Expand Up @@ -222,6 +226,50 @@ class MuxImaAdsListener private constructor(
adCollector?.dispatch(event)
}


/** VideoAdPlayerCallback */
override fun onAdProgress(mediaInfo: AdMediaInfo, progress: VideoProgressUpdate) {
customerVideoAdPlayerCallback?.onAdProgress(mediaInfo, progress)
}

override fun onBuffering(mediaInfo: AdMediaInfo) {
customerVideoAdPlayerCallback?.onBuffering(mediaInfo)
}

override fun onContentComplete() {
customerVideoAdPlayerCallback?.onContentComplete()
}

override fun onEnded(mediaInfo: AdMediaInfo) {
customerVideoAdPlayerCallback?.onEnded(mediaInfo)
}

override fun onError(mediaInfo: AdMediaInfo) {
adCollector?.dispatch(MuxAdErrorEvent(null))
customerVideoAdPlayerCallback?.onError(mediaInfo)
}

override fun onLoaded(mediaInfo: AdMediaInfo) {
adCollector?.dispatch(AdResponseEvent(null))
customerVideoAdPlayerCallback?.onLoaded(mediaInfo)
}

override fun onPause(mediaInfo: AdMediaInfo) {
customerVideoAdPlayerCallback?.onPause(mediaInfo)
}

override fun onPlay(mediaInfo: AdMediaInfo) {
customerVideoAdPlayerCallback?.onPlay(mediaInfo)
}

override fun onResume(mediaInfo: AdMediaInfo) {
customerVideoAdPlayerCallback?.onResume(mediaInfo)
}

override fun onVolumeChanged(mediaInfo: AdMediaInfo, p1: Int) {
customerVideoAdPlayerCallback?.onVolumeChanged(mediaInfo, p1)
}

companion object {
private const val TAG = "MuxImaAdsListener"

Expand All @@ -233,28 +281,30 @@ class MuxImaAdsListener private constructor(
muxSdk: MuxStatsSdkMedia3<*>,
customerAdEventListener: AdEventListener = AdEventListener { },
customerAdErrorListener: AdErrorListener = AdErrorListener { },
customerVideoAdPlayerCallback: VideoAdPlayerCallback? = null,
): MuxImaAdsListener {
return MuxImaAdsListener(
Provider { muxSdk },
customerAdEventListener,
customerAdErrorListener,
customerVideoAdPlayerCallback
)
}
/**
* Creates a new [MuxImaAdsListener] based on the given [MuxStatsSdkMedia3]
*/
@JvmStatic
fun newListener(
muxSdkProvider:() -> MuxStatsSdkMedia3<*>?,
customerAdEventListener: AdEventListener = AdEventListener { },
customerAdErrorListener: AdErrorListener = AdErrorListener { },
): MuxImaAdsListener {
return MuxImaAdsListener(
Provider { muxSdkProvider() },
customerAdEventListener,
customerAdErrorListener
)
}
/**
* Creates a new [MuxImaAdsListener] based on the given [MuxStatsSdkMedia3]
*/
@JvmStatic
fun newListener(
muxSdkProvider:() -> MuxStatsSdkMedia3<*>?,
customerAdEventListener: AdEventListener = AdEventListener { },
customerAdErrorListener: AdErrorListener = AdErrorListener { },
): MuxImaAdsListener {
return MuxImaAdsListener(
Provider { muxSdkProvider() },
customerAdEventListener,
customerAdErrorListener
)
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,18 @@ package com.mux.stats.sdk.media3_ima
import androidx.annotation.OptIn
import androidx.media3.common.util.UnstableApi
import androidx.media3.exoplayer.ima.ImaAdsLoader
import androidx.media3.exoplayer.ima.ImaServerSideAdInsertionMediaSource
import androidx.media3.exoplayer.ima.ImaServerSideAdInsertionMediaSource.AdsLoader
import com.google.ads.interactivemedia.v3.api.AdErrorEvent.AdErrorListener
import com.google.ads.interactivemedia.v3.api.AdEvent.AdEventListener
import com.mux.stats.sdk.muxstats.MuxStatsSdkMedia3

/**
* Monitors the [ImaAdsLoader] created by the given [ImaAdsLoader.Builder].
* Monitors the [ImaServerSideAdInsertionMediaSource.AdsLoader] created by the a
* [ImaServerSideAdInsertionMediaSource.AdsLoader.Builder].
*
* This method is just for DAI server-side ad-insertion. If you're doing Client-Side Ad Insertion
* (CSAI), use [ImaAdsLoader.Builder.monitorWith]
*
* Mux must take ownership of the [AdErrorListener] and [AdEventListener] for this ads loader, but
* you can provide your own listeners and logic using the provided optional params
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import com.mux.stats.sdk.core.events.EventBus
import com.mux.stats.sdk.core.events.playback.AdEvent
import com.mux.stats.sdk.core.model.CustomerData
import com.mux.stats.sdk.core.model.CustomerVideoData
import com.mux.stats.sdk.core.util.MuxLogger
import com.mux.stats.sdk.muxstats.media3.BuildConfig
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
Expand Down Expand Up @@ -61,6 +62,7 @@ class MuxStatsSdkMedia3<P : Player> @OptIn(UnstableApi::class) @JvmOverloads con
),
makeNetworkRequest = { iDevice -> network ?: MuxNetwork(iDevice, CoroutineScope(Dispatchers.IO)) }
) {

/**
* Collects events related to ad playback and reports them. If you are using Google IMA, you don't
* need to interact with this class directly. Instead, use the `media3-ima` library provided by
Expand Down
Loading