Is there any way to directly pass vast ad response to androidx media3 exo player instead of passing adTag url
Below is example of passing adTag url
private AdsLoader getClientSideAdsLoader(MediaItem.AdsConfiguration adsConfiguration) {
// The ads loader is reused for multiple playbacks, so that ad playback can resume.
if (clientSideAdsLoader == null) {
clientSideAdsLoader = new ImaAdsLoader.Builder(/* context= */ this)
.build();
}
clientSideAdsLoader.setPlayer(player);
return clientSideAdsLoader;
}
@Override
protected void onCreate(Bundle savedInstanceState) {
MediaSource.Factory mediaSourceFactory =
new DefaultMediaSourceFactory(this)
.setLocalAdInsertionComponents(this::getClientSideAdsLoader, /* adViewProvider= */ playerView);
player = new ExoPlayer.Builder(this)
.setMediaSourceFactory(mediaSourceFactory)
.build();
playerView.setPlayer(player);
MediaItem mediaItem =
new MediaItem.Builder()
.setUri("<DASH URI>")
.setAdsConfiguration(
new MediaItem.AdsConfiguration.Builder(Uri.parse("vast ad url")).build())
.build();
// Set the media item to be played.
player.setMediaItem(mediaItem);
// Prepare the player.
player.prepare();
// Start the playback.
player.play();
}
I went through the documentation of androidx.media3 exo player but couldn't find any way. For exo player 2.11, we can pass as below
ImaAdsLoader.Builder builder = new ImaAdsLoader.Builder(mContext);
ImaSdkSettings imaSdkSettings = ImaSdkFactory.getInstance().createImaSdkSettings();
builder = builder.setImaSdkSettings(imaSdkSettings);
ImaAdsLoader imaAdsLoader = builder.buildForAdsResponse(adResource);
is it possible to pass similary for androidx media3 exo player
String vmapXMLString = "<vmap:VMAP ........";
MediaItem mediaItem =
new MediaItem.Builder()
.setUri(<mpd_url>)
.setAdsConfiguration(
new MediaItem.AdsConfiguration.Builder(Util.getDataUriForString("text/xml",vmapXMLString)).build())
.build();