Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Apr 2007
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    javascript jukebox

    Dear All,
    Go easy on me, i'm new to javascript and as a project for uni i'm making a jukebox using an array for an album, however when i run it it does not display the items within my array even tho i use a document.writeline function.

    <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>

  • #2
    Regular Coder riptide's Avatar
    Join Date
    Jan 2007
    Posts
    143
    Thanks
    1
    Thanked 0 Times in 0 Posts
    I'm trying to do something along those lines. I need help to


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •