This project is read-only.

PlayerFramework.Advertising Multiple MidrollAdvertisement support ?

Topics: Windows 8 JavaScript
Dec 13, 2012 at 9:17 PM

Hi Guys,

Does "PlayerFramework.Advertising" supports multiple midrolladvertisement? I am having problem when user scroll to (seek) certain position on video. Video hangs and doesn't play anymore.

       setupAds: function (player) {
            var player = this.getPlayerObject();
            var numPreRolls = window.appSettings.videoSettings.numPreRolls;
            var numPostRolls = window.appSettings.videoSettings.numPostRolls;

            // this is an array
            var numMidRolls = window.appSettings.videoSettings.numMidRolls;
            while (numPreRolls-- > 0) {
                var preroll = new PlayerFramework.Advertising.PrerollAdvertisement();
                preroll.source = this.createAdSource();
            for (var i = 0; i <; i++) {
                var howManyAds = numMidRolls[i % numMidRolls.length];
                while (howManyAds-- > 0) {
                    var midroll = new PlayerFramework.Advertising.MidrollAdvertisement();
                    midroll.source = this.createAdSource();
                    midroll.time =[i];

            while(numPostRolls-- > 0) {
                var postroll = new PlayerFramework.Advertising.PostrollAdvertisement();
                postroll.source = this.createAdSource();

            AdHandlerPlugin.bind("adstarted", function () {
        createAdSource: function () {
            var adSource = new Microsoft.PlayerFramework.Js.Advertising.RemoteAdSource();
            adSource.type = Microsoft.VideoAdvertising.VastAdPayloadHandler.adType;
            adSource.uri = new Windows.Foundation.Uri(VideoData.pageObject.videoAdURL);
            return adSource;

Dec 14, 2012 at 5:51 PM

Hello, yes multiple mid-rolls are supported. I don't see anything wrong with your code but am unable to duplicate the problem. Would you be able to either send me a full repro or tell me how to modify the sample (vast.js) to demonstrate the problem. Here's what I tried in vast.js which worked correctly.

var prerollAd = new PlayerFramework.Advertising.PrerollAdvertisement();
prerollAd.source = new Microsoft.PlayerFramework.Js.Advertising.RemoteAdSource();
prerollAd.source.type = Microsoft.VideoAdvertising.VastAdPayloadHandler.adType;
prerollAd.source.uri = new Windows.Foundation.Uri("");

var midrollAd1 = new PlayerFramework.Advertising.MidrollAdvertisement();
midrollAd1.source = new Microsoft.PlayerFramework.Js.Advertising.RemoteAdSource();
midrollAd1.source.type = Microsoft.VideoAdvertising.VastAdPayloadHandler.adType;
midrollAd1.source.uri = new Windows.Foundation.Uri("");
midrollAd1.time = 10;

var midrollAd2 = new PlayerFramework.Advertising.MidrollAdvertisement();
midrollAd2.source = new Microsoft.PlayerFramework.Js.Advertising.RemoteAdSource();
midrollAd2.source.type = Microsoft.VideoAdvertising.VastAdPayloadHandler.adType;
midrollAd2.source.uri = new Windows.Foundation.Uri("");
midrollAd2.time = 20;

var postrollAd = new PlayerFramework.Advertising.PostrollAdvertisement();
postrollAd.source = new Microsoft.PlayerFramework.Js.Advertising.RemoteAdSource();
postrollAd.source.type = Microsoft.VideoAdvertising.VastAdPayloadHandler.adType;
postrollAd.source.uri = new Windows.Foundation.Uri("");

var mediaPlayerElement = element.querySelector("[data-win-control='PlayerFramework.MediaPlayer']");
mediaPlayer = mediaPlayerElement.winControl;
Dec 14, 2012 at 9:41 PM
Edited Dec 17, 2012 at 8:04 PM

Thanks for looking into it !!

Can you please try one more test where you try to seek @ 25 seconds. So you are bypassing 10 and 20 second intervals for midroll? For me Ad will play for one of the midroll and video freezes. Is same happening for you can you please check? If you seek @ 15 seconds (> 10 and < 20) it will work as expected.

So here could be couple of things which could be possible. We are trying to enable midroll on DRM content. Below is the VAST;show=glee;sz=320x240;pr=win8;dcmt=text/xml

<VAST xsi:noNamespaceSchemaLocation="vast.xsd" version="2.0">
  <Ad id="21916511">
      <Description>video ad</Description>
        <Creative sequence="1" AdID="dddd92067311">
              <Tracking event="start"></Tracking>
              <Tracking event="firstQuartile"></Tracking>
              <Tracking event="midpoint"></Tracking>
              <Tracking event="thirdQuartile"></Tracking>
              <Tracking event="complete"></Tracking>
              <Tracking event="mute"></Tracking>
              <Tracking event="unmute"></Tracking>
              <Tracking event="rewind"></Tracking>
              <Tracking event="pause"></Tracking>
              <Tracking event="resume"></Tracking>
              <Tracking event="fullscreen"></Tracking>
              <Tracking event="acceptInvitation"></Tracking>
              <Tracking event="creativeView"></Tracking>
              <ClickThrough id="GDFP"></ClickThrough>
              <MediaFile id="GDFP" delivery="progressive" bitrate="878" width="852" height="480" type="video/mp4" scalable="false" maintainAspectRatio="false"></MediaFile>
        <Extension type="geo">

What we are trying to do is try injecting ad @ interval of 802,1167,1508 seconds on DRM video. When you try to seek anything > 1167 that's when Ad plays and video hangs. If I seek position greater than 802 and less than 1167 it plays fine. I tried to put (hardcoded) ad url ( you provided in your sample code (xBox Ad) and it behaved same way hanging when I try to seek video @ multiple midroll ad. I hope this might help you. Please let me know if you need more information.