Advertising Placement

Topics: Windows 8 JavaScript
Sep 18, 2012 at 7:21 PM

Hey, again, sorry if this is an obvious question - but I'm not seeing any sort of advertising documentation other to discuss the overall architecture.

So, I'm basically pulling what I need from the samples, and I'm able to play an ad, however I'd prefer it be inside the video frame (including when the user chooses full screen).  Currently, the video sprite is showing underneath the MMPPF player in the samples and my project.

Is there a way to put this inside the frame?  I don't see any positioning properties with intellisense (but it IS Javascript).  

Also, would love to know how to construct ads a more basic way if possible.  For numerous reasons on this project I need to construct ads on the fly, and can't schedule or use VAST.  Right now, I'm creating a media file, appending to a new creative linear, appending THAT to a new ad pod, and then setting THAT to a newly created ad source.

I'm not finding any documentation to steer me to an easier way.

thanks!

Sep 18, 2012 at 8:12 PM

Oops, never mind - <link href="/Microsoft.PlayerFramework.Js.Advertising/css/advertising.css" rel="stylesheet"> in the example source should probably be   <link href="/Microsoft.PlayerFramework.Js.Advertising/css/PlayerFramework.Advertising.css" rel="stylesheet">

Love to hear if there's a less verbose way to create a simple programmatic ad though.

Coordinator
Sep 18, 2012 at 8:34 PM

Hi Ben, you might want to take a look at the "Clip ad" sample included with the source download. Here's how to use it. For more complex ads, you can create your own VAST model (see programmatic ad sample for this).

var midrollAd = new PlayerFramework.Advertising.MidrollAdvertisement();
midrollAd.source = new Microsoft.PlayerFramework.Js.Advertising.AdSource();
midrollAd.source.type = Microsoft.VideoAdvertising.ClipAdPayloadHandler.adType;
midrollAd.source.payload = new Microsoft.PlayerFramework.Js.Advertising.ClipAdPayload();
midrollAd.source.payload.mediaSource = new Windows.Foundation.Uri("http://smf.blob.core.windows.net/samples/ads/media/XBOX_HD_DEMO_700_2_000_700_4x3.wmv");
midrollAd.source.payload.mimeType = "video/x-ms-wmv";
midrollAd.time = 5;

mediaPlayer.adSchedulerPlugin.advertisements.push(midrollAd);
Sep 18, 2012 at 9:42 PM

Thanks, I saw the clip ad example, and it does look simpler, however I'd prefer not to use scheduling given the nature of what I'm working on - so I believe midroll ads are out.  If I could do basically what you did above and have something I can pass on to player.adHandlerPlugin.playAd(), I'd be happy.

Coordinator
Sep 18, 2012 at 10:15 PM

I see; in that case, check out the programmatic ad sample. To do your own scheduling, you can just call:

mediaPlayer.adHandlerPlugin.playAd(adSource).done(
    function () {
        console.log("Ad played.");
    },
    function () {
        console.error("Ad failed.");
    }
);

(where adSource is the same object set to midrollAd.source in the example above)

Sep 19, 2012 at 4:35 PM

Perfect, thanks.  I was stuck a little bit previously because I was looking for an ad type to use instead of MidrollAdvertisement that I would set the .source property of.