androidx / androidx/media

DefaultMediaItemConverter ignores AdsConfiguration when creating MediaQueueItem

Open
#590 3 comments 0 reactions 1 assignee View on GitHub

@marcbaechinger is already working on this.

Since Aug 18, 2023.

enhancement
Dominant language
Java
Stars
3k
Forks
955
Avg merge
12d 14h
Merged PRs (30d)
2

Description

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 android-media-github@google.com after filing this issue.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.