spacer
Yehuda Shiran December 11, 1999
Media Player Programming
Tips: December 1999

Yehuda Shiran, Ph.D.
Doc JavaScript

Developer News
OpenOffice 3.2 Lands Amid Critical Changes
Red Hat, IBM Firmly in KVM Virtualization Camp
Red Hat Talks Up Open Source Cloud Plans

The Windows Media Player comes in two versions: ActiveX control for Internet Explorer 4.0 and up, and plugin for everything else. The set of the ActiveX control's properties, methods, and event handlers is very similar to the plugin's. The names of the methods and events are identical. The properties are different though. While you can set and get the ActiveX control's properties as they are, you have to use the plugin's set and get methods to set and get, respectively, the plugin's properties. Let's take the ActiveX control's fileName property. You can set it in the ActiveX control as follows:

document.mediaPlayer.fileName = url;

You can get it simply by referring to document.mediaPlayer.fileName. In the plugin Media Player, you can set it as follows:

document.mediaPlayer.SetFileName(url);

and get it:

document.mediaPlayer.GetFileName();

To streamline the integration between the ActiveX control and plugin conventions, we chose to write our own functions for getting and setting properties. In this way, the difference between the browsers is reflected only inside our functions, leaving the overall script quite generic and neat. For example, let's examine the function that sets the media file name, setFileName():

function setFileName(url) {
  if (activeX)
    document.mediaPlayer.fileName = url
  else
    document.mediaPlayer.SetFileName(url);
}

Now, let's examine a get function. Here is the function that gets the showControls flag:

function getShowControls() {
  if (activeX)
    return document.mediaPlayer.showControls;
  else
    return document.mediaPlayer.GetShowControls();
}

You can learn more about multi-browser Media Player programming from Column 53, A Streaming Media JukeBox, Part III: Browser-Independent.


People who read this tip also read these tips:

Look for similar tips by subject:


The Network for Technology Professionals

Search:

About Internet.com

Legal Notices, Licensing, Permissions, Privacy Policy.
Advertise | Newsletters | E-mail Offers

webref The latest from WebReference.com Browse >
Installing and Using Meeplace, the Business Review CMS · Sending an HTML and Plain Text E-newsletter with ASP.NET, Part 2 · Create Multilingual Web Sites with Windows Unicode Fonts
Sitemap · Experts · Tools · Services · Email a Colleague · Contact FREE Newsletters 
 The latest from internet.com
MySql View Technique for Grouping Crosstab Column Data · Why You Need a Mobile Web Site · Tame Web Marketing with Social Media Management