Back to Forums








View Full Version : Embedding MIDI Files in a web page


carloc
December 5th, 2005, 10:11 AM
What's the correct tag for embedding a MIDI song in a web page?

<bgsound src="http://www.myurl.com/sound.mid" loop=N">
(where N is the number of loops, -1 for an infinite loop)

or
<embed src="http://www.myurl.com/sound.mid">

Is this sintax HTML standard compliant or does it work only with IE?

And how can I turn the sound ON/OFF with a mouse click?

rohitk89
December 6th, 2005, 09:50 AM
I learnt from here (http://www.2kweb.net/html-tutorial/links/embed-mid/) that there is no major difference except that the <bgsound> tag should be included in the <background> tag.

The output will vary in each case though. The <bgsound> tag will cause the file to be played in the background whereas the <embed> tag will make the midi file appear as an object on the page- thereby enabling the user to turn on/turn off the music as he wishes.

More info here (http://www.w3schools.com/media/media_browsersounds.asp).

Reverend
December 6th, 2005, 23:05 PM
Continuous play:

<EMBED src="http://www.myurl.com/sound.mid" autostart=true loop=true volume=100 hidden=true><NOEMBED><BGSOUND src="http://www.myurl.com/sound.mid"></NOEMBED>

Play once:

<EMBED src="http://www.myurl.com/sound.mid" autostart=true loop=false volume=100 hidden=true><NOEMBED><BGSOUND src="http://www.myurl.com/sound.mid"></NOEMBED>

carloc
December 9th, 2005, 09:23 AM
Thank you guys!:)
Currently I'm testing this solution:
<SCRIPT TYPE="text/javascript">
<!--
var filename="Jingle bells.mid";
if (navigator.appName == "Microsoft Internet Explorer")
document.writeln ('<BGSOUND SRC="' + filename + '">');
else if (navigator.appName == "Netscape")
document.writeln ('<EMBED SRC="' + filename + '" AUTOSTART=TRUE WIDTH=150 HEIGHT=20>');
// -->
</SCRIPT>
<NOSCRIPT>
<BGSOUND SRC="Jingle bells.mid">
</NOSCRIPT>