Click Here to Install Silverlight*
United StatesChange|All Microsoft Sites
Windows Media Player 9 Series
|Windows Media Worldwide

Advertising Solutions: Client-Side Playlist Ad Insertion

Feedback
E-mail us with your comments and feedback about this article.
 
Abstract
Summary: Discusses how to insert ads into a client-side playlist, known as a Windows Media metafile with an .asx extension, including how to use dynamic and personalized ads by using Active Server Pages (ASP) technology. Readers should be familiar with Windows Media metafiles, creating Windows Media-based content, and Web page scripting.

 

David Wrede
Microsoft Corporation
Updated December 2004
 

Applies to:
   Microsoft® Windows Media® Player 10 Software Development Kit
 

Contents


Introduction

Many types of Internet-related businesses can make use of advertising on the Internet. For Internet Content Providers (ICPs), the increase in the amount of content for streaming and downloading has led to an increase in production costs. As an alternative to "pay-per-view" and subscription-based models for delivering content, an ICP can look into recovering those costs with advertising.

Likewise, advertisers can take advantage of this new medium to get their messages out to users who are viewing or listening to digital media content. The Internet provides ICPs with a powerful means of obtaining user information and creating user profiles because of the ability to connect to users one on one. Advertisers can target their messages more effectively, down to individual users. This advertising method is very different from the one used with television broadcasting in which ads must be targeted at a wide audience.

Microsoft® Windows Media® technologies support a number of solutions for advertising. This article describes client-side playlist ad insertion and shows you how to implement it with step-by-step instructions and examples. Either use the examples "as is," or build on them to create dynamic Web pages.

This article assumes that you are familiar with Windows Media metafiles, creating Windows Media-based content, and Web page scripting. It is recommended that you download the Windows Media Player 10 Software Development Kit (SDK), which contains complete information on how to create metafiles, embed the Player in a Web page, and create Player skins and borders.

Back to the top of this pageBack to Top


Understanding Playlists and Ads

Playlists provide an extensible, dynamic method for delivering audio and video content to users. A playlist is a sequential list of digital media content that you create by using scripting in a Windows Media metafile to string together multiple ENTRY elements. A playlist can include a mixture of program content and ads. It can be used to play several short clips or to provide a user with long blocks of programming.

Client-side playlists can be created by Windows Media Player, Web scripts, or through a text editor like Notepad. Server-side playlists can be created through the user interface in Windows Media Services 9 Series or through a text editor like Notepad. The main difference between client-side playlists and server-side playlists is that Windows Media Player has control of the streaming experience when using client-side playlists, while the server running Windows Media Services 9 Series has control of the streaming experience when using server-side playlists.

Ads are divided into three categories depending on how they are inserted into a playlist: gateway ads, interstitial ads, and bumper ads.
  • Gateway ads are played before the program content. Gateway ads are often popular on news websites where you might see, for example, a short clip or promotion played prior to a news story.
  • Interstitial ads are played between program entries in a playlist. For example, using the same newscast scenario, interstitial ads can be inserted between each top news story. The ads can be the same for all users or different based on a user's profile.
  • Bumper ads are appended to the end of the program content.

Because metafiles are simple text files, the playlist concept can be expanded in many directions. For example, you can use another provider's ad server software to create personalized or dynamic playlists—that is, metafiles that are built on the fly based on demographics, special interests, or any other user attribute. Taking it one step further, the entries in a playlist can point to ASP pages that return metafile scripting, or dynamic entries. With a creative use of metafiles, you can design dynamic on-demand programming, such as a personalized newscasts or radio stations.

For more information about metafiles, see the Windows Media Metafiles section of the Windows Media Player 10 SDK on the MSDN website.

The examples in the following sections show how to insert ads into client-side playlists.

Creating a Static Playlist

To create a playlist, write your script in a text editor such as Notepad. A playlist script is based on Extensible Markup Language (XML) syntax and made up of elements and their associated tags and attributes. Each element in the script defines a particular setting or behavior in the client, Windows Media Player.

