Using Windows Media Technologies for Advertising on the Internet

Cherylene Simonetti, Bill Birney, and Jim Travis
Microsoft Digital Media Division

May 2001

Summary: From banner advertisements to e-mail, the Internet provides many creative solutions for advertisers—solutions that make use of the power of global reach, instant access, and one-on-one interaction. With Microsoft Windows Media Technologies, a content provider can use digital media to deliver a high-impact message to a targeted audience. This article describes five advertising solutions that take advantage of the rich set of features and components in Windows Media Technologies. You'll learn how to create your own solutions, with step-by-step procedures and sample code. (30 printed pages)

Contents

Introduction
Banner Ads in Windows Media Player
Playlist Ad Insertion
Broadcast Ad Insertion
Streaming Banners
Borders in Windows Media Player 7
For More Information

Introduction

The Internet has evolved from a novelty into an integral and necessary part of our lives. Along with this maturity has come new, effective, and engaging ways of communicating and sending messages to a wide audience. Digital media is emerging as a popular method for delivering creative content on the Internet. As high bandwidth connections become more accessible and the quality of digital media continues to improve, more and more users and content providers are recognizing the vast potential of digital media for delivering not just content, but also a message: advertising.

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 the digital media content. The Internet provides a powerful means of obtaining user information and creating user profiles because of its ability to connect to users one on one. This enables advertisers to target their messages more effectively, down to individual users. This method is very different from television broadcasting, for example, in which ads must be targeted at a wide audience.

Microsoft® Windows Media™ Technologies support a number of solutions for advertising. This article describes five advertising solutions and shows you how to implement them with step-by-step instructions and samples. This article assumes you are familiar with Windows Media metafiles, creating Windows Media-based content, and Web page scripting. It is recommended that you download the Microsoft Windows Media Player 7.1 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. To create Windows Media files, download Windows Media Encoder and the encoding tools from the Windows Media page of the Microsoft Web site.

This article contains the following advertising solution topics:

  • Banner ads in Windows Media Player. A small ad banner can be inserted in the video display area of Windows Media Player. The banner can be tied directly to a specific digital media stream or file and can contain a hyperlink that opens a Web page in the user's default browser.
  • Playlist ad insertion. You can create playlists of on-demand digital media content that also contain ads. The playlists can be static or dynamic. Dynamic playlists can be created using Active Server Pages (ASP) that can take advantage of ad serving technology.
  • Broadcast ad insertion. Script commands can be added to live broadcasts that trigger Windows Media Player to cut away from the broadcast in order to play personalized ads or other content. After that content has played, the Player then resumes the broadcast. This feature can be especially useful when certain broadcast content, such as national commercials, must be replaced with different content in the Internet stream.
  • Streaming banners. Windows Media-based video content can be created in many sizes and rectangular shapes, enabling you to embed streaming video in a banner ad on a Web page.
  • Borders in Windows Media Player 7. The Now Playing feature of Windows Media Player can play digital media and contain a border, similar to a built-in mini-Web page. A border can contain images, text, links, and scripting that can be used to enhance the digital media and embed advertising.

The banner ad is the most popular advertising device used on the Internet today. As an alternative to Web page banners, you can associate an ad with a piece of digital media content by displaying a banner ad directly on the Windows Media Player interface. Windows Media Player displays an ad image in the area just beneath the video panel. The images are downloaded to Windows Media Player with a simple URL, so ads can be either static or generated dynamically. For example, you could use ASP pages to deliver personalized banners with an ad server.

In addition to displaying an image, the banner can contain a hyperlink that opens a Web page on the user's default browser. You can use this feature to market a music compact disc (CD), for example. As a user plays a streaming sample of the music, the Player can display a banner that contains a link to a Web site where the user can purchase the full CD.

Figure 1. An ad banner displayed in Windows Media Player 7 image

Figure 1. An ad banner displayed in Windows Media Player 7

How It Works

Ad banners in the Player are implemented by using scripting in Windows Media metafiles. To add Windows Media-based content to a Web page, point to a Windows Media metafile instead of linking directly to the digital media. When a user clicks the link, the metafile downloads, and then Windows Media Player opens and interprets the contents of the metafile. A Windows Media metafile usually contains the URLs of streaming digital media on a Windows Media server. The Player then uses the URLs to locate and stream the content.

In addition to the URLs of digital media content, the metafile can contain the URLs of ad banner images and hyperlinks. When Windows Media Player opens a metafile containing banner information, it downloads the banner images from the Web server and displays them with their hyperlinks. You can assign one banner ad to each metafile, or you can assign banners to each entry in a playlist. Playlists will be described in the next topic.

Implementing Ad Banners

To add an ad banner to Windows Media Player, create the banner image file and the Windows Media metafile and then save both files on a Web server.

Creating the banner image file

Use a graphics program to create an image file in the BMP, GIF, or JPG file format. The banner can be as large as 32 pixels high by 194 pixels wide. After you create the image, save it on a Web server. You could locate all Windows Media Player ad banners in a single folder; for example, WMPBanners. The following figure shows a full-size ad banner image.

Figure 2. A full-size ad banner image

Figure 2. A full-size ad banner image

Creating a Windows Media metafile

To create a metafile, write your script in a text editor such as Microsoft Notepad. The 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 Windows Media Player.

For example, when the following script is opened in Windows Media Player, the banner ad Advert.gif is downloaded and shown in the banner display area, and MusicClip.wma is located and streamed.

<ASX VERSION="3.0">
   <ENTRY>
      <BANNER HREF="https://WebServer/WMPbanners/Advert.gif" />
      <REF HREF = "mms://WindowsMediaServer/MusicClip.wma" />
   </ENTRY>
</ASX>

This simple metafile includes the following basic elements and attributes:

  • ASX. Defines the enclosed text as a Windows Media metafile.
  • ENTRY. Contains a digital media file or broadcast stream and any elements associated with that file or stream.
  • BANNER HREF. Specifies the URL of the banner image file.
  • REF HREF. Specifies the URL of a digital media file or broadcast stream. In this case, MusicClip.wma is to be streamed using the Microsoft Media Server (MMS) protocol.

When you finish writing the script, save the text file with one of the following file name extensions:

Extension When to use it
.wvx When the digital media content has the file name extension .asf, .wma, or .wmv.
.wax When the digital media content has the file name extension .asf or .wma.
.asx When the digital media content has the file name extension .asf.

An ad banner can contain a link. For example, you may want to link to an advertiser's Web site. This is accomplished by adding a MOREINFO element within the BANNER element.

<ASX VERSION="3.0">
   <ENTRY>
      <BANNER HREF="https://WebServer/WMPbanners/Advert.gif">
         <MOREINFO HREF="https://www.microsoft.com" />
      </BANNER>
      <REF HREF = "mms://WindowsMediaServer/MusicClip.wma " />
   </ENTRY>
</ASX>

You can further define the frame or window in which the Web page will appear by adding a TARGET attribute to the MOREINFO element.

<MOREINFO HREF="URL" TARGET="Frame" />

This attribute can be very useful, especially when Windows Media Player is embedded in a Web page. If a target frame is not specified and a user clicks the banner, the Web page containing the Player will be replaced by the MOREINFO page, thereby unloading the Player control and stopping the stream. The TARGET attribute enables you to specify a separate frame to display the MOREINFO page and keep the embedded Player open in another frame. If the metafile is opened in the standalone Windows Media Player, the TARGET attribute is ignored, and the site specified by the URL opens in a new browser window.

Playlist Ad Insertion

Playlists provide an extensible, dynamic method for delivering audio and video content to users. A playlist is a sequential list of digital media content 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.

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 promo 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 themselves are simple text files, the playlist concept can be expanded in many directions. Complex ad server programs can be employed 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. There are three basic ways to use playlists:

  • Static playlist. The metafile and the playlist entries are hard-coded with explicit URLs of digital media files and other content.
  • Dynamic playlist. An entire metafile is created dynamically; for example, a personalized newscast that contains programming and ads of particular interest to the user.
  • Dynamic entries. Entries in a metafile point to digital media files or other content that is inserted dynamically.

Dynamic playlists enable content providers to target a specific audience and present them with personalized programming and ads. Advertisers can sell their products more effectively because they can pre-determine who will see their ads; for example, males between the ages of 30 and 40. The advantage of dynamic entries is that a content provider can build a user profile and insert updated, personalized content while the user is streaming.

How Playlists Work

The basic element of a playlist is an ENTRY. You create a playlist by simply adding multiple ENTRY elements to a metafile. An entry contains a piece of digital media content, and can also include supporting elements, such as ad banners and links. When Windows Media Player opens a metafile containing a playlist, each entry is located or resolved, and any banner images or icons are downloaded, after which the first entry in the list buffers and starts to play. The entries continue to play in order until the end of the list. A playlist can consist of video content, audio-only content, or a mixture of both.

A metafile can access digital media content in the following ways:

  • Direct link. An ENTRY element links directly to digital media content with a URL. The content can be of several types. Windows Media-based streaming content is typically accessed using a URL that points to the content on a Windows Media server.
  • Metafile. An ENTRYREF element is used in place of an ENTRY in a playlist. ENTRYREF enables you to link to a Windows Media metafile that, in turn, contains links to the digital media content. For example, a personalized newscast could use direct links for program content and then link to metafiles that contain complete playlists of several ads.
  • ASP page. Anywhere you can enter the URL of digital media content or a metafile, you can also enter an ASP page. ASP pages enable you to create links dynamically. In the newscast scenario, for example, you could have boilerplate ASP pages that are scripted to retrieve the latest breaking news stories or ads that are targeted to individual users.
Seamless stream switching

One of the compelling features of playlists in Windows Media metafiles is seamless stream switching. To understand how seamless stream switching works, you need to know about buffering.

When the status box on Windows Media Player indicates it is buffering, that means the Player is loading the first five or so seconds of the incoming stream into memory. The memory buffer acts as a reserve to compensate for uneven network conditions. Whenever you change from one streaming source to another, you must wait while Windows Media Player stops, locates the new digital media, and starts buffering the stream.

Seamless stream switching minimizes the wait between entries in a playlist. The Player locates and pre-buffers about five seconds of an upcoming entry as the current entry nears its end. When the current entry ends, Windows Media Player then immediately starts the next entry by streaming directly from the buffer. Seamless stream switching enables you to create playlists that play smoothly with minimal interruption between entries.

To make use of seamless stream switching, keep the following points in mind:

  • An entry must be 20 seconds or longer. A short file does not allow enough time for pre-buffering to take place.
  • Seamless stream switching is not currently supported when switching to a Windows Media metafile. The switch is only seamless if the Hypertext Reference (HREF) URL points directly to a digital media file or stream, or to an ASP page inside an ENTRY element that returns a digital media file or stream.
  • Seamless switching is not supported in Windows Media Player 7. However, it is supported in Windows Media Player versions 6.4 and 7.1.
Implementing Playlists

Just as the Production department is separate from Sales and Traffic in a broadcast environment, the production and hosting of your Windows Media-based content is a separate process from the creation and hosting of the metafiles that access the content. Metafiles are all text, so many methods can be developed for creating them—from building them in Microsoft Notepad to generating them automatically with proprietary ad placement software that connects to databases of content and user types.

Again, there are three ways to use playlists: static playlists, dynamic playlists, and dynamic entries.

Static playlists

Static playlists contain direct links to content. The following sample shows a simple playlist script that plays Advert.wmv, followed by Clip.wmv.

<ASX VERSION="3.0">
  <ENTRY CLIENTSKIP="NO">
    <REF HREF="mms://example.microsoft.com/Advert.wmv" />
  </ENTRY>
  <ENTRY>
    <REF HREF="mms://example.microsoft.com/Clip.wmv" />
  </ENTRY>
</ASX>

In the first ENTRY, the CLIENTSKIP attribute is set to NO. Doing so disables the playback controls on Windows Media Player, so the user is prevented from skipping your commercials or any other content; in this case, the entry containing Advert.wmv.

You can take metafile scripting even further by linking to other metafiles within a playlist. The following sample uses the ENTRYREF element to play Advert.asx, followed by Clip.wmv.

<ASX VERSION="3.0">
  <ENTRYREF HREF="https://example.microsoft.com/Advert.asx" />
  <ENTRY CLIENTSKIP="NO">
    <REF HREF="mms://example.microsoft.com/Clip.wmv" />
  </ENTRY>
</ASX>

Advert.asx could contain a complete break of four 30-second ads, for example.

A static playlist does not necessarily mean the digital media content must itself be static. You could, for example, use the previous sample as a boilerplate metafile and simply replace the Clip.wmv file. In our newscast scenario, Clip.wmv could be up-to-the-minute headlines. The news production company could produce periodic updates to the file and replace the file on the Windows Media server, while an advertising agency maintains current content accessed by Advert.asx.

Server-side playlists

Playlists can be client-side or server-side. The type described so far is client-side, meaning that the playlist is contained in a metafile on the client or end-user's computer. In a server-side playlist, the list is contained on the Windows Media server. A server-side playlist plays a broadcast stream of on-demand files. When one file finishes, the next one starts. A loop parameter can also be added to a playlist that commands the server to play from the top of the list after the last item finishes. Because the playlist is broadcast from the server, the user does not control playback, but tunes in to the playlist in progress.

The following figure shows a server-side playlist configured to loop the broadcast of four files.

Figure 3. A server-side playlist broadcast image

Figure 3. A server-side playlist broadcast

Server-side playlists can contain multiple Windows Media files. Metafiles or ASP pages cannot be used as entries in the playlist, but content in the list can be updated dynamically. For more information about setting up a server-side playlist, see Windows Media Services Help.

Dynamic playlists

You can create a dynamic playlist by using an ASP page to build a dynamic metafile. The URL of the ASP page is assigned to the URL or FileName parameter of Windows Media Player, which then accesses the page and passes any QueryStrings to the Web server. (For Windows Media Player 7 and later, the parameter is URL. For earlier versions, the parameter is FileName.) The following diagram illustrates the steps.

Figure 4. The steps for serving a dynamic playlist image

Figure 4. The steps for serving a dynamic playlist

In this example, three users open a Web page and enter parameters to choose the order in which they would like to receive news clips. Scripting in the Web page generates a URL that is then assigned to the URL or FileName property of an embedded Windows Media Player control or plug-in. For example, Sue has chosen to view news clips A, B, and C in that order, while Bob has chosen to view them in the order C, B, and A. The URL and QueryString assigned to Sue's embedded Windows Media Player control or plug-in could be:

https://WebServer/News.asp?Order=ABC

The following steps describe the process after the end users click a link on the Web page to start the stream:

  1. Windows Media Player locates the Web server and passes the QueryString to the ASP page. The following is an example of a simple ASP page that receives the Order parameter and passes it in the MakeEntries function to a script in an include file, Dynamic.inc.

    <%Response.ContentType="video/x-ms-wma" %><%Response.expires=0%>
    <%ClientOrder=Request.QueryString("Order")%> 
    <!-- #INCLUDE FILE = "Dynamic.inc" -->
    
    <ASX VERSION="3.0">
        <TITLE>Dynamic Playlist</TITLE>
        <%=MakeEntries(ClientOrder)%>
    </ASX>
    

    Note   Notice the Multipurpose Internet Mail Extensions (MIME) type of the return value, which sets the ContentType as a Windows Media metafile:

    Response.ContentType="video/x-ms-wma".
    
  2. Dynamic.inc contains script that queries a Microsoft SQL Server™ database, which returns an updated list of news clip file names and an advertisement, which is the third entry in the playlist. The MakeEntries function then returns the body of the playlist to the ASP page.

  3. The Web server returns Windows Media metafile text to the clients.

  4. Windows Media Player plays the list and performs any other tasks, such as downloading and displaying ad banner images, and displaying text properties.

With the ability to open ASP pages, Windows Media Player provides many creative solutions that can be implemented easily, often with minimal scripting. You can also link to ASP pages from within a metafile, thus giving you the ability to create dynamic entries as well.

Dynamic entries

You can add dynamic entries to a playlist by linking to ASP pages within a metafile. You can use an ASP page in place of digital media content in an ENTRY or in place of a metafile in an ENTRYREF, using the same syntax. For example:

<ENTRYREF HREF="https://example.microsoft.com/Advert.asp" />
<ENTRY>
    <REF HREF="https://example.microsoft.com/Clip.asp" />
</ENTRY>

The metafile text that is returned to the client can contain one or more entries and any related images and links. The ASP page in an ENTRY element returns the URL of the desired digital media content.

If you create a solution that uses ASP pages as both the URL or FileName source and as ENTRY or ENTRYREF elements, you can have dynamic playlists with dynamic entries. Using the news clip example scenario, you could use an ASP server to deliver a dynamic playlist containing ads that are ASP pages. Figure 5 below illustrates this concept.

Figure 5. The steps for serving a dynamic playlist and entry image

Figure 5. The steps for serving a dynamic playlist and entry

This scenario could be used in cases in which the program content is produced separately from the ad content. For example, a news service could handle the creation of personalized playlists that contain empty positions for ads; these ads could then be inserted by an Advertising Solution Vendor's (ASV) back-end system. The news company would not necessarily need to know which ads are being inserted, just that they need to insert the advertiser's ASP page into the list.

  1. The clients pass the QueryString to the ASP page on the news server. For this example, suppose an additional parameter is added to the string that identifies users by their preference of automobile type. The ASP page receives the QueryString and passes it to the include file, Dynamic.inc.

  2. Dynamic.inc queries the SQL Server database, which returns the playlist. The ad is in the third position of the list, and includes the user preference QueryString:

    <ENTRY>
       <HREF="https://AdServer/NewsService/Advert.asp?UserPref=SUV" />
    </ENTRY>
    
  3. The Web server returns the Windows Media metafile text to the clients.

  4. Windows Media Player plays the list.

  5. As Windows Media Player nears the end of the second position in the playlist, it begins the process of locating and pre-buffering the digital media content referenced in the third position entry. The Player locates the ASP page on the ASV server, Advert.asp, and passes the QueryString to the ASP page.

  6. A script file on the ad server queries the ad database, which returns the URL of the appropriate ad.

  7. The ad server returns the URL to the client, which then pre-buffers the digital media, plays the ad, and then continues with the playlist.

Windows Media metafile scripting provides a flexible platform for creating many solutions by using playlists, ad banners, and text properties. Metafile scripting also provides ways to enhance broadcasting, as well as a way to insert personalized ads into a live broadcast.

Broadcast Ad Insertion

Broadcasting is a method of delivering a digital media stream to a user, in which playback of the stream is controlled at the point of origin. The other method of stream delivery is called on-demand streaming, in which playback is controlled by the end user. The on-demand experience is similar to playing a CD, while the broadcast experience is like listening to the radio. There are two basic types of broadcasts: a live broadcast, in which a live program is encoded and accessed immediately by a user, and a server-side playlist broadcast, in which the playback of one or more on-demand files is controlled by a Windows Media server.

There are two scenarios for delivering advertising within a broadcast: the traditional broadcast method and personalized ad insertion. The traditional broadcast advertising method is very familiar: Advertising is mixed with program material and then broadcast to a broad audience; everyone receives the same programming and ads. The following diagram shows how components are used in a traditional broadcast.

Figure 6. Components setup for a traditional broadcast image

Figure 6. Components setup for a traditional broadcast

The traditional broadcast method for delivering advertising

In the traditional broadcast method, advertising and programming are assembled, encoded, and served to multiple users.

Because broadcasting over the air is one-way communication, this traditional method is the only way to deliver advertising on television or radio. However, the interactive nature of the Internet provides a number of advertising solutions that take advantage of the two-way communication and direct connections established with every user. With the Internet and Windows Media Technologies, you can deliver targeted advertising through personalized ad insertion. Figure 7 below illustrates how Windows Media components can be used for personalized ad insertion in live broadcasting.

Figure 7. Components setup for a personalized broadcast image

Figure 7. Components setup for a personalized broadcast

The personalized ad insertion method for delivering broadcast advertising

All users receive the same live programming. However, the personalized advertising is not included in the live broadcast stream. Advertising is delivered to the user as on-demand files, and a method called event switching is used to switch the stream each end user receives between the live stream and on-demand streams.

The complete personalized ad insertion broadcast system also includes interaction between users and a Web server. The Web server delivers Windows Media metafiles containing instructions to prepare each user's Windows Media Player for event switching. These metafiles also contain the properties that define the ads that will be played. Each user can receive a different, personalized set of ads. In addition, a database and ad server system can be used to further refine the personalization. Figure 8 below illustrates the interaction between the components.

Figure 8. Interaction between Web components image

Figure 8. Interaction between Web components

For example, a user clicks a link to receive the broadcast of a football game. The link accesses a Windows Media metafile on a Web server. The metafile starts the broadcast stream and prepares Windows Media Player for event switching. The ads that the metafile calls are ASP pages.

Before clicking the link to receive the game, the user enters information about her location. This information is used to determine which ads she will receive. She lives in Tucson, so she will receive advertising localized to that area. The personalization could be expanded to further define her demographic and target ads for females, age 18 to 49, attending college, and who enjoy rock climbing, for example.

In this case, the football game producers have another motive for using ad insertion in the broadcast besides personalization. Many of the ads in national television broadcasts must be blocked out on the Internet for contractual reasons. As the broadcast proceeds, event switching is used to cut away from the main feed at points when personalized ads must be inserted over national ads. When the personalized ads finish, Windows Media Player resumes the main feed.

The same process is used in a server-side playlist broadcast. A user downloads a metafile that links to a server-side playlist. The event switching commands can be added to the on-demand files in the list, and switching occurs as if the stream is live from an encoder. If the football game is archived and looped as a server-side playlist, for example, the event switching would work the same.

The rest of this topic focuses on how to implement event switching with Windows Media Technologies by using a simple personalization scheme. There are many methods for enhancing personalization of ads with databases, ASP pages, and proprietary ad server programs. For more information about advanced serving of advertising, contact an Advertising Solution Vendor (ASV) that specializes in those services.

How It Works

In broadcast television and radio, a system similar to event switching is used to automate the insertion of local ad breaks within a national broadcast or satellite feed. A similar system could be used to automate event switching. In broadcasting, an inaudible tone, cue signal, or precise timing is used to automate the cut away to local breaks from the network feed.

With event switching, the signal is sent using script commands. At the point in a live encoding session when a break is to occur, two script commands are sent that prepare and execute the switch to an on-demand file in each Windows Media Player. A script command contains two strings of text. The first string, called the Type, normally contains a command that Windows Media Player executes or passes to a browser to execute. The second text string, called the Parameter, normally contains additional information that is used in the execution of the command. In event switching, an OPENEVENT script command type is sent 15 to 20 seconds prior to the point when the switch is to occur. At the switch point, an EVENT script command is sent. The following table describes the elements of the script commands:

Type string Parameter string
OPENEVENT Name of event to be played
EVENT Name of event to be played

The OPENEVENT command acts as a pre-roll for the ad break; the first ad in the break is located by Windows Media Player, then the first five seconds or so are downloaded into a memory buffer. When the EVENT command is received, the switch is made. Because the first part of the ad has been pre-buffered, there is a minimal wait before the ad starts. In some cases, there is little or no additional buffering. If more than one ad is contained in a break, each one is played in order. After the last ad finishes, Windows Media Player resumes the main broadcast feed. The wait between ads is also minimal because pre-buffering takes place automatically between entries in an event.

Seamless stream works the same in event switching as it does in playlists. For more information, see Seamless stream switching. You can create dynamic metafiles for event switching the same way you created dynamic playlists with dynamic entries. For more information, see Playlist Ad Insertion.

Implementing Broadcast Ad Insertion

Two items must be in place for event switching to occur: a Windows Media metafile that implements event switching and the proper script command in the broadcast stream.

Creating the metafile for event switching

The basic metafile for event switching contains two elements: an ENTRY that defines the live or server-side broadcast stream, and one or more EVENT elements that define the playlists for the ad breaks.

The following metafile script plays an example broadcast unicast stream, FootballGame, and defines two events: AdBreak1 and AdBreak2. Each event contains two entries, each containing an ad.

<ASX VERSION="3.0">
<ENTRY>
   <REF HREF="mms://WindowsMediaServer/FootballGame" />
</ENTRY>
<EVENT NAME="AdBreak1" WHENDONE="RESUME">
   <ENTRY CLIENTSKIP="NO">
       <REF HREF="mms://WindowsMediaServer/Ad1.wmv" />
   </ENTRY>
   <ENTRY CLIENTSKIP="NO">
       <REF HREF="mms://WindowsMediaServer/Ad2.wmv" />
   </ENTRY>
</EVENT>
<EVENT NAME="AdBreak2" WHENDONE="RESUME">
   <ENTRY CLIENTSKIP="NO">
       <REF HREF="mms://WindowsMediaServer/Ad3.wmv" />
   </ENTRY>
   <ENTRY CLIENTSKIP="NO">
       <REF HREF="https://AdServer/Ad4.asp" />
   </ENTRY>
</EVENT>
</ASX>

Note that the second ad position in AdBreak2 calls for an ASP page. The use of ASP pages in metafiles enables you to integrate ad servers, for example, to return personalized ads based on a user profile or other parameters. In the first break, the football game producers used their ads to cover national ads. With Ad4.asp in the second break, a Windows Media file is returned based on some user parameter, such as automobile preference. You can follow the same scenario for creating dynamic events as you did for creating dynamic entries.

The WHENDONE="RESUME" attribute defines the behavior of Windows Media Player following the last item in a break. In this case, Resume returns the Player to the main feed, FootballGame.

There is no difference in the sample metafile when using a server-side playlist. The original ENTRY points to a unicast broadcast with the name FootballGame. The broadcast unicast publishing point on the Windows Media server can point to a live stream coming from Windows Media Encoder, or it can be configured to point to a server-side playlist broadcast. In this case, for example, FootballGame could point to the live encoder during the game. After the broadcast is finished, the server can be quickly configured to point the FootballGame publishing point to a server-side playlist that loops playback of the game.

For more information about configuring the server and creating server-side playlists, see Windows Media Services Help.

Inserting an Event script command

Script commands are added while encoding a live program with the Script panel in Windows Media Encoder. To set up a live session that includes script commands, create a new encoding profile, or copy and edit an existing profile, and then select the Script check box in the Edit Profile window.

Figure 9. Edit Profile window showing the Script check box image

Figure 9. Edit Profile window showing the Script check box

On the Common Stream Settings window of the New Session Wizard, type 1000 in the Script text box.

Figure 10. The Script text box in the Common Stream Settings window image

Figure 10. The Script text box in the Common Stream Settings window

After finishing the wizard, the script panel appears in the lower section of the Windows Media Encoder interface. When you start encoding, the script panel becomes enabled. Click the Custom Script Command button, and the Type text box becomes enabled.

Figure 11. Windows Media Encoder interface showing the Script panel image

Figure 11. Windows Media Encoder interface showing the Script panel

To send an event, use the following procedure:

  1. Type OPENEVENT in the type box, and the name of the next event (break) in the parameter textbox.
  2. About 15 to 20 seconds before the switch, click Insert.
  3. Type EVENT in the type box and leave the name of the event in the parameter box.
  4. At the point when you want to switch, click Insert.

Windows Media Player begins buffering the break when it receives the OPENEVENT command, and cuts away to the first ad in the break when it receives the EVENT command.

For more information about setting up Windows Media Encoder for a broadcast encoding session, see Windows Media Encoder Help.

If you want to implement an automated solution, you can create an encoder application with the Windows Media Encoder Software Development Kit (SDK). A programming environment, such as Microsoft Visual Basic® can be used to create a program that controls an instance of Windows Media Encoder. The program can make use of an input port of a computer, such as the serial port or joystick port, to trigger script commands based on switch contact closures. The port can then be connected to an external automation device that detects the presence of cue tones, signals in the vertical interval of the video, or timing cues from an automation system. For more information about creating an encoder application, download the Windows Media Encoder SDK. For more information about developing programs for Microsoft Windows, see the Microsoft Windows Developer Center on the Microsoft Web site.

Streaming Banners

You can enhance your basic Web page banner ad with streaming banners. A streaming banner is a banner that contains an embedded Windows Media Player control or plug-in. When a user opens a Web page containing a streaming banner, the embedded Player opens and streams video that has been produced to fit within the design of the banner. The video can be sized to fit the majority of the space of a traditional 468 x 60 pixel banner, for example 300 x 60. The video can also be clipped and sized to fit many rectangular sizes down to the size of an icon, 32 x 32.

Figure 12 below illustrates how you can design a banner ad around an embedded video stream.

Figure 12. A video banner ad image

Figure 12. A video banner ad

How It Works

The streaming banner is a Web page that can be contained in a frame of a Web page, or created as a freestanding, borderless browser window. The banner page can contain any elements that a standard Web page can contain, including text, background color, images, and Microsoft ActiveX® controls. Streaming video is added using the Windows Media Player control and plug-in. The embedded Player control is configured to display only the video frame at the specified size and to play the video stream as soon as the control opens.

The video should be shot and produced with the specified frame size in mind. When the video is converted to a Windows Media file, the frame is sized and clipped to the exact dimensions specified in the banner design.

Implementing Streaming Banners

To create a streaming banner, produce the video and then design the banner around the embedded Windows Media Player control. Save the banner on the Web server you use to serve ads and the Windows Media content on your Windows Media server.

Producing the video

When shooting or selecting the video to use in the banner, you need to know what the final video frame size will be so that you can estimate the height-to-width ratio. For example, if your banner is 468 x 60 pixels, and the area that holds the embedded Player is 320 x 32 pixels, your height to width ratio would be 1:10. The video that you use for the banner will most likely be standard broadcast video, which has a frame ratio of 3:4. To use standard video for streaming banners, select a 1:10 portion of the full video frame, and then use the custom frame size and clipping settings in Windows Media Encoder to create the final frame. Figure 13 below illustrates a standard video frame and the 1:10 section that has been marked off for the banner.

Figure 13. A video frame showing marks for 1:10 section image

Figure 13. A video frame showing marks for 1:10 section

As you shoot, select, and edit scenes to stream in your banners, refer to this ratio to make sure that the portion of the complete video frame that you want to display in the banner is in the correct ratio. To help, for example, you can create a border with masking tape on your video monitor that approximates the banner ratio.

Save your final full-frame video as an AVI file with audio. Windows Media Encoder cannot encode from an AVI file that does not have an audio track. If you do not want to use audio in your banner, select the Windows Media Audio 7 codec and the 0 kbps, 8 kHz, mono format setting.

Open Windows Media Encoder and configure it to encode a Windows Media file from your AVI source file. Refer to the Help included with Windows Media Encoder for detailed information about encoding files and using encoding profiles. Use the following procedures for clipping and sizing the frame by using Windows Media Encoder.

How to change the frame size
  1. On the Session Properties dialog box, click the Profile tab.
  2. Click Manage.
  3. In the Manage Profiles dialog box, click a suitable profile, such as Video for Web servers (28.8 Kbps), and then make a copy of it. Give it a name that makes sense to you, such as Banner Video (28.8 Kbps).
  4. Click the copied profile and then click Edit.
  5. Proceed through the Edit Profile wizard screens to the Common Stream Settings page.
  6. If you do not want audio, click the Windows Media Audio V7 codec and the 0 kbps, 8kHz, mono format.
  7. In the Video Size box, click Custom.
  8. Type 320 in the Width box and 32 in the Height box.
  9. Close all the dialog boxes. The video frame in the Video Preview pane displays the new frame dimensions.
How to clip the frame

If you encoded the AVI file as it is now, the complete 3:4 frame will appear stretched and compressed to fit the 320 x 32 pixel size. For the video to appear normal, you must use clipping to crop out sections of the full frame so that the portion of the remaining video frame has the correct ratio.

  1. In the Session Properties dialog box, click Change.

  2. In the Change Source Group dialog box, click the Video Clipping tab.

  3. Adjust the Top, Bottom, Left, and Right boxes to clip or crop out parts of the original frame. For example, setting Top to 100 crops the top 100 pixels of the frame. Some experimentation will be required to get the right settings and maintain the ratio of 1:10.

    If your original AVI file is 320 x 240, then you must clip a total of 208 pixels from the top and bottom of the file to obtain a height of 32 pixels. For example, you could use a Bottom setting of 100 and a Top setting of 108. Keep in mind that the minimum height and width of any file is 32 pixels. To determine the height of a video after it has been clipped, subtract the top and bottom setting values from the original video height; in this example, 240 pixels.

After encoding the banner video, copy the file to the Windows Media server. The Windows Media Player control then accesses the file and streams the video in the banner.

Designing the banner

The streaming banner is a Web page displayed either in a frame or as a freestanding borderless browser window. To add streaming video to the page, you embed a Windows Media Player control and plug-in. The following sample banner page script contains text, the Player control, and an image.

<html>
<head>
</head>
<body bgcolor="#000000">
<p>
<font color="#FFFF00" face="Century Gothic" size="5">
Live Quotes</font>
<object classid="clsid:22D6F312-B0F6-11D0-94AB-0080C74C7E95"
id="MediaPlayer1" width="440" height="40">
  <param name="AutoStart" value="-1">
  <param name="AnimationAtStart" value="0">
  <param name="AllowChangeDisplaySize" value="0">
  <param name="Filename" value="mms://WindowsMediaServer/Quotes">
  <param name="ShowControls" value="0">
  <param name="TransparentAtStart" value="-1">
</object>
<img border="0" src="logo2.gif" width="54" height="44">
</font>
</p>
</body>
</html>

The script opens the Windows Media Player version 6.4 ActiveX control, as specified by the CLASSID attribute, and streams the broadcast video stream indicated by the FileName parameter. You can also expand the script to ensure the video streams in browsers that do not support ActiveX controls. The following parameter settings are necessary for the Player control to display properly in the banner:

  • AutoStart = -1. The video plays as soon as the control opens. The user does not start the video manually.
  • AnimationAtStart = 0. By default, the Windows Media Player animation runs until the video starts streaming. When this AnimationAtStart value is set to 0, the video display remains black.
  • AllowChangeDisplaySize = 0. The user cannot change the display size.
  • FileName = mms://WindowsMediaServer/Quotes. Specifies the URL of the digital media stream or file on the Windows Media server.
  • ShowControls = 0. The playback controls are hidden.
  • TransparentAtStart = -1. The Windows Media Player control is transparent unless video is streaming.

Borders in Windows Media Player 7

A border is similar to a skin. However, instead of replacing the entire user interface in the compact mode of Windows Media Player, a border is rendered in the Now Playing feature of Windows Media Player in full mode. A border can be used to present advertisements along with the content in several scenarios. Figure 14 below illustrates a sample border.

Figure 14. A Windows Media Player 7 border image

Figure 14. A Windows Media Player 7 border

This sample border includes text, the video frame, and an ad banner with a hyperlink. Your border could contain multiple images, more hyperlinks, buttons, and so forth. Anything that you can put in a skin, you can put in a border, because a border is simply a skin that has been designed specially to fit in Now Playing.

Because a border can support an ad banner of any size and is not restricted by placement, you can include overlay ads on top of video content. An overlay ad, sometimes referred to as a watermark, is a logo or other image displayed on top of the video content.

For more information, see Creating Custom Skins. For complete information about how to create borders and skins, see the Windows Media Player SDK.

How Borders Work

A skin is a custom user interface for Windows Media Player version 7 and later. Figure 15 below displays one of the skins included with Windows Media Player.

Figure 15. A Windows Media Player 7 skin image

Figure 15. A Windows Media Player 7 skin

You can create your own skins and borders by using scripting in a skin definition file, which is a text file with a .wms file name extension. The skin definition file defines the appearance and behavior of the skin or border. To make the file available to Windows Media Player, use a program that creates compressed files with a .zip file name extension to package the WMS file with any image and Microsoft JScript® files, and then change the .zip file name extension to .wmz. When Windows Media Player opens the compressed skin file with the .wmz file name extension, the skin you created becomes the new Player interface.

To make the skin into a border, create a Windows Media metafile that contains a SKIN element that points to the compressed skin file.

<SKIN href="https://myserver/myborder.wmz"/>

The metafile also contains the URLs of the digital media files, any ad banners, and associated links. When Windows Media Player opens the metafile and encounters the SKIN element, it downloads the border file and renders the skin in the Now Playing feature. Then, it plays the content.

Implementing Borders

The following is an example of a simple but complete metafile script that implements a border:

<ASX version="3.0">
   <SKIN href="https://MyServer/MyBorder.wmz"/>
   <ENTRY>
      <REF href="mms://MyWindowsMediaServer/Song1.wma"/>
   </ENTRY>
</ASX>

In this example, Windows Media Player downloads MyBorder.wmz, displays the skin as a border, and starts streaming Song1.wma. When the metafile is opened by Windows Media Player 6.4 and earlier, the content plays, but the SKIN element is ignored.

A skin definition file also gives you the opportunity to enhance the manner in which banners are displayed. Normally a banner has a fixed maximum size and appears in the area at the bottom of the video display. With borders, you have much more control over the size and placement of banners. For example, you can include many types of images, such as album art or dynamically updated banner ads. You define banners by using scripting in the skin definition file. The following script in a skin definition file defines how a banner displays.

<!-- Create the button element that contains the banner image. -->
<BUTTON 
    id = "AdBanner"
    width = "194" 
    height = "32"
    top = "303" 
    left = "25"

    image = "WMPImage_AdBanner"

    onClick = "onBannerClick();"
    onMouseOver = "onBannerMouseOver();"
    onMouseOut = "onBannerMouseOut();">
</BUTTON>

A banner is defined within a BUTTON element. In the example, the BUTTON is first identified with the name AdBanner, and then sized and positioned.

The final three lines of the script are event handlers. Clicking the ad banner, for example, triggers the onClick event. This event calls the following onBannerClick function in an external JScript file declared earlier in the definition file.

Function onBannerClick()
{
var strTargetURL = player.currentMedia.getItemInfo("BannerInfoURL");
   if ( strTargetURL != "")
   {
   player.launchURL(strTargetURL);   
   }
}

The function launches a user's default browser and opens a Web page, such as that of an advertiser. The method player.currentMedia.getItemInfo assigns the URL associated with the string BannerInfoURL to the variable strTargetURL, which then opens the URL in a user's default browser with the Player method launchURL. BannerInfoURL is a Windows Media Player keyword that defines the URL as that which is assigned to the MOREINFO element of an entry in the Windows Media metafile. When the user clicks the ad banner, Windows Media Player uses the MOREINFO URL of the current entry to launch the browser.

The Image property in the skin definition file defines the image to be used in the button. You can assign any image and then include it in the compressed skin file. In this case, however, the keyword WMPImage_AdBanner is used. This keyword defines the image as that which is assigned as the BANNER image in the metafile.

The following metafile assigns the banner image AdBanner.gif and a MOREINFO hyperlink to the ad banner button.

<ASX version="3.0">
   <SKIN href="https://MyServer/MyBorder.wmz" />
   <ENTRY> 
      <REF href="mms://MyWindowsMediaServer/Song1.wma" />
      <BANNER href="https://MyServer/Images/AdBanner.gif">
         <MOREINFO href="https://examples.microsoft.com/" />
      </BANNER>
   </ENTRY>
</ASX>

The following script is the complete skin definition file for the border shown at the beginning of this topic.

<!-- Skin definition file for a border with an ad banner -->
<THEME>
<VIEW 
   id = "main" 
   height = "600" 
   width = "800" 
   titlebar = "false" 
   backgroundColor = "black">

   <!-- Create the text element to hold messages. -->
   <TEXT 
      id = "text1" 
      value = "Enjoy the video!" 
      foregroundColor = "white"
      fontSize = "14">
   </TEXT>

   <!-- Create a subview element to contain the video and the banner. -->
   <SUBVIEW 
      id = "svBanner"
      zindex = "2"
      left = "20"
      top = "20" 
      width = "755"
      height = "555"
      backgroundColor = "black"
      horizontalAlignment = "left" 
      visible = "true">

      <!-- Create the video element. Set windowless = "true" so 
      the banner overlays the video image. -->
      <VIDEO 
         id = "video" 
         windowless = "true"  
         top = "25" 
         left = "25">
      </VIDEO>

      <!-- Create the button element that contains the banner image. -->
      <BUTTON 
         id = "AdBanner"
         width = "194" 
         height = "32"
         top = "303" 
         left = "25"

         image = "WMPImage_AdBanner"

         onClick = "OnBannerClick();"
         onMouseOver = "OnBannerMouseOver();"
         onMouseOut = "OnBannerMouseOut();">
      </BUTTON>

   </SUBVIEW>

   <!-- Provide an event for the player element to initialize. -->
   <PLAYER CurrentMediaItemAvailable = "OnCurrentMediaItemAvailable();">
   </PLAYER>
</VIEW>
</THEME>
Creating dynamic borders

As with metafiles that contain playlists (described earlier in this article), metafiles that contain borders can be generated dynamically with ASP pages. You can create an ASP page and script file, for example, that generates an entire metafile with links to a border, multiple banners, a playlist, and MOREINFO links. The banner image assigned in the metafile can also be referenced by an ASP page URL, as in the following script.

<BANNER href="https://MyServer/Images/AdBanner.asp">

This can be useful if the banner image is unknown when the metafile is created, or the metafile is created in a separate process from the ad banners, such as if the banners come from an Advertising Solution Vendor. The primary purpose of dynamically generating a border with a server-side script is to populate the border with the most current ads. Using ASP pages in place of fixed banner images is one simple way to accomplish this.

For More Information

  • Windows Media Encoder Help. You can download Windows Media Encoder and other encoding tools from the Windows Media section of the Microsoft Web site.
  • Windows Media Encoder SDK. Download the SDK from the MSDN download site.
  • Windows Media Player SDK. Download the SDK from the MSDN download site.