Name is required.
Email address is required.
Invalid email address
Answer is required.
Exceeding max length of 5KB

Mid Roll ads using IMA.

I am trying to add multiple ads using IMA in JW Player. Some how i am able to play one mid roll but not multiple ads. Can Someone please show me how to do that. A demo would be really useful. Attaching my code below for reference.

======================================= Code Starts Here =======================================
public void loadVideo(VideoURLModel videoItem) {
// Construct a new Ad
mVideoItem = videoItem.getPlayback_url();
Ad ad = new Ad(AdSource.IMA, "Ad_url");

Ad ad1 = new Ad(AdSource.IMA, "Ad_url");

// Construct a new AdBreak containing the Ad
// This AdBreak will play a midroll at 10%
AdBreak adBreak = new AdBreak("pre", ad);
AdBreak adBreak1 = new AdBreak("00:05:00:000",ad1);
AdBreak adBreak2 = new AdBreak("00:10:00:000",ad1);
AdBreak adBreak3 = new AdBreak("00:15:00:000",ad1);
AdBreak adBreak4 = new AdBreak("00:20:00:000",ad1);

// Create a new AdSchedule containing the AdBreak we just created
LinkedList<AdBreak> schedule = new LinkedList<>();

Log.i(TAG, "DDD-----------getDuration------------" + mPlayerView.getDuration());

// Using the PlaylistItem.Builder build a new PlaylistItem containing the schedule.
PlaylistItem item = new PlaylistItem.Builder()
.adSchedule(schedule) // Set the Ad Schedule

// Load the playlist item with the AdSchedule into the Player

======================================= Code ends here =======================================

3 Community Answers


JW Player Support Agent  
0 rated :

You do not need to write direct code for the IMA SDK with our player. You can schedule multiple mid-roll breaks directly in your player setup’s advertising: {} block.

advertising: {
client: ‘googima’,
schedule: {
adbreak1: {
offset: “10”,
tag: ‘//your_ad_tag.xml’
adbreak2: {
offset: “20”,
tag: ‘//your_ad_tag.xml’,

Please see for more details.


JW Player Support Agent  
0 rated :

My apologies, I did not realize you were trying to add these ad breaks in the Android SDK. I will escalate this to our Android SDK support engineers and ask them to reply directly to your e-mail as well as post a basic code example here.

Daniel Berger

JW Player Support Agent  
0 rated :

Hi Sujata,

My name is Daniel. I see that you also submitted an email to I will respond to you from your emailed question.

Thank you,

This question has received the maximum number of answers.