RSS

Adding audio with HTML

07 Jan
<object classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B"
 codebase="http://www.apple.com/qtactivex/qtplugin.cab" width="200" height="16">

<param name="src" value="fileName.mp3" />
 <param name="controller" value="true" />
 <param name="autoplay" value="false" />
 <param name="autostart" value="0" />
 <param name="pluginspage" value="http://www.apple.com/quicktime/download/" />

<!--[if !IE]> <-->

<object type="audio/x-mpeg" data="fileName.mp3" width="200" height="16">
 <param name="src" value="fileName.mp3" />
 <param name="controller" value="true" />
 <param name="autoplay" value="false" />
 <param name="autostart" value="0" />
 <param name="pluginurl" value="http://www.apple.com/quicktime/download/" />

</object>

<!--> <![endif]-->

</object>

IE and non-IE browsers treat audio objects in a web page two different ways. Therefore <Object> should be used carefully in order to play the audio in all browsers perfectly. In the code, there are two sections for IE and other browsers like FF.

IE looks for class Id before playing audio.  But other browsers do not use this attribute. They rely on the MIME type of the audio object. In the above code commented section is used by non IE  browsers to play audio.

Some Other sound formats

  • au (type=”audio/basic”)
  • wav (type=”audio/wav” or “audio/x-wav”)
  • ra (type=”audio/x-pn-realaudio”)
  • mp3 (type=”audio/x-mpeg”)
  • wma (type=”audio/x-ms-wma”)

Alternatives for class Id

Advertisements
 
Leave a comment

Posted by on January 7, 2012 in HTML

 

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
%d bloggers like this: