# Can I have multiple ads schedule?

**URL:** <https://community.bitmovin.com/t/can-i-have-multiple-ads-schedule/2030>\
**Category:** Support\
**Tags:** live-streaming, web\
**Created:** [June 7, 2023, 2:33am UTC](https://community.bitmovin.com/t/can-i-have-multiple-ads-schedule/2030 "2023-06-07T02:33:45Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![digital.licensing](https://avatars.discourse-cdn.com/v4/letter/d/b9e5f3/32.png) [@digital.licensing](https://community.bitmovin.com/u/digital.licensing)\
**Post date:** [June 7, 2023, 2:33am UTC](https://community.bitmovin.com/t/can-i-have-multiple-ads-schedule/2030/1 "2023-06-07T02:33:45Z")

</div>

Is there any ways we can add multiple ads in one video, For example, one preroll ads and one ads in mid-roll/or any insertions in video.

---

<div class="post-metadata">

**Author:** ![ludovic.michaud](https://sea1.discourse-cdn.com/flex015/user_avatar/community.bitmovin.com/ludovic.michaud/32/811_2.png) [@ludovic.michaud](https://community.bitmovin.com/u/ludovic.michaud)\
**Post date:** [June 7, 2023, 2:41am UTC](https://community.bitmovin.com/t/can-i-have-multiple-ads-schedule/2030/2 "2023-06-07T02:41:31Z")

</div>

Yes, you can add an array of ads with different positions, as shown in the following example

```auto
conf.advertising = {
  adBreaks: [{
    tag: {
      url: 'http://your.ad.provider/vmap-manifest.xml',
      type: 'vmap'
    },
  }, {
    tag: {
      url: 'http://your.ad.provider/vast-manifest.xml',
      type: 'vast'
    },
    replaceContentDuration: 5,
    persistent: true,
    id: 'pre-roll-1',
    position: 'pre',
  }, {
    tag: {
      url: 'http://your.ad.provider/vast-manifest.xml',
      type: 'vast'
    },
    id: 'mid-roll-1',
    position: '00:08:30.000',
    preloadOffset: 5
  }, {
    tag: {
      url: 'http://your.ad.provider/vast-manifest.xml',
      type: 'vast'
    },
    persistent: true,
    id: 'post-roll-1',
    position: 'post',
    preloadOffset: 5
  }],
}

```

(source [AdvertisingConfig | Bitmovin Player API 8.120.0](https://cdn.bitmovin.com/player/web/8/docs/interfaces/advertising.advertisingconfig.html))

Let us know in case you have any questions

---

<div class="post-metadata">

**Author:** ![digital.licensing](https://avatars.discourse-cdn.com/v4/letter/d/b9e5f3/32.png) [@digital.licensing](https://community.bitmovin.com/u/digital.licensing)\
**Post date:** [June 7, 2023, 3:41am UTC](https://community.bitmovin.com/t/can-i-have-multiple-ads-schedule/2030/3 "2023-06-07T03:41:50Z")

</div>

Thanks Ludo, you are a great champion! Does this work on live stream as well? as we cannot predict how long the live stream will be?

---

<div class="post-metadata">

**Author:** ![digital.licensing](https://avatars.discourse-cdn.com/v4/letter/d/b9e5f3/32.png) [@digital.licensing](https://community.bitmovin.com/u/digital.licensing)\
**Post date:** [June 7, 2023, 3:57am UTC](https://community.bitmovin.com/t/can-i-have-multiple-ads-schedule/2030/4 "2023-06-07T03:57:18Z")

</div>

And also does the ads time will be included in the whole video time? cause I got a issue like this: the whole video time is 15s long, ads video time is around 15s as well. I set up a pre-roll ads and a mid-roll ads with the position: “pre” and position:“50%” . the mid-roll was expected to start to play at around 8 seconds in the video. but actually the mid-roll ads was played afterwards the pro-roll ads. is there any way we can fix this? many thanks

---

<div class="post-metadata">

**Author:** ![ludovic.michaud](https://sea1.discourse-cdn.com/flex015/user_avatar/community.bitmovin.com/ludovic.michaud/32/811_2.png) [@ludovic.michaud](https://community.bitmovin.com/u/ludovic.michaud)\
**Post date:** [June 7, 2023, 3:16pm UTC](https://community.bitmovin.com/t/can-i-have-multiple-ads-schedule/2030/5 "2023-06-07T15:16:20Z")

</div>

You can schedule ads on live streams dynamically with the `schedule` API.

Example

```auto
player.ads.schedule({
  tag: {
    url: "https://pubads.g.doubleclick.net/gampad/ads?iu=/21775744923/external/single_ad_samples&sz=640x480&cust_params=sample_ct%3Dlinear&ciu_szs=300x250%2C728x90&gdfp_req=1&output=vast&unviewed_position_start=1&env=vp&impl=s&correlator=",
    type: "vast"
  },
  id: 'Ad',
  position: "pre"
});

```

---

<div class="post-metadata">

**Author:** ![ludovic.michaud](https://sea1.discourse-cdn.com/flex015/user_avatar/community.bitmovin.com/ludovic.michaud/32/811_2.png) [@ludovic.michaud](https://community.bitmovin.com/u/ludovic.michaud)\
**Post date:** [June 7, 2023, 3:17pm UTC](https://community.bitmovin.com/t/can-i-have-multiple-ads-schedule/2030/6 "2023-06-07T15:17:48Z")

</div>

The ads don’t replace the video by default unless you specify it in the configuration  
[https://cdn.bitmovin.com/player/web/8/docs/interfaces/advertising.adtagconfig.html#replacecontentduration](https://cdn.bitmovin.com/player/web/8/docs/interfaces/advertising.adtagconfig.html#replacecontentduration)

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex015/uploads/bitmovin/original/1X/1ab86334145095b0af9c5b924fa3ae6d920b6482.png) [@system](https://community.bitmovin.com/u/system)\
**Post date:** [June 8, 2023, 1:20am UTC](https://community.bitmovin.com/t/can-i-have-multiple-ads-schedule/2030/7 "2023-06-08T01:20:58Z")

</div>

This topic was automatically closed 60 minutes after the last reply. New replies are no longer allowed.
