DefaultMediaItemConverter ignores AdsConfiguration when creating MediaQueueItem
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 bugreportto [email protected] after filing this issue.
Ads are currently not supported with CastPlayer. I marked this issue as an enhacement.
is there any update on this @marcbaechinger ? is there a plan for when this will be integrated ?
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.