Forum Moderators: open
I can do it with a midi files but not the wav file.
This works:
<HTML><HEAD>
</HEAD>
<BODY>
<SCRIPT LANGUAGE="JavaScript">
sstatus=0;
function togglemusic()
{
if (sstatus==1)
{
sstatus=0;
document.music.play();
}
else
{
sstatus=1;
document.music.stop();
}
}
setInterval("togglemusic()", 10000);
</SCRIPT>
<embed name="music" SRC="pinball.mid"
loop=true autostart=false hidden=true mastersound volume="50">
</BODY>
</HTML>
but this doesn't:
<HTML><HEAD>
</HEAD>
<BODY>
<SCRIPT LANGUAGE="JavaScript">
sstatus=0;
function togglemusic()
{
if (sstatus==1)
{
sstatus=0;
document.music.play();
}
else
{
sstatus=1;
document.music.stop();
}
}
setInterval("togglemusic()", 10000);
</SCRIPT>
<embed name="music" SRC="guadalajara.wav"
loop=true autostart=false hidden=true mastersound volume="50">
</BODY>
</HTML>
Does anybody know why? This should have been a 10 minute task and I've been on it for 4 days.
Thanks for replying.
The plugin does work because I can play it with autostart=true. The problem is with the play() and stop() functions which work for the midi file but not for the wave.
I'm a bit of a novice regarding plugins. I don't really understand which plugin the browser is trying to use, I don't know to check if it supports play() and stop() and I don't know how to change the plugin to another.
Can you help?
I don't really understand which plugin the browser is trying to use
nevertheless, if a file type is well known (like wav), there might be lot's of different plugins and that's bad news for you, because you don't know which one the user of your site installed. and this answers your second question: you just can not now.
one solution with the wav playing might be a flash movie with enabled fs_commands. you can 'remote control' the movie via javascript (java has to be enabled, too) and then you can start and stop the sound. you now a bit about flash?
<object id="music" width="1" height="1"
classid="CLSID:22D6f312-B0F6-11D0-94AB-0080C74C7E95"
standby="Loading Windows Media Player components..."
type="application/x-wav">
<param name="FileName" value="guadalajara.wav"></param>
<param name="AutoStart" value="False"></param>
<param name="Hidden" value="True"></param>
</object>
It responds to both the play() and stop() commands.
Is this a good way to do it? Presumably this will only work on Windows. Are there any other time-bombs here?
Isn't Flash just another plugin? How do I check that all my users have the correct version installed?
There's an attribute called "codebase" you can use in the Flash object tag that dictates the version of Flash required. If someone doesn't have a recent enough version they automatically get a notice to upgrade.
But you wouldn't even have to worry about using that attribute - you're using basic functions and any version of Flash should work - 97% penetration I'd say, and it will work on Macintosh.