Angelojoseph17
04-17-2007, 08:01 AM
I'm new to javascript and dom, and i'm trying to make an offline jukebox player. I have used arrays to store the songs and onclick functions to play and stop songs. but none of the song names show on up in the browser when i run it. can anyone help?
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>JukeBox V1.0</title>
<script type="text/javascript">
function new_song(sN, fN){
this.songName = sN;
this.fileName = fN;
}
var album1 = new Array(5);
album1[0] = new new_song("I Will remember", "albertlucj/iwillremember.wav");
album1[1] = new new_song("Life Has Begun","albertluck/lifehasbegun.mp3 ");
album1[2] = new new_song("Valentine", "albertluck/Valentine.mp3");
album1[3] = new new_song("Time of Your Life", "albertluck/timeofyourlife.mp3");
album1[4] = new new_song("Yesterday", "albertluck/yesterday.mp3");
/*Repeat chunk for new album*/
function checkPlay(){
var ppb = document.getElementById("ppbutton");
if(ppb.value != 'Play'){
ppb.value = 'Play'
}
}
function playpause(){
var songCurrent = document.getElementById("playerOb");
var ppb = document.getElementById("ppbutton");
if(ppb.value == 'Play'){
songCurrent.controls.play();
ppb.value = 'Pause';
} else{
songCurrent.controls.pause();
ppb.value = 'Play';
}
}
function stopSong(){
var songCurrent = document.getElementById("playerOb");
songCurrent.controls.stop();
checkPlay();
}
function playSong(aN,sN){
checkPlay();
var songLoc;
switch(aN){
case 1: songLoc = album1[sN]; break;
case 2: songLoc = album2[sN]; break;
case 3: songLoc = album3[sN]; break;
}
var songName = songLoc.songName;
var fileName = songLoc.fileName;
var writeTest = document.getElementById("testwrite");
writeTest.firstChild.nodeValue = "fileName: "+fileName+" \n";
/*Write in the song name*/
var writeName = document.getElementById("songNameH");
writeName.firstChild.nodeValue = "Name: "+songNameH+" \n";
/*add the song to be played*/
var playelem = document.getElementById("playerDiv");
playelem.innerHTML = '<object id="playerOb" width="0" height="0" classid="CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6">'
+'<param name="autoStart" value="false">'
+'<param name="URL" value="'+fileName+'">'
+'</object>';
}
function song(num){
var elem = document.getElementById("testwrite");
elem.firstChild.nodeValue = "Num value = "+num+".";
}
function loader(num){
}
</script>
</head>
<body>
<div id="body">
<div id="content">
<div id="header" class="width100">
JukeBox V1.0
</div>
<div id="column1" class="floatleft width25">
<div class="group">
<div id="groupname" onclick="Effect.toggle('album1','slide')">
Albert Luck
</div>
<div id="album1" style="display:none;">
<a href="#" onclick="playSong(1,0)">I will Remember</a><br />
<a href="#" onclick="playSong(1,1)">Life Has Begun</a><br />
<a href="#" onclick="playSong(1,2)">Valentine</a><br />
<a href="#" onclick="playSong(1,3)">Time of Your Life</a><br />
<a href="#" onclick="playSong(1,4)">Yesterday</a><br />
</div>
</div>
<div id="column2" class="floatright width73">
<div id="testwrite">fileName:</div>
<div id="songNameH">Name:</div>
<div id="playerDiv">
</div>
<br />
<input type="button" value="Play" onclick="playpause()" id="ppbutton" />
<input type="button" value="Stop" onclick="stopSong()" />
</div>
</div>
</div>
</body>
</html>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>JukeBox V1.0</title>
<script type="text/javascript">
function new_song(sN, fN){
this.songName = sN;
this.fileName = fN;
}
var album1 = new Array(5);
album1[0] = new new_song("I Will remember", "albertlucj/iwillremember.wav");
album1[1] = new new_song("Life Has Begun","albertluck/lifehasbegun.mp3 ");
album1[2] = new new_song("Valentine", "albertluck/Valentine.mp3");
album1[3] = new new_song("Time of Your Life", "albertluck/timeofyourlife.mp3");
album1[4] = new new_song("Yesterday", "albertluck/yesterday.mp3");
/*Repeat chunk for new album*/
function checkPlay(){
var ppb = document.getElementById("ppbutton");
if(ppb.value != 'Play'){
ppb.value = 'Play'
}
}
function playpause(){
var songCurrent = document.getElementById("playerOb");
var ppb = document.getElementById("ppbutton");
if(ppb.value == 'Play'){
songCurrent.controls.play();
ppb.value = 'Pause';
} else{
songCurrent.controls.pause();
ppb.value = 'Play';
}
}
function stopSong(){
var songCurrent = document.getElementById("playerOb");
songCurrent.controls.stop();
checkPlay();
}
function playSong(aN,sN){
checkPlay();
var songLoc;
switch(aN){
case 1: songLoc = album1[sN]; break;
case 2: songLoc = album2[sN]; break;
case 3: songLoc = album3[sN]; break;
}
var songName = songLoc.songName;
var fileName = songLoc.fileName;
var writeTest = document.getElementById("testwrite");
writeTest.firstChild.nodeValue = "fileName: "+fileName+" \n";
/*Write in the song name*/
var writeName = document.getElementById("songNameH");
writeName.firstChild.nodeValue = "Name: "+songNameH+" \n";
/*add the song to be played*/
var playelem = document.getElementById("playerDiv");
playelem.innerHTML = '<object id="playerOb" width="0" height="0" classid="CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6">'
+'<param name="autoStart" value="false">'
+'<param name="URL" value="'+fileName+'">'
+'</object>';
}
function song(num){
var elem = document.getElementById("testwrite");
elem.firstChild.nodeValue = "Num value = "+num+".";
}
function loader(num){
}
</script>
</head>
<body>
<div id="body">
<div id="content">
<div id="header" class="width100">
JukeBox V1.0
</div>
<div id="column1" class="floatleft width25">
<div class="group">
<div id="groupname" onclick="Effect.toggle('album1','slide')">
Albert Luck
</div>
<div id="album1" style="display:none;">
<a href="#" onclick="playSong(1,0)">I will Remember</a><br />
<a href="#" onclick="playSong(1,1)">Life Has Begun</a><br />
<a href="#" onclick="playSong(1,2)">Valentine</a><br />
<a href="#" onclick="playSong(1,3)">Time of Your Life</a><br />
<a href="#" onclick="playSong(1,4)">Yesterday</a><br />
</div>
</div>
<div id="column2" class="floatright width73">
<div id="testwrite">fileName:</div>
<div id="songNameH">Name:</div>
<div id="playerDiv">
</div>
<br />
<input type="button" value="Play" onclick="playpause()" id="ppbutton" />
<input type="button" value="Stop" onclick="stopSong()" />
</div>
</div>
</div>
</body>
</html>