Richard's JavaScript Tutorials

Updated 07/18/14

Home
Animation
precachedImages
digitalClock
Object Tag (Audio)
Cookies.htm
Math_Object
Using CSS
The Style Object
Client_Info
customObject
functions
UsingArrays
comments
concatenation
documentwrite
ifelse
Loops
forms
Strings
variables

 

Streaming audio with the object tag

In this section I'll show you how to stream audio using the object tag. You can also use the bgsound and or embed tags to use music on your web pages however the W3C promotes using the newer object tag to use audio in your web pages. Below is my example of audio streaming "Hail to the Redskins" . For some reason the object tag doesnt work in FireFox so I'll use the embed tag for Firefox.

Firefox (works in IE too)

Now the IE version using the Object Tag

The best method is to use the embed tag because it works in all platforms and browsers. Note*** You can easily put the code in a JavaScript function for some kind of event handler

Now here is the code using the object tag:

// This is where the size of the display and the audio selection is made
<object data="Hail.mp3" width="100" height="50">

// Here are the parameters I have included you can use only the parameters you need.
// For this example I have just chosen a few of the most basic ones.
<param name="src" value="Hail.mp3">
<param name="autostart" value="false">
<param name="hidden" value="true">
</object>

and finally the code for the embed tag

<embed src="http://www.cayemay.com/Hail.mp3" autostart="false" loop="false">
</embed>

Very short and simple the object and the parameters. There are many other parameters that you can use to manipulate your page you can find all of the parameters on the net or try searching the w3c website to find them. Sounds work funny ways in different browsers so make sure you test them in different platforms and browsers before uploading them to a live webpage.


Now try replacing my audio file "Hail.mp3" with one of your own audio files to create your own web pages with audio. For question about this script or any other script on this website you can e-mail me  webmaster@cayemay.com

 

Home | Animation | precachedImages | digitalClock | Object Tag (Audio) | Cookies.htm | Math_Object | Using CSS | The Style Object | Client_Info | customObject | functions | UsingArrays | comments | concatenation | documentwrite | ifelse | Loops | forms | Strings | variables

This site was last updated 07/18/14