Media playback problem on web page
Hi there,
I want to embed midi music into a page, I wrote a simple script to randomly play a midi file each time the page is loaded, and I use the meta tag refresh the page after a delay, this is very basic but at least it works on Firefox, Konqueror and Chrome, but Opera does not play the sound.
================================================================================
<script type="text/javascript" language="javascript"
src="script/music.js"></script>
================================================================================
[Music script #1]
================================================================================
function rand(num)
{
return Math.floor(Math.random()*num)+1;
}
document.write("<embed src=audio/"+rand(31)+".mid"+" hidden=true autostart=true volume=100 loop=no>"+"</embed>");
================================================================================
The problem is, FF only play the music once, no sound after the refresh, but Konqueror and Chrome play after refresh. I then try another script.
[Music script #2]
================================================================================
function rand(num)
{
return Math.floor(Math.random()*num)+1
}
document.write('<object data="audio"+rand(17)+".mid" width="0" height="0" hidden="yes">');
document.write('<param name="controller" value="false">');
document.write('<param name="autoplay" value="yes">');
document.write('<param name="volume" value="100">');
document.write('</object>');
================================================================================
But the above script is not recognized by all browser, any idea ?
|