Certainly, script can manage everything both with pictures, and with music. For example, there is demo code where background varies each 3 seconds.
But music has such feature, that it works not on all computers and not in all browsers. There can even be error messages which will prevent to look content. There are many ways to start music, but they differ even what player is established - MS mediaplayer or Apple QuickTime or other.
I tried to start in different browsers such code:
Code:
<embed id=snd src=your_media_file.mp3 autostart=false height=42 loop=true controller=true hid den=true></embed><br>
<input type=button onClick=d.getElementById("snd").Play(); value=Play>
<input type=button onClick=d.getElementById("snd").Stop(); value=Stop>
<input type=button onClick=d.getElementById("snd").Rewind(); value=Rewind)>
If it will work from the button with the help of the code specified in tag of the button, it is possible to start one or other melody (from other embed tag). They may be invisible if write "hidden=true". (But will play in IE only.)
Here is script with optimization - it won't be preload all images, but only one according to time of day:
Code:
<script>D=new Date().getHours();
A=new Image();
onload=function(){
if(D>=6&&D<12){A.src='snow1.gif';document.body.background=A.src;} //bg 6-12AM
if(D>=12&&D<20){A.src='snow2.gif';document.body.background=A.src;} //bg from 12AM to 8PM
if(D>=20||D<6){A.src='snow3.gif';document.body.background=A.src;} //bg from 8PM to 6AM
if(D<6||D>=20)setTimeout('document.getElementById("snd2").Play();',1999); //snd 20-6
if(D>=6&&D<20)setTimeout('document.getElementById("snd1").Play();',1999); //snd 6-20; timeshift needed for opening of plugin
}
</script>
<body><embed id=snd1 src=snd1.mp3 autostart=false height=1 width=1 loop=true controller=false></embed>
<embed id=snd2 src=snd2.wav autostart=false height=1 width=1 loop=true controller=false></embed>
<input type=button onClick=document.getElementById("snd1").Stop();document.getElementById("snd2").Stop(); value=Stop_Music>
(I cannot speak reliably without the checked up example, therefore it's present
)
Bookmarks