" ALL_ADS_COMPLETED" event is not triggered. - Android

0 views
Skip to first unread message

Shakir Ansari

unread,
3:30 PM (3 hours ago) 3:30 PM
to Interactive Media Ads SDK
Hello team,

I want to fetch and play a video ad using exoplayer ima(androidx.media3:media3-exoplayer-ima). My problem is that I don't have the content's uri to set in the  ImaAdsLoader object. if I am not setting the content uri using the setUri() method of the ImaAdsLoader object, it plays the ad but it is not giving the "ALL_ADS_COMPLETED" or "COMPLETE" event. Is there an alternative to this where there is no need to set the content uri and get the " ALL_ADS_COMPLETED" or "COMPLETE" event.

i am using the below dependencies
implementation 'com.google.ads.interactivemedia.v3:interactivemedia:3.29.0'
//media3 exoplayer
implementation "androidx.media3:media3-exoplayer:1.2.0"
implementation "androidx.media3:media3-ui:1.2.0"
implementation "androidx.media3:media3-exoplayer-ima:1.2.0"
implementation "androidx.media3:media3-datasource-okhttp:1.2.0"


Related Code snippet:
playerView = PlayerView(context!!)

            // Create an AdsLoader.
            adsLoader = ImaAdsLoader.Builder(context!!)
                .setAdEventListener(this)  // here i am not using setUri() method because i don't have the content's uri
                .build()

            // Set up the factory for media sources, passing the ads loader and ad view providers.
            val dataSourceFactory: DataSource.Factory = DefaultDataSource.Factory(context!!)

            val mediaSourceFactory: MediaSource.Factory =
                DefaultMediaSourceFactory(dataSourceFactory)
                    .setLocalAdInsertionComponents(
                        { adsLoader },
                        playerView!!
                    )


            // Create an ExoPlayer and set it as the player for content and ads.
            player = ExoPlayer.Builder(context!!).setMediaSourceFactory(mediaSourceFactory).build()
            playerView!!.player = player
            playerView!!.useController = false
            adsLoader!!.setPlayer(player)

            val mediaItem = MediaItem.Builder()
                .setUri(Uri.parse(""))
                .setAdsConfiguration(
                    MediaItem.AdsConfiguration.Builder(Uri.parse(vastAdTagUri!!)).build()
                )
                .build()

            // Prepare the content and ad to be played with the SimpleExoPlayer.
            player!!.setMediaItem(mediaItem)
            player!!.prepare()
            // Set PlayWhenReady. If true, content and ads will autoplay.
            player!!.playWhenReady = false
Reply all
Reply to author
Forward
0 new messages