Embedding Windows Media Player WMV

When you create a WMV movie using Windows Movie Maker, Windows Media Encoder or any of the dozens of video editing apps supporting WMV, you have a number of options for sharing your video. The widest audience is obviously online. Windows Movie Maker includes a rather deceptive Save to the Web option, which really means, "save to Web if you have an account with Neptune Mediashare." You don't need to use Neptune or the Save to the Web option to in Windows Movie Maker to share your videos online.

There are two primary ways to share a WMV file online: direct download or streaming playback. A third option would be to offer the video as an RSS subscription, which is loosely related to direct downloads and gets covered in another article. When you offer a direct download, users click on a link to the video file and either view the video in their desktop Windows Media Player or save it to their hard drive. To stream a Windows Media video file, you need to embed the Windows Media Player in the page where you post the video. This requires some specific HTML code included in the page or blog post where the video is linked.

There are some potential headaches to this method, like support for browsers like Firefox and Safari. Mac users don't have Windows Media Player installed by default and Safari issues a nasty warning message with no link to the resolution on Macs without Windows Media Player. Internet Explorer handles embedded Windows Media files nicely, which is to be expected since it's also a Microsoft product. For broad compatibility with all browsers, it's best to stick with the version 6.4 embedded player (which has nothing to do with the version of desktop player the user might have installed).

There are certain things every embedded Windows Media Player needs to function properly, along with a long list of optional parameters. Each embedded player instance on your Web page needs the object definition to clarify which version of the Windows Media Player will be called. This is identified by both the CLSID reference and the CODEBASE definition. For the 6.4 version of the embedded player, an will look like this (the width and height may be different depending on your actual movie size):

<object id="MediaPlayer" width=320 height=286 classid="CLSID:22D6f312-B0F6-11D0-94AB-0080C74C7E95" standby="Loading Windows Media Player components..." type="application/x-oleobject" codebase="http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=6,4,7,1112">

The one required parameter is the location of your movie, which is defined using the "filename" parameter:

<param name="filename" value="http://yourdomain/yourmovie.wmv">

Some optional parameters include showing the Windows Media Player controls and whether the movie will start automatically. If you use the Showcontrols parameter, keep in mind your movie height needs to be 46 pixels bigger than the movie so your file doesn't get scrunched. A movie with a height of 240 would need to have a height reference of 286 to display accurately.

<param name="Showcontrols" value="True">
<param name="autoStart" value="True">

The final part of the implementation is the embed statement which includes the application you are embedding and a link to your video file like this:

<embed type="application/x-mplayer2" src="http://media.pmcmovies.com/SixtiesLove.wmv" name="MediaPlayer" width=320 height=240></embed>

The finished code looks like the example below, which you can copy for your own site and simply replace the links to your movie file where appropriate and adjust the necessary height settings.

<object id="MediaPlayer" width=320 height=286 classid="CLSID:22D6f312-B0F6-11D0-94AB-0080C74C7E95" standby="Loading Windows Media Player components..." type="application/x-oleobject" codebase="http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=6,4,7,1112">

<param name="filename" value="http://yourdomain/yourmovie.wmv">
<param name="Showcontrols" value="True">
<param name="autoStart" value="True">

<embed type="application/x-mplayer2" src="http://media.pmcmovies.com/SixtiesLove.wmv" name="MediaPlayer" width=320 height=240></embed>

</object>

Be sure to close the whole thing with that ending </obeject> tag.

For more advanced streaming needs, consider using a Windows Streaming Server to manage your video files, which allows you to offer files capable of detecting the users connection speed for an optimized experience and include things like advertising when appropriate.