media icon indicating copy to clipboard operation
media copied to clipboard

DefaultMediaItemConverter ignores AdsConfiguration when creating MediaQueueItem

Open ziem opened this issue 2 years ago • 3 comments

Version

Media3 1.1.1

More version details

No response

Devices that reproduce the issue

All devices

Devices that do not reproduce the issue

No response

Reproducible in the demo app?

Yes

Reproduction steps

DefaultMediaItemConverter ignores AdsConfiguration when creating MediaQueueItem.

When constructing a new MediaItem, I can specify AdsConfiguration:

MediaItem.Builder()
    ...
    .setAdsConfiguration(adsConfiguration)
    .build()

Unfortunately, this field is not passed to the newly created MediaInfo/MediaQueueItem inside DefaultMediaItemConverter, thus preventing us from displaying ads when casting.

The workaround is to copy the DefaultMediaItemConverter with the following changes:

@Override
public MediaQueueItem toMediaQueueItem(MediaItem mediaItem) {
    ...

    VastAdsRequest vastAdsRequest = null;
    if (mediaItem.localConfiguration.adsConfiguration != null) {
        vastAdsRequest = new VastAdsRequest.Builder()
                .setAdTagUrl(mediaItem.localConfiguration.adsConfiguration.adTagUri.toString())
                .build();
    }
    MediaInfo mediaInfo =
            new MediaInfo.Builder(contentId)
                    .setStreamType(MediaInfo.STREAM_TYPE_BUFFERED)
                    .setContentType(mediaItem.localConfiguration.mimeType)
                    .setContentUrl(contentUrl)
                    .setMetadata(metadata)
                    .setCustomData(getCustomData(mediaItem))
                    .setVmapAdsRequest(vastAdsRequest)
                    .build();
    return new MediaQueueItem.Builder(mediaInfo).build();
}

I'm wondering, if this is something that should be supported out of the box.

Expected result

Ads are played when casting

Actual result

Ads are not played when casting

Media

Not applicable

Bug Report

  • [ ] You will email the zip file produced by adb bugreport to [email protected] after filing this issue.

ziem avatar Aug 18 '23 11:08 ziem

Ads are currently not supported with CastPlayer. I marked this issue as an enhacement.

marcbaechinger avatar Aug 18 '23 11:08 marcbaechinger

is there any update on this @marcbaechinger ? is there a plan for when this will be integrated ?

daroltidan avatar May 08 '24 11:05 daroltidan

There are no plans. Please see the initial report how you can do this by creating your own MediaItemConverter that creates a VastAdsRequest and includes it in the MediaQueueItem sent to the cast device.

marcbaechinger avatar May 08 '24 11:05 marcbaechinger