Embedding Sound in Web Pages, Part II: Initializing the Song and Volume Arrays - Doc JavaScript
Initializing the Song and Volume Arrays
Each song in the jukebox is represented as an object with two properties: the URL of the audio file and the name of the song. Here's the function that creates such objects:
function makeSong(url, name) {
this.url = url;
this.name = name;
}
Note that the URL
property can be a full or relative path. The name
property determines the song's name, which is displayed in the menu. The songs
variable is simply an array of makeSong
(our constructor) objects.
Now let's take a look at the song definitions:
var songs = new Array();
songs[0] = new makeSong("eleanor.mid", "Eleanor");
songs[1] = new makeSong("girl.mid", "Girl");
songs[2] = new makeSong("michelle.mid", "Michelle");
songs[3] = new makeSong("sheway.mid", "She's Got a Way");
songs[4] = new makeSong("wholenew.mid", "A Whole New World");
This is the only segment in the script that sets the songs in the jukebox. The <EMBED>
definition references the URL of the first song, so songs[0]
determies the first song to be loaded.
The IEvolume
array holds Internet Explorer's ten volume levels that corresponds to the ten dots of our volume gauge. Explorer's volume levels range from -10000 (no volume) to 0 (full volume), measured in hundredths of decibels.
The NSvolume
array holds Navigator's ten volume levels that corresponds to the ten dots of the volume gauge. Navigator's volume levels range from 0 (no volume) to 100 (full volume). The LivaAudio plug-in seems to have a bug in its volume control. Therefore, our custom volume controls may not affect the actual volume (neither will the defailt LiveAudio panel).
Created: July 6, 1998
Revised: July 6, 1998
URL: https://www.webreference.com/js/column21/songs.html