The following example demonstrates how to insert an ad in front of a single video clip. All users will see the same ad and video clip.

<ASX Version="3">

<ENTRY ClientSkip="no">
<REF HREF="mms://MyMediaServer/AdInsertion/AlpineSkiHouseAd.asf"/>
</ENTRY>

<ENTRY>
<REF HREF="mms://MyMediaServer/Content/UpcomingReleases2004.wmv"/>
</ENTRY>

</ASX>
The metafile elements are fairly simple. The first line of code defines the file as a Windows Media metafile (.asx) and tells the client, Windows Media Player, what version of the ASX file format you're using.

<ASX Version="3">
Then, two entries are defined. Note that the first entry (the advertisement) has the CLIENTSKIP attribute set to "no", which prevents users from skipping the ad. To enforce this behavior, the Player disables the playback controls in the user interface.

After viewing the ad, users will immediately see the second entry, the video clip, with the typical Player behavior restored. Windows Media Player starts buffering the second entry while the first entry is still playing, eliminating the traditional "black hole" between clips.

The last line in the script, the </ASX> tag marks the end of this metafile.

Creating a Static Playlist with Enhanced Elements

The previous example showed the simplest advertisement scenario. This example expands on that scenario by including titles and abstracts for the content, and a Buy Now button. You can use a Buy Now button to let users purchase content directly from your website or send them to an advertiser's website.

<ASX version="3">

<TITLE>Demo ASX File</Title>

<ENTRY ClientSkip="no">
<REF HREF="mms://MyMediaServer/AdInsertion/AlpineSkiHouse.asf"/>
<banner HREF="http://MyMediaServer/AdInsertion/images/MoreInfo.gif">
<moreinfo HREF="http://www.alpineskihouse.com"
TARGET="_blank"/>
<ABSTRACT>Have fun in the snow at Alpine Ski House!
</ABSTRACT>
</BANNER>
<TITLE>Alpine Ski House</TITLE>
<COPYRIGHT> 2004, Alpine Ski House </COPYRIGHT>
</ENTRY>

<ENTRY>
<TITLE>Upcoming Movie Releases in 2004</TITLE>
<COPYRIGHT> Copyright Southridge Video 1/11/04 </COPYRIGHT>
<REF HREF="mms://MyMediaServer/Content/UpcomingReleases2004.asf"/>
<ABSTRACT>Check out the latest movies to hit the big screen in 2004!
</ABSTRACT>
<COPYRIGHT> Copyright 2004, Southridge Video -- All Rights Reserved
</COPYRIGHT>
</ENTRY>

</ASX>
The TITLE element is used to define the title of the content, which appears in the stand-alone Windows Media Player.

The BANNER element points to a .gif file for the button image, which points to a URL. Notice how the TARGET attribute is set to point to a frame name, just like it would in a typical HTML page. And, like an HTML page, you can use inline Microsoft JScript® in place of a URL.

The ABSTRACT element provides the ToolTip text that will appear when users hover their pointers over the clip title. The COPYRIGHT, TITLE, and AUTHOR elements provide information about the playlist content, which will appear in the Player for users to access.

You can also use all of the elements described in conjunction with an embedded Player, rendered through JScript.

Creating Dynamic Playlists and ASP Pages

The most compelling ads are personalized to user preferences. For example, viewers interested in travel on cruise ships are sent cruise-related ads, and backpacking enthusiasts are sent hiking-related ads. By using personalized ads, you can avoid annoying viewers, and at the same time command premium rates from advertisers because they know only interested viewers will see their ad.

This example implements option buttons, providing viewers a choice between two ads. These choices, in turn, drive dynamic content and determine how the ASP pages are generated.

Three steps are required to create a dynamic playlist in this example:
  1. Ask the user for personalized information. The following code example uses a simple form with two choices.
  2. Process user preferences to create a personalized playlist. This example uses ASP pages to create a playlist and insert Windows Media Player as an embedded object. The first ASP page embeds the Player object and references a playlist created by the second ASP page.
  3. Play the user's content.

The user preference form (Preferences.htm) is shown in the following code example. The method of the FORM element is set to POST to pass the URL in clear text to PlayerPage.asp.

<HTML>

<! Preferences.htm>

<BODY>
Please choose one of the following options:<BR>

<FORM METHOD=POST ACTION=PlayerPage.asp>
<INPUT TYPE=RADIO NAME=AdPref VALUE=0> I like cruises
<BR>
<INPUT TYPE=RADIO NAME=AdPref VALUE=1> I like backpacking
<P>
<INPUT TYPE=SUBMIT>
</FORM>

</BODY>
</HTML>
The PlayerPage.asp page embeds the Player, and then passes user choices on to the BuildAsx.asp page.

<%@ language="JScript" %>
<HTML>

<body>
<OBJECT id="Player" height="207" width="242"
classid="CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6" VIEWASTEXT>
<PARAM NAME="URL" VALUE="BuildASX.asp?AdPref=<%=Request.Form("AdPref")%>">
</OBJECT>
</body>
</HTML>
The dynamic playlist is created in the BuildAsx.asp page. This page does not send the usual HTTP headers to the Player, which is why the page works as a Windows Media metafile.

<%@ Language="JScript" %>
<%
// Note that setting the Request.ContentType property to
// "video/x-ms-asf" lets you create dynamic
// metafiles that do not contain HTTP header data.
Response.ContentType = "video/x-ms-asf";
%>

<%
// Set the BASE_PATH variable to point to your
// server running Windows Media Services.
var BASE_PATH = "mms://MyMediaServer/";

//Force content to always refresh.
Response.Expires = 0;

//Create the opening ASX tag.
Response.Write (AsxHeader());

//Create an ad.
Response.Write (AdEntry());

//Create an XML entry for content.
Response.Write (AsxEntry());

//Write the ASX footer.
Response.Write (AsxFooter());

// This function returns an opening <ASX> tag.
function AsxHeader ()
{
return "<ASX Version=\"3\">" + "\n" + "<TITLE> Demo Dynamic ASX File
From Active Server Pages </TITLE>" + "\n";
}

// This function returns an ad based on user request.
function AdEntry()
{
if (Request("AdPref") == 0)
{
return " <ENTRY>" + "\n" + "\t" + "<REF HREF=\"" + BASE_PATH +
"AdInsertion/BackpackingAd.wmv\" />" + "\n" +
" </ENTRY>" + "\n";
}
else
{
return " <ENTRY>" + "\n" + "\t" + "<REF HREF=\"" + BASE_PATH +
"AdInsertion/TravelAd.wmv\" />" + "\n" +
" </ENTRY>" + "\n";
}
}

// This function returns an XML entry for a specific piece of content.
// With actual code, this function does a database lookup.
function AsxEntry ()
{
var AsxEntry, Abstract;
AsxEntry = " <ENTRY>" + "\n" + "\t" +
"<TITLE> Upcoming Movie Releases in 2004 </TITLE>" + "\n";
AsxEntry += "\t" + "<REF HREF=\"" + BASE_PATH +
"Content/UpcomingReleases2004.asf \"/>" + "\n";
AsxEntry += "\t" + "<ABSTRACT>" + "\n";
Abstract = " Check out the latest movies to hit the big screen in 2004!";
AsxEntry += Abstract + "\n";
AsxEntry += "\t" +"</ABSTRACT>" + "\n";
AsxEntry += "\t" + "<COPYRIGHT> Copyright 2004,
Southridge Video -- All Rights Reserved </COPYRIGHT>" + "\n";
AsxEntry += " </ENTRY>" + "\n";
return AsxEntry;
}

// This function returns a closing </ASX> tag.
function AsxFooter ()
{
return "</ASX>";
}
%>

Back to the top of this pageBack to Top


For More Information


Back to the top of this pageBack to Top



© 2009 Microsoft Corporation. All rights reserved. Contact Us |Terms of Use |Trademarks |Privacy Statement
Microsoft