Midi tags

I been doing many Google searches in an attempt to find a definite answer as to the correct HTML tags to use for midi that will be compatible for most of the current set of browsers.

From what I've read, <bgsound> is pretty much obsolete now and <embed src> appears to be recommended over the official <object> tag.

However, I've read conflicting information and some of it is undated, so I don't know which stuff to believe.

I realise that it's impossible to cater for all browsers, but so long as I can cater for around 90% of users, I'll be happy.
LVL 48
TintinAsked:
Who is Participating?
 
davidlars99Connect With a Mentor Commented:
if flash is not an option than you're stuck with <object> and <embed> tags, well with flash you'd use same combination, but you point "pluginspage" attribute to macromedia's website, which is 95% of browsers have flash support, without flash you have to do various plugin detections in javascript according to what type audio/video file you are reffering to, here is the complete decection script of most popular plugins



<html>
<body>
<code>
<pre>
// Copyright © 2000 by Apple Computer, Inc., All Rights Reserved.
//
// You may incorporate this Apple sample code into your own code
// without restriction. This Apple sample code has been provided "AS IS"
// and the responsibility for its operation is yours. You may redistribute
// this code, but you are not permitted to redistribute it as
// "Apple sample code" after having made changes.
&#60;script language="JavaScript"&#62;
&#60;!--
// initialize a variable to test for JavaScript 1.1.
// which is necessary for the window.location.replace method
var javascriptVersion1_1 = false;
// --&#62;
&#60;/script&#62;


&#60;script language="JavaScript1.1"&#62;
&#60;!--
javascriptVersion1_1 = true;
// --&#62;
&#60;/script&#62;


&#60;script language="JavaScript"&#62;
&#60;!--

// initialize global variables
var detectableWithVB = false;
var pluginFound = false;


function goURL(daURL) {
    // if the browser can do it, use replace to preserve back button
    if(javascriptVersion1_1) {
      window.location.replace(daURL);
    } else {
      window.location = daURL;
    }
    return;
}

function redirectCheck(pluginFound, redirectURL, redirectIfFound) {
    // check for redirection
    if( redirectURL && ((pluginFound && redirectIfFound) ||
      (!pluginFound && !redirectIfFound)) ) {
      // go away
      goURL(redirectURL);
      return pluginFound;
    } else {
      // stay here and return result of plugin detection
      return pluginFound;
    }      
}

function canDetectPlugins() {
    if( detectableWithVB || (navigator.plugins && navigator.plugins.length &#62; 0) ) {
      return true;
    } else {
      return false;
    }
}

function detectFlash(redirectURL, redirectIfFound) {
    pluginFound = detectPlugin('Shockwave','Flash');
    // if not found, try to detect with VisualBasic
    if(!pluginFound && detectableWithVB) {
      pluginFound = detectActiveXControl('ShockwaveFlash.ShockwaveFlash.1');
    }
    // check for redirection
    return redirectCheck(pluginFound, redirectURL, redirectIfFound);
}

function detectDirector(redirectURL, redirectIfFound) {
    pluginFound = detectPlugin('Shockwave','Director');
    // if not found, try to detect with VisualBasic
    if(!pluginFound && detectableWithVB) {
      pluginFound = detectActiveXControl('SWCtl.SWCtl.1');
    }
    // check for redirection
    return redirectCheck(pluginFound, redirectURL, redirectIfFound);
}

function detectQuickTime(redirectURL, redirectIfFound) {
    pluginFound = detectPlugin('QuickTime');
    // if not found, try to detect with VisualBasic
    if(!pluginFound && detectableWithVB) {
      pluginFound = detectQuickTimeActiveXControl();
    }
    return redirectCheck(pluginFound, redirectURL, redirectIfFound);
}

function detectReal(redirectURL, redirectIfFound) {
    pluginFound = detectPlugin('RealPlayer');
    // if not found, try to detect with VisualBasic
    if(!pluginFound && detectableWithVB) {
      pluginFound = (detectActiveXControl('rmocx.RealPlayer G2 Control') ||
                   detectActiveXControl('RealPlayer.RealPlayer(tm) ActiveX Control (32-bit)') ||
                   detectActiveXControl('RealVideo.RealVideo(tm) ActiveX Control (32-bit)'));
    }      
    return redirectCheck(pluginFound, redirectURL, redirectIfFound);
}

function detectWindowsMedia(redirectURL, redirectIfFound) {
    pluginFound = detectPlugin('Windows Media Player');
    // if not found, try to detect with VisualBasic
    if(!pluginFound && detectableWithVB) {
      pluginFound = detectActiveXControl('MediaPlayer.MediaPlayer.1');
    }
    return redirectCheck(pluginFound, redirectURL, redirectIfFound);
}

function detectPlugin() {
    // allow for multiple checks in a single pass
    var daPlugins = detectPlugin.arguments;
    // consider pluginFound to be false until proven true
    var pluginFound = false;
    // if plugins array is there and not fake
    if (navigator.plugins && navigator.plugins.length &#62; 0) {
      var pluginsArrayLength = navigator.plugins.length;
      // for each plugin...
      for (pluginsArrayCounter=0; pluginsArrayCounter &#60; pluginsArrayLength; pluginsArrayCounter++ ) {
          // loop through all desired names and check each against the current plugin name
          var numFound = 0;
          for(namesCounter=0; namesCounter &#60; daPlugins.length; namesCounter++) {
            // if desired plugin name is found in either plugin name or description
            if( (navigator.plugins[pluginsArrayCounter].name.indexOf(daPlugins[namesCounter]) &#62;= 0) ||
                (navigator.plugins[pluginsArrayCounter].description.indexOf(daPlugins[namesCounter]) &#62;= 0) ) {
                // this name was found
                numFound++;
            }  
          }
          // now that we have checked all the required names against this one plugin,
          // if the number we found matches the total number provided then we were successful
          if(numFound == daPlugins.length) {
            pluginFound = true;
            // if we've found the plugin, we can stop looking through at the rest of the plugins
            break;
          }
      }
    }
    return pluginFound;
} // detectPlugin


// Here we write out the VBScript block for MSIE Windows
if ((navigator.userAgent.indexOf('MSIE') != -1) && (navigator.userAgent.indexOf('Win') != -1)) {
    document.writeln('&#60;script language="VBscript"&#62;');

    document.writeln('\'do a one-time test for a version of VBScript that can handle this code');
    document.writeln('detectableWithVB = False');
    document.writeln('If ScriptEngineMajorVersion &#62;= 2 then');
    document.writeln('  detectableWithVB = True');
    document.writeln('End If');

    document.writeln('\'this next function will detect most plugins');
    document.writeln('Function detectActiveXControl(activeXControlName)');
    document.writeln('  on error resume next');
    document.writeln('  detectActiveXControl = False');
    document.writeln('  If detectableWithVB Then');
    document.writeln('     detectActiveXControl = IsObject(CreateObject(activeXControlName))');
    document.writeln('  End If');
    document.writeln('End Function');

    document.writeln('\'and the following function handles QuickTime');
    document.writeln('Function detectQuickTimeActiveXControl()');
    document.writeln('  on error resume next');
    document.writeln('  detectQuickTimeActiveXControl = False');
    document.writeln('  If detectableWithVB Then');
    document.writeln('    detectQuickTimeActiveXControl = False');
    document.writeln('    hasQuickTimeChecker = false');
    document.writeln('    Set hasQuickTimeChecker = CreateObject("QuickTimeCheckObject.QuickTimeCheck.1")');
    document.writeln('    If IsObject(hasQuickTimeChecker) Then');
    document.writeln('      If hasQuickTimeChecker.IsQuickTimeAvailable(0) Then ');
    document.writeln('        detectQuickTimeActiveXControl = True');
    document.writeln('      End If');
    document.writeln('    End If');
    document.writeln('  End If');
    document.writeln('End Function');

    document.writeln('&#60;/scr' + 'ipt&#62;');
}
// --&#62;
&#60;/script&#62;

</pre>
</code>
</body>
</html>
0
 
nurbekCommented:
check here
bgsound is not supported by netscape

http://www.javascripter.net/faq/sound/play.htm
0
 
cristy56Commented:
There can be a conflict between the tags needed for background music with Netscape and Internet Explorer browsers. To make your music accessible to more people, it is wise to include both Netscape and I.E tags.

 Netscape supports <embed> tags.
 I.E supports <bgsound> tags.

And I suggest you write some Javascript to check which browser the user is using, and then for each type of browser, u can code with different tag so that the majority user can hear the midi.

Regards,
Cristy
0
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

 
TintinAuthor Commented:
I've read that newer versions of IE use the embed tags for midi and lost compatibility with the <bgsound> tag.

Or course, neither <bgcound> or <embed> tags are part of any of the HTML specs,  but the official <object> tag is supposed to be inflexible and not correctly supported by a lot of browsers.

0
 
cristy56Commented:
If u don't want any Javascript fro browser checking, u can just simply write the following code(all of them on the same homepage) :-

<embed src="filename.mid">
<noembed>
<bgsound src="filename.mid">
</noembed>

then IE will recognize bgsound and Netscape wll recognize embed and your midi file will be guaranteed to wrok under both.

Cheers,
Cristy
0
 
cristy56Commented:
Well, the newest version of IE supports embed but u've no idea which version of IE most users are using, so for safety sake, it is better to write both, anyway, the browser would only run the sound file once.

Cristy
0
 
cristy56Commented:
0
 
TintinAuthor Commented:
cristy56.

That's the combination of tags I'm currently using, but that breaks with the latest version of IE.

See http://midistudio.com/Help/Help_HomePg.htm (which is the most useful page I've found so far).
0
 
davidlars99Commented:
any updates from asker..?
0
 
TintinAuthor Commented:
Haven't really got any definitiive answers here, but I'll close this anyway.
0
All Courses

From novice to tech pro — start learning today.