advertisement

Article:
  Build a Simple MP3 Player for Your Site
Subject:   How to make pop-up MP3 player work in all browsers
Date:   2005-04-14 21:52:12
From:   Gary_Burke
Hello all,


From the Microsoft Software Developer's site comes information saying that if you want the embedded or Pop-Up Media Player to work in both Internet Explorer and Netscape/Firefox you have to use the <object> tag wrapped around the <embed> tag in order to get it to work. I tried it as a player embedded in a web page and it worked on all three browsers. Getting it to work in a Pop-Up version is beyond my capabilities as a script writer; David has sent me an e-mail saying he thinks the Javascript needs to be re-written in order for this to work as a cross-browser Pop-Up player. Now having read the material from Microsoft, I agree.


According to Microsoft's SDK for PC/Mac verisons of the Media Player, to get an embedded or Pop-Up player to work on all browsers on both PC and Mac is a challenge, having something to do with how Active X is supported on Mac. Hmmm. Well, hopefully David will put some more thought into this and then we'll all have a really cool media tool at our disposal. I scoured the net for hours, and besides Flash-based players (I can't afford to buy Flash right now) there dooesn't seem to be a MP3 player, streaming or otherwise, that works on everything. At least I couldn't find the code for it.


Here is Microsoft's recommendation for how to script an embedded Media Player for the three major browser types: I.E., Netscape and Firefox. I got it to work; your mileage may vary. Compare it to David's Javascipt "Soundpop.js" file and you will see obvious differences:


Embedding Microsoft Windows Media Player


To accommodate cross-browser compatibility, you can enable Windows Media Player in a Web page so that it can be successfully downloaded to either Microsoft Internet Explorer or Netscape Navigator. For Netscape Navigator, use the EMBED tag to embed a plug-in. For Internet Explorer, use the OBJECT tag to embed the Microsoft ActiveX control. To ensure that Windows Media Player is enabled properly for both types of browsers, you can nest the EMBED tags within the OBJECT tags, as illustrated in the following code segment.


<OBJECT ID="MediaPlayer" WIDTH=320 HEIGHT=240
CLASSID="CLSID:22D6F312-B0F6-11D0-94AB-0080C74C7E95"
STANDBY="Loading Windows Media Player components..."
TYPE="application/x-oleobject">


<PARAM NAME="FileName" VALUE="demo.asf">
<EMBED TYPE="application/x-mplayer2"
SRC="C:\Program Files\Windows Media Components\SDK\Samples\Plugin\demo.asf"
NAME="MediaPlayer"
WIDTH=320
HEIGHT=240>
</EMBED>
</OBJECT>


In this example, Windows Media Player is configured to play the demo.asf file in the C:\Program Files\Windows Media Components\SDK\Samples\Plugin directory. The Windows Media Player control is identified as MediaPlayer, which is specified by the ID attribute of the OBJECT tag. The plug-in is also named MediaPlayer, which is specified by the NAME attribute of the EMBED tag. You can use the object identifier MediaPlayer, in the script to refer to the Windows Media Player when invoking methods, accessing properties, and handling events.


The preceding code example uses branded MIME types to load Windows Media Player to play a Windows Media file. This use of branded MIME types ensures automatic version upgrade for the plug-in on a user machine. All other supported media types can be specified in a similar fashion.


I would still like someone to tell me why the embedded Quicktime player wouldn't work for me.


Gary Burke