The Mpeg Dilemma

Bad HTML Code

A javascript variant of the code below is used to play an mpeg on my home page <http://vic.norton.name>. This code is not valid HTML 4.01 code because the EMBED element is undefined in HTML 4.01. Nevertheless the code works on every browser I have tested.

   <embed
      src="Everything_Funky.mp3"
      width=180 height=16
      autostart=false loop=false
      volume=75>
   </embed> <!-- closing tag unnecessary -->

Javascript Code

The following audio player was created by a javascript realization of the invalid HTML code. The javascript hides the EMBED tag from any HTML validator—including the validator at the bottom of this page. This player should work on any browser that supports javascript.



   <script type="text/javascript">
      newMpegPlayer("player", "Everything_Funky.mp3",
         180, 18, 75,
         "true", "false", "false");
   </script>
Here is the code for the newMpegPlayer function with examples of its use.

Valid HTML Code 1

The OBJECT code that calls the following audio player (if you can see an audio player) is valid HTML 4.01 code. It works on Firefox but does not work on Internet Explorer (Windows). Click on the player (if you can see it). Does it work on your browser?


   <object
      data="Everything_Funky.mp3"
      type="audio/mpeg"
      width=180 height=16>
      <param name=src value="Everything_Funky.mp3">
      <param name=autoplay value=false>
      <param name=loop value=false>
      <param name=volume value=75>
   </object>

Valid HTML Code 2

The OBJECT code that calls the following audio player (if you can see an audio player) is valid HTML 4.01 code. It works on Internet Explorer (Windows) but does not work on Firefox. Click on the player (if you can see it). Does it work on your browser?


   <object
      classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B"
      codebase="http://www.apple.com/qtactivex/qtplugin.cab"
      type="audio/mpeg"
      width=180 height=16>
      <param name=src value="Everything_Funky.mp3">
      <param name=autoplay value=false>
      <param name=loop value=false>
      <param name=volume value=75>
   </object>

The Mpeg Dilemma

The EMBED element is not defined in HTML 4.01. The OBJECT element is supposed to replace EMBED. However, it seems to be impossible to use OBJECT without EMBED to represent an audio player that works on all browsers. Safari and iCab are the only browsers I know of that can represent and play both examples of “valid” HTML code above.


[home]
Last updated: 15-Jan-08
Valid HTML 4.01 Transitional Valid CSS!