03-10-2005, 01:06 AM | #1 (permalink) | |
Oh shit it's Wayne Brady!
Location: Passenger seat of Wayne Brady's car.
|
[Javascript/HTML] Random Music Player
Hi. I'd like to know how to program a random music player that would work on any standard web browser. Here is the code I have so far:
Code:
<html> <body> <h2>NAME OF SONG</h2> <object height="50%" width="50%" classid="clsid:22D6F312-B0F6-11D0-94AB-0080C74C7E95"> <param name="AutoStart" value="0" /> <param name="FileName" value="URLtoSONG.wav" /> </object> </body> </html> 1) I need it to work similar to the standard HTML code above as far as how user-friendly it is and how it is displayed. 2) I need either a random or sequential number within a range to be selected every time an external button (placed under the display, saying "Click here to change the song!") is clicked. 3) I need an "if" clause that aligns that range of numbers with URLs to different songs (which I will provide later), and then assigns them to the "FileName" value in the code above. 4) I also need the range of numbers to be assigned to the names of the songs, which will display in a label above the display. 5) If at all possible, it would also be cool if there can be a checkbox stuck next to the display that says "Autoplay?", and when checked, it would assign "AutoStart" value to "1", and when unchecked, it would assign that same value to "0". Can anyone help me out with this? I've been wondering how to do this for quite some time. I've accomplished it in Visual Basic, but I have absolutely no experience with Javascript, and I haven't done any Visual Basic work at all for over 2 years.
__________________
The words "love" and "life" go together. It is almost as if they are one. You must love to live, and you must live to love, or you have never lived nor loved at all. Quote:
|
|
03-18-2005, 11:07 PM | #2 (permalink) | |
Oh shit it's Wayne Brady!
Location: Passenger seat of Wayne Brady's car.
|
I'd really appreciate it if someone could point me in the right direction here.
__________________
The words "love" and "life" go together. It is almost as if they are one. You must love to live, and you must live to love, or you have never lived nor loved at all. Quote:
|
|
04-04-2005, 09:03 AM | #3 (permalink) | |
Oh shit it's Wayne Brady!
Location: Passenger seat of Wayne Brady's car.
|
Anyone? Please?
__________________
The words "love" and "life" go together. It is almost as if they are one. You must love to live, and you must live to love, or you have never lived nor loved at all. Quote:
|
|
04-04-2005, 01:22 PM | #4 (permalink) |
Sky Piercer
Location: Ireland
|
I have very little experience with javascript, and what little I did was quite a while ago, so there is certainly a more elegant way to do this, but here I go:
Code:
<HTML> <BODY> <SCRIPT> num_of_songs = 3 randnum = Math.round(Math.random()*(num_of_songs-1)) + 1 if(randnum == 1){ filename = "song1.wav"; songname = "Name of first song"; }else if(randnum == 2){ filename = "song2.wav"; songname = "Name of second song"; }else if(randnum == 3){ filename = "song3.wav"; songname = "Name of thrd song"; } document.write("<H2>"); document.write(songname); document.write("<\H2>"); document.write("<object height=50% width=50% classid=clsid:22D6F312-B0F6-11D0-94AB-0080C74C7E95> <param name=AutoStart value=0 /> <param name=FileName value='"); document.write(filename); document.write("'/></object>"); </SCRIPT> <P> <A HREF="javascript:history.go()">Click here to change track</A> </BODY> </HTML> The "change track" link actually refreshes the page, causing a different random number to be picked. This might not be a very satisfactory way of doing it, but its a start at least. Unfortunately, this method does not lend itself to easily implementing your "Autoplay" check box.
__________________
Last edited by CSflim; 04-04-2005 at 03:07 PM.. |
Tags |
javascript or html, music, player, random |
|
|