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

Advertising Solutions: Server-side Playlist Ad Insertion

Feedback
E-mail us with your comments and feedback about this article.
 
Abstract
Discusses how to insert ads into a server-side playlist, including how to use dynamic and personalized ads by using Active Server Pages (ASP) technology.

Wyatt Jackson
Microsoft Corporation
June 2004


Applies to:
   Microsoft® Windows Media® Services 9 Series
   Microsoft Windows Media Services 9 Series SDK
 


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 advertising on television, where ads must be targeted at a wide audience.

Microsoft® Windows Media® technologies support several solutions for advertising. This article describes server-side playlist ad insertion and shows you how to implement it with step-by-step instructions and examples. You can use the examples as they are, or build on them to create dynamic Web pages.

This article assumes that you are familiar with Windows Media Services, creating Windows Media-based content, and Web page scripting. Microsoft recommends that you download the Windows Media Services 9 Series Software Development Kit (SDK), which contains more complete information on how to create and use server-side playlists. For downloading information, see For More Information at the end of this document.

Back to the top of this pageBack to the top


Understanding Playlists and Ads

Playlists provide an extensible, dynamic method for delivering audio and video content to users. A playlist represents an ordered list of the media items that the server can stream to a client. 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 when client-side playlists are used, Windows Media Player has control of the streaming experience, but when server-side playlists are used, a server running Windows Media Services 9 Series has control of the streaming experience. A server-side playlist can be dynamic, meaning that you can modify the playlist even while a client computer is receiving content based on that playlist. This lets you customize a playlist for a particular user, for example.

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 Web sites 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 all the news stories. The ads can be the same for all users, or different for different users, based on user profiles.
  • Bumper ads are appended to the end of the program content.

Because playlists 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, playlists 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 scripted playlists, or dynamic entries. With creative use of metafiles, you can design dynamic on-demand programming, such as personalized newscasts or radio stations.

For more information about server-side playlists, see the Programming Playlists section of the Windows Media Services SDK on the MSDN Web site.

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

Creating a Static Playlist

To create a playlist, write your script in a text editor such as Notepad. A server-side playlist script is based on the Synchronized Multimedia Integration Language (SMIL) 2.0 syntax and made up of elements and their associated tags and attributes. Each element or attribute in the script defines a particular setting or behavior in the server, Windows Media® Services.

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.

<?wsx version="1.0"?>

<smil>

   <seq>

      <media src="C:\WMPub\WMRoot\encoder_ad.wmv" noSkip="true"

         role="Advertisement" />

      <media src="C:\WMPub\WMRoot\ContentTrailer.wmv" />

   </seq>

</smil>

The playlist elements are fairly simple. The first two lines of code define the file as a SMIL-compliant server-side playlist (.wsx) and notify the server, Windows Media Services, what version of the WSX file format you're using.

Then, two entries are defined. Note that the first entry (the advertisement) has the noSkip attribute set to "true", which prevents users from skipping the ad. To enforce this behavior, the Player disables the playback controls in the user interface. The first entry also has a role attribute set to "Advertisement". Setting the role attribute to this specific value causes Windows Media Services to increment a counter that keeps track of how many ad impressions have been served on a particular publishing point. When working with advertisements in server-side playlists, you should always ensure that your ads have these two attributes defined.

After viewing the ad, users will immediately see the second entry, the video clip, with the typical Player behavior restored.

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

Creating a Dynamic Playlist with ASP.NET

Dynamic playlists offer a much greater level of flexibility when it comes to managing and delivering your content. Advertising content can be customer tailored to the audience to create a more compelling user experience. Dynamic playlists can also make it easier to manage large amounts of content more effectively. The following example uses an ASP.NET server-side script to rotate advertising content so that all the advertisements will receive equal air time. Using a server-side script in combination with a server-side playlist lets you keep content paths hidden from users, for better security.

The server-side playlist used to generate the dynamic playlist is shown in the following code example.

<?wsx version="1.0"?>

<smil>

    <media src="httpd://localhost/DynamicPlaylist.aspx" />

    <media src="C:\WMPub\WMRoot\ContentClip.wmv"/>

</smil>

The first entry in the playlist has a src attribute that begins with "httpd://". When Windows Media® Services encounters a playlist entry with this prefix, the entry is handled by the WMS HTTP Download Data Source plug-in. The plug-in goes out and retrieves the playlist from that address. The playlist it retrieves is generated by the following ASP.NET server-side script.

<%@ Page language="c#" %>

// Run this script as a server-side script.

<script runat="server">

// Implement the Page_Load event handler.

private void Page_Load(object sender, System.EventArgs e)

{

   Random rand;

   // If no random seed exists, create

   // it and save it.

   if( Application["Random"] == null )

   {

      rand = new Random();

      Application["Random"] = rand;

   }

   else

   {

      rand = (Random)Application["Random"];

   }

   // Set up an array to hold the list of ads.

   // This array could be pulled from a SQL server

   // or an XML file as well.

   ArrayList ads = new ArrayList();

   if( Session["Ads"] == null )

   {

      ads.Add("C:\\WMPub\\WMRoot\\encoder_ad.wmv");

      ads.Add("C:\\WMPub\\WMRoot\\powered_by_300.wmv");

      ads.Add("C:\\WMPub\\WMRoot\\fupgrade.asf");

      Session["Ads"] = ads;

   }

   else

   {

      ads = (ArrayList)Session["Ads"];

   }

   int index = 0;

   // If the ad rotation has already started,

   // then play the next one in the array.

   if( Session["Index"] == null )

   {

      index = rand.Next(ads.Count);

   }

   else

   {

      index = 1 + (int)Session["Index"];

      if( index >= ads.Count )

         index = 0;

   }

   // Save the current index into the array of ads.

   Session["Index"] = index;

   // Write out the playlist containing the

   // ad at the current index in the array.

   Response.Write("<?wsx version=\"1.0\"?>\r\n");

   Response.Write("<smil>\r\n");

   Response.Write("   <media src=\"" + ads[index] + "\" noSkip=\"true\"" +

                  "role=\"Advertisement\" />\r\n");

   Response.Write("</smil>\r\n");

}

</script>

Windows Media Services will also let you to pass variables from a server-side playlist to an ASP.NET page. For example, if authentication is turned on, the following playlist would pass a client's user ID to the ASP.NET page. The user ID can then be used to tailor the advertising content to the user.

<?wsx version="1.0"?>

<smil>

    <media src="httpd://localhost/DynamicPlaylist.aspx

               ?name=%UserName%&id=%UserID%&ip=%UserIP%" />

    <media src="C:\WMPub\WMRoot\ContentClip.wmv"/>

</smil>

For more information on the variables provided by Windows Media Services, see the Programming Playlists section of the Windows Media Services SDK on the MSDN Web site.

Creating a Wrapper Playlist

Wrapper playlists enable a Windows Media® Services publishing point to wrap advertising content around user requested content automatically. Instead of having a separate playlist for each piece of content, a wrapper playlist can be enabled on a publishing point, and whenever a user requests a piece of content, a playlist will be generated that includes the content from the wrapper playlist. The following example shows a wrapper playlist that plays an ad both before and after users view the content they requested.

<?wsx version="1.0"?>

<smil>

    <media src="httpd://localhost/DynamicPlaylist.aspx" />

    <media src="%requestedUrl%"/>

    <media src="httpd://localhost/DynamicPlaylist.aspx" />

</smil>

The "%requestedUrl%" entry is a special entry used in wrapper playlists. When Windows Media Services encounters this entry, it replaces it with the path to the content requested by the user.

Back to the top of this pageBack to the top


Conclusion

Independent Content Providers (ICPs) as well as advertisers can benefit by using these techniques to reach their customers. ICPs gain more control over their advertising model, and advertisers can be assured that they are reaching the customers that matter most to them.

Back to the top of this pageBack to the top


For More Information


Back to the top of this pageBack to the top



© 2008 Microsoft Corporation. All rights reserved. Contact Us |Terms of Use |Trademarks |Privacy Statement (Updated)
Microsoft