HTML, XHTML & CSS FAQ

Streaming Media

You need to embed your player into the page using the <object> tag for IE and the <embed> tag for NS. You can encapsulate the <embed> in the <object> so that IE only sees the <object> and NS only sees the <embed>.

Ignore the spaces after the slashes in the URLs... they are only there so it would line break and not scroll all the way across the page.

Now, in order to access the plugin from JavaScript, it can be referenced as document.Video or, what I like to do is to name a simple variable:var Player = document.Video;

To assign a file, you should do one of two things. One, you could set the FileName and SRC attributes in the tags. Two, you could set it via JavaScript:if (IE) {Player.FileName = your_file;}else {Player.SetFileName(your_file);}

This way you can set it dynamically by choosing amongst several files, for instance. your_file can be any media type that WMP can play (mp3, wav, asf, wmf, etc).

In order to play the file, you should use:Player.Play();

There are many other functions you can use, such as stop, fast forward, pause, rewind, etc. There are also other attributes you can access such as the position, packets received, reception quality, etc. Download the WMP SDK from http://www.microsoft.com for more info on that.

On Netscape, before using the media player functions, you have to initialize the plugin. In your body tag, call a function onload (ie. onLoad="start()"). In that function, you should register your event observers. Below is an example of my start() function:function start() { if (!document.all) {document.all = document.layers}; Player = document.Video;