By default, the player framework will only play ads that are supported natively by Windows 8. However, if you need to allow smooth streaming ads to play in the player framework, you can easily enable this with a few lines of code.

This document describes how to enable smooth streaming ads in the player framework (regardless of whether or not you are playing smooth streaming main content).

Step by step instructions for Windows 8 JavaScript apps

1. If you have already added the smooth streaming support to your app, skip to step 7.

2. Install the Visual Studio Extension SDK for the Smooth Streaming Client (this is a separate download).

3. Add 'Microsoft Smooth Streaming Client SDK for Windows 8' and 'Microsoft Visual C++ Runtime Package' to your project References. Under References --> Microsoft--> Extensions

4. Add 'Microsoft Player Framework Adaptive Streaming Plugin' to your project references. Under References --> Windows --> Extensions
js-step-4.png

5. Add the following script tag after your existing player framework references.
<!-- PlayerFramework references -->
<link href="/Microsoft.PlayerFramework.Js/css/PlayerFramework-dark.css" rel="stylesheet">
<script src="/Microsoft.PlayerFramework.Js/js/PlayerFramework.js"></script>

<!-- PlayerFramework.Adaptive references -->
<script src="/Microsoft.PlayerFramework.Js.Adaptive/js/PlayerFramework.Adaptive.js"></script>

6. Set your target platform to x86, x64, or ARM. Because the Smooth Streaming Client SDK is written in unmanaged code, AnyCPU will not work and instead you must build your application for each platform that you wish to support.
xaml-step-6a.png
xaml-step-6b.png

7. Register the smooth streaming mime types with the ad player factory plugin (this is a plugin that helps create the player for the ad).
mediaPlayer.adPlayerFactoryPlugin.supportedVideoMimeTypes.push("text/xml");
mediaPlayer.adPlayerFactoryPlugin.supportedVideoMimeTypes.push("application/vnd.ms-sstr+xml");

8. That's all, both smooth streaming and progressive download ads should now play.

Step by step instructions for Windows 8 Xaml apps

1. If you have already added the smooth streaming support to your app, skip to step 7.

2. Install the Visual Studio Extension SDK for the Smooth Streaming Client (this is a separate download).

3. Add 'Microsoft Smooth Streaming Client SDK for Windows 8' and 'Microsoft Visual C++ Runtime Package' to your project References. Under References --> Microsoft--> Extensions

4. Add 'Microsoft Player Framework Adaptive Streaming Plugin' to your project references. Under References --> Windows --> Extensions
xaml-step-4.png

5. Modify the MediaPlayer control Xaml to add the Adaptive plugin to the plugins collection on the player framework.
xmlns:adaptive="using:Microsoft.PlayerFramework.Adaptive"

<mmppf:MediaPlayer Source="...">
    <mmppf:MediaPlayer.Plugins>
        <adaptive:AdaptivePlugin />
    </mmppf:MediaPlayer.Plugins>
</mmppf:MediaPlayer>
Note: alternatively, you can add the plugin in your code behind

6. Target your app to x86, x64, or ARM. Because the IIS Smooth Streaming Client is written in unmanaged code, AnyCPU will not work and instead you must target and build your app for each platform you wish to support.
xaml-step-6a.png
xaml-step-6b.png

7. Register the smooth streaming mime types with the ad player factory plugin (this is a plugin that helps create the player for the ad).
var adPlayerFactory = player.Plugins.OfType<Microsoft.PlayerFramework.Advertising.AdPlayerFactoryPlugin>().FirstOrDefault();
if (adPlayerFactory == null)
{
    adPlayerFactory = new Microsoft.PlayerFramework.Advertising.AdPlayerFactoryPlugin();
    player.Plugins.Add(adPlayerFactory);
}
adPlayerFactory.SupportedVideoMimeTypes.Add("text/xml");
adPlayerFactory.SupportedVideoMimeTypes.Add("application/vnd.ms-sstr+xml");

8. That's all, both smooth streaming and progressive download ads should now play.

Last edited Aug 22, 2013 at 10:45 PM by timgreenfield, version 6