-
I've been browsing through all flash related webpages looking for a tutorial on how to import or play a midi file in Flash, but still couldn't find it ! can anyone help ? since mp3 and wav file is pretty slowing down the movie. Midi isn't such a bad alternative right ?
-
To my knowledge, Flash won't import MIDI files.
I've seen some script programming that enables a MIDI file to played along with the Flash movie though.
I'll check for the link that gives that. :)
-
This is some Javascript that has been posted in the past to control Midi files within Flash. I don't know if you want to go through this much trouble, but here it is. :)
The first step is to create a flash movie with the following links under the GETURL: command.
to stop: Javascript: stopmusic ()
to start: Javascript: startmusic ()
Next, place the ENTIRE section below into your html document.
PASTE THIS:
<head>
<title>Midi In Flash</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script language="JavaScript">
<!-- function MM_controlSound(sndAction,_sndObj) { //v2.0 var sndObj = eval( _sndObj );
if (sndObj != null) {
if (sndAction=='stop') { sndObj.stop(); } else {
if (navigator.appName == 'Netscape' ) { sndObj.play(); }
else {
if (document.MM_WMP_DETECTED == null) { document.MM_WMP_DETECTED = false; var i; for( i in sndObj )
if ( i == "ActiveMovie" ) { document.MM_WMP_DETECTED = true; break; } }
if (document.MM_WMP_DETECTED) sndObj.play();
else
if ( sndObj.FileName ) sndObj.run(); }}}} //-->
</script>
</head>
<script language="JavaScript">
function startmusic(){
MM_controlSound('play','document.CS930346114680',' yourmidifile.mid') }
</script>
<script language="JavaScript">
function stopmusic(){
MM_controlSound('stop','document.CS930346114680',' yourmidifile.mid') }
</script>
<body bgcolor="#FFFFFF"> <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#3,0,0,0"
width="91" height="67"> <param name="SRC"
value="yourswffile.swf"> <embed src="yourswffile.swf"
pluginspage="http://www.macromedia.com/shockwave/download/" type="application/x-shockwave-flash" width="91" height="67"> </embed> </object>
<EMBED NAME='CS930346114680' SRC='yourmidifile.mid' LOOP=true AUTOSTART=false MASTERSOUND HIDDEN=true WIDTH=0 HEIGHT=0> </EMBED>
</body>
</html>
-
you can also convert mid's to wav's
http://www.midi2wav.com
-
Thanks for your replies
Thanks Mike-Edwards for your hard-work, but is it possible to load somewhat the midi files directly from the harddisk or server instead of embedding the files to flash or webpages ? i tried loading it with loadMovie(), but it's fruitless :(
I've actually thought of converting the file to wav but still it surely slows down my movie a lot .
-
umm no
the mid file needs to be on the server.
there's an easier code for html
here's the embed tag
<OBJECT ID="MediaPlayer1" width=0 height=0
classid="CLSID:22D6F312-B0F6-11D0-94AB-0080C74C7E95"
codebase=
"http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=6,0,02,0902"
standby="Loading Microsoft® Windows® Media Player components..."
type="application/x-oleobject">
<PARAM NAME="FileName" VALUE="yourfile.mid">
<PARAM NAME="AutoStart" VALUE="False">
</OBJECT>
Then use
javascript
document.MediaPlayer1.Play()
-
Read the MIDI entry in the Sound Forum FAQ on using MIDI with flash. (see sig for link).