UBB.Dev
Posted By: Felix 10 music changer - 12/30/2004 6:26 AM
I have this code in my Header
Code
 <embed height="1" src="http://www.romanianational.com/ubb/christmas/carols/cvpastori.mid" width="1" EN? 3.2 HTML DTD W3C ?- PUBLIC <!DOCTYPE AUTOSTART="TRUE">  
which plays a Christmas song on the page. Is there a way to make the .mid file change automatically every day without editing the Style Header daily?

Felix
Posted By: Ian Spence Re: music changer - 12/30/2004 7:13 AM
um, upload a different song to that url everyday?


and about the html, how about something like

Code
<embed src="http://www.romanianational.com/ubb/christmas/carols/cvpastori.mid" style="display: none;" autostart="true"></embed>
I doubt it's the right syntax, but it's probably a lot closer than what you have
Posted By: Felix 10 Re: music changer - 12/30/2004 5:46 PM
Yes, your code is much cleaner. Mine was generated by the FrontPage and didnt bother to clean it, why fix it if it works? smile

As far as "upload a different song every day"....I know I have been doing that all along, I was thinking I could set it up to change it by itself..

Thank you,

Felix
Posted By: 1QuickSI Re: music changer - 12/30/2004 7:39 PM
Try this...

Code
<SCRIPT LANGUAGE="Javascript"><!--
function sound() {
//Random Sounds
} ; s = new sound() ; n = 0

// - Sound Database -
s[n++]= "Some.wav"
s[n++]= "OrSome.mid"
s[n++]= "Another.wav"
s[n++]= "Again.mid"
s[n++]= "And.wav"
s[n++]= "sound.mid"

i=Math.floor(Math.random() * n) ;

if (navigator.appName.indexOf("Microsoft") != -1){
document.write('<BGSOUND SRC="'+ s[i] +'"> ')
}
else if (navigator.appName.indexOf("Netscape") != -1){
document.write('<EMBED SRC="'+ s[i] +'" HIDDEN=TRUE AUTOSTART=TRUE> ')
}
//--></SCRIPT>
Posted By: Felix 10 Re: music changer - 12/31/2004 3:59 AM
Thank you very much for trying. smile

in
Code
 // - Sound Database - 
what format should the .mid directory be written?

I tried:

I also tried this:

Code
<SCRIPT LANGUAGE="Javascript"><!--
function sound() {
//Random Sounds
} ; s = new sound() ; n = 0

src="http://www.romanianational.com/ubb/christmas/carols/"
s[n++]= "betleem.mid"
s[n++]= "cvapstori.mid"
etc
etc..
none of them work frown

Felix
Posted By: 1QuickSI Re: music changer - 12/31/2004 11:04 PM
The line:

// - Sound Database -

Is just a remark line and is not intended to imply the need to chnage it.

Just enter the file names in between the quotes on these lines.

s[n++]= "Some.wav"
s[n++]= "OrSome.mid"
s[n++]= "Another.wav"
s[n++]= "Again.mid"
s[n++]= "And.wav"
s[n++]= "sound.mid"

The actual file(s) should reside in the same directory as the file the script is being called from. Although untested you might be able to place the path there as well allowing you to keep the files in their own directory.
Posted By: Felix 10 Re: music changer - 01/01/2005 8:46 PM
I understand. I've already done that. But it still doesnt work. I am not sure which is the directory though, I added this code in the header of the (seasonal) Christmas Style template, therefore I loaded these .mid files in the Templates folder
(
http://romanianational.com/public_html/ubb/Templates/)
Is that correct?

Thank you Steven
Posted By: LK Re: music changer - 01/01/2005 11:19 PM
I think you have to put the files in both the /cgi-bin (ultimatebb.cgi, for non-topic pages) and /ubb (ultimatebb.php, and also for topic loaded with ultimatebb.cgi) directories.

Note that Steven gave you the code to make it random, not according to the day.
Posted By: Felix 10 Re: music changer - 01/02/2005 9:17 AM
I already tried LK.
I wasnt sure where they're needed and I uploaded them in 3 directories, /ubb, /Templates and /cgi-bin. No music to my ears... frown

Thank you.
Posted By: 1QuickSI Re: music changer - 01/04/2005 8:29 PM
Sorry I miss read the inital post on wanting it based on the day of week frown Try this...

Change each document.write line's src= portion for the different songs you wish to play and their location. Also if you want the audio file to play "loop" change to true.

Code
<body>

<script language="JavaScript" type="text/javascript">

s_date = new Date();

if(s_date.getDay() == 1){
document.write('<embed width=0 height=0 hidden="true" autostart="true" volume="5" loop="false" src="AudioFile1.mp3">');
}

if(s_date.getDay() == 2){
document.write('<embed width=0 height=0 hidden="true" autostart="true" volume="5" loop="false" src="AudioFile2.mp3">');
}

if(s_date.getDay() == 3){
document.write('<embed width=0 height=0 hidden="true" autostart="true" volume="5" loop="false" src="AudioFile3.mp3">');
}

if(s_date.getDay() == 4){
document.write('<embed width=0 height=0 hidden="true" autostart="true" volume="5" loop="false" src="AudioFile4.mp3">');
}

if(s_date.getDay() == 5){
document.write('<embed width=0 height=0 hidden="true" autostart="true" volume="5" loop="false" src="AudioFile5.mp3">');
}

if(s_date.getDay() == 6){
document.write('<embed width=0 height=0 hidden="true" autostart="true" volume="5" loop="false" src="AudioFile6.mp3">');
}

if(s_date.getDay() == 7){
document.write('<embed width=0 height=0 hidden="true" autostart="true" volume="5" loop="false" src="AudioFile7.mp3">');
}

if(s_date.getDay() == 0){
document.write('<embed width=0 height=0 hidden="true" autostart="true" volume="5" loop="false" src="AudioFile0.mp3">');
}
</script>
Posted By: Felix 10 Re: music changer - 01/05/2005 8:51 AM
Steven, it doesnt matter if they work randomly or by day, as long as they work smile

Right now they dont because I dont know what directory I should load the into. Is it the:

/ubb/
/cgi-bin/
/Templates/ ?

or all?

thank you very much for your effort.

Felix
Posted By: 1QuickSI Re: music changer - 01/05/2005 7:08 PM
Are you trying to implement this site wide to your UBB system or jsut a single webpage?
Posted By: Felix 10 Re: music changer - 01/05/2005 11:04 PM
Just the UBB. http://romanianational.com/cgi-bin/ultimatebb.cgi
And just the Summary page will suffice.

Funny think is that it did work a little, and trully "random" indeed, only on the Topic page and on the PM page, can't figure that out because I uploaded (4 songs, true) in each of the above directories.

smile
© UBB.Developers