Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4

Thread: midi won't play

  1. #1
    New to the CF scene
    Join Date
    Dec 2006
    Location
    phoenix, az
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question midi won't play

    code from page: http://www.alwaysalady.net/gwain/gwain.html

    I know there is something very simple I'm missing, *sigh*, and I'm tired of looking soooo...I'm "going to the experts".

    So will some wonderful, kind and knowledgable person (flattery always helps), help me out, pretty, pretty please???

    <script>
    var musicsrc="../midis/fantasy.mid"
    if (navigator.appName=="Microsoft Internet Explorer")
    document.write('<bgsound src='+'"'+musicsrc+'"'+' loop="infinite">')
    else
    document.write('<embed src=\"'+musicsrc+'\" hidden="true" border="0" width="20" height="20" autostart="true" loop="true">')
    </script>

  • #2
    Banned
    Join Date
    May 2006
    Location
    England
    Posts
    664
    Thanks
    0
    Thanked 84 Times in 84 Posts
    Quote Originally Posted by alwaysalady View Post
    It does play - you must have a browser/plugin/hardware issue.

    Here's a recommended enhancement:
    Code:
    <SCRIPT type='text/javascript'>
    var musicsrc="../midis/fantasy.mid"
    
    if (navigator.appName=="Microsoft Internet Explorer" && typeof window.pageXOffset=='undefined')
     document.write('<bgsound id="muz" src='+'"'+musicsrc+'"'+' loop="infinite">')
    else 
     document.write('<embed id="muz"src=\"'+musicsrc+'\" hidden="true" border="0" width="20" height="20" autostart="true" loop="true">');
     
    var embedObj=document.getElementById?document.getElementById('muz'):document.all?document.all('muz'):null;
     
    if(embedObj && document.body.removeChild)  
     document.write("<A HREF='#' onclick='document.body.removeChild(embedObj);return false'><B>KILL MUSIC STONE DEAD<\/B><\/A>");
    </SCRIPT>

  • #3
    Senior Coder Arbitrator's Avatar
    Join Date
    Mar 2006
    Location
    Splendora, Texas, United States of America
    Posts
    3,372
    Thanks
    32
    Thanked 286 Times in 280 Posts
    You don’t need JavaScript for this. You may as well use the correct method of calling a MIDI file for standard‐compliant browsers as well. The below code was tested in Firefox 2, Internet Explorer 6/7, and Opera 9.

    Code:
    <!--[if IE]>
    <bgsound src="sound.mid" loop="infinite"/>
    <![endif]-->
    <object width="0" height="0" type="audio/midi" data="sound.mid">
      <param name="loop" value="true"/>
    </object>
    The above code will leave a dot in Internet Explorer. If you find it problematic, you can get rid of the dot by using another conditional comment to set the object element’s display property to none for that browser.
    For every complex problem, there is an answer that is clear, simple, and wrong.

  • #4
    New to the CF scene
    Join Date
    Dec 2006
    Location
    phoenix, az
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Thumbs up midi doesn't work

    don't know why, but the original code works now.....go figure!!

    Thanks guys soooo much for your help, you're AWESOME!!!!


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •