简体   繁体   中英

Exoplayer with preroll and dynamic ad insertion

I want to make work my DASH stream with preroll and DAI. For now, I was able to make: DASH + preroll working and DASH + dai. But all three not

dash + dai:

val dashMediaSource = DashMediaSource.Factory(dashChunkSourceFactory, manifestDataSourceFactory)
            .createMediaSource(
                MediaItem.Builder()
                    .setUri(Uri.parse(URLDAI))  //diff
                    .setDrmConfiguration(
                        MediaItem.DrmConfiguration.Builder(drmSchemeUuid)
                            .setLicenseUri(DRM_LICENSE_URL).build()
                    )
                    .setMimeType(MimeTypes.APPLICATION_MPD)
                    .setTag(null)
                    .build()
            )

  playerView.setMediaSource(adsMediaSource)
    playerView.prepare()

dash + preroll

val dashMediaSource = DashMediaSource.Factory(dashChunkSourceFactory, manifestDataSourceFactory)
            .createMediaSource(
                MediaItem.Builder()
                    .setUri(Uri.parse(URL))  //diff
                    .setDrmConfiguration(
                        MediaItem.DrmConfiguration.Builder(drmSchemeUuid)
                            .setLicenseUri(DRM_LICENSE_URL).build()
                    )
                    .setMimeType(MimeTypes.APPLICATION_MPD)
                    .setTag(null)
                    .build()
            )

val dataSpec = DataSpec(Uri.parse(PREROLL))
val imaSdkSettings = ImaSdkFactory.getInstance().createImaSdkSettings()
val imaAdsLoader = ImaAdsLoader.Builder(this).setImaSdkSettings(imaSdkSettings).build()
imaAdsLoader.setPlayer(playerView)
val adsMediaSource = AdsMediaSource(mediaSource, dataSpec, 0, DefaultMediaSourceFactory(this), imaAdsLoader, binding.playerView)
playerView.setMediaSource(adsMediaSource)
playerView.prepare()

But if I combine both I get:

com.google.android.exoplayer2.upstream.Loader$UnexpectedLoaderException: Unexpected IllegalArgumentException: null

How can I have all three workings: preroll + dai + dash ( drm widevine) in exoplayer 2.18.1?

Thanks

It might not like the .setTag(null) part; either remove that or provide String .

And I also find it strange that you access playerView ...and not player ; for comparison:

player.setMediaSource(adsMediaSource)
player.prepare()

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM