Embedding Windows Media Player WMA

It's definitely smart to make your audio offerings available for subscription via RSS and direct download via a Website link. Enabling audio playback from the familiar audio playback experience of the Windows Media Player play controls helps get some listeners past the hurdle of figuring out how to tune in. If your audio file is a WMA or MP3 file, there are a few simple steps to linking your audio to Windows Media Player controls imbedded in the browser.

When you offer a direct download, users click on a link to the audio file and either view the video in their desktop Windows Media Player or save it to their hard drive. To stream your audio file with visible Windows Media Player controls, you need to embed the player in the page where you post your audio file. This requires some specific HTML code included in the page or blog post where the audio is linked.

There are some potential headaches to this method, including 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 this looks like the example below:

<object id="MediaPlayer" height=46 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 audio file, which is defined using the "filename" parameter:

<param name="filename" value="http://yourdomain/youraudio.mp3">

Some optional parameters include showing the Windows Media Player controls and whether the audio starts automatically. Since you are using the Showcontrols parameter, keep in mind your player height should be 46 pixels to accommodate the height of the files. The height parameter isn't required, but leaving it out causes the player to resize as it's loading, creating an ugly experience for your listener.

<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://yourdomain.com/youraudio.mp3" 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 audio file where appropriate and adjust the necessary height settings.

<object id="MediaPlayer" height=46 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.com/youraudio.mp3">
<param name="Showcontrols" value="True">
<param name="autoStart" value="True">

<embed type="application/x-mplayer2" src=" http://yourdomain.com/youraudio.mp3" name="MediaPlayer"></embed>

</object>

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

Here's an example of the code in action:

For more advanced streaming needs, consider using a Windows Streaming Server to manage your audio 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.