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 8 of 8
  1. #1
    New Coder
    Join Date
    Feb 2005
    Posts
    32
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question Playing a Midi in Netscape

    Hey guys, here's what my script looks like. It works fine in IE but it doesn't work at all in FF.

    Code:
    ns = ((navigator.appName == "Netscape"));
    ie = ((navigator.appName == "Microsoft Internet Explorer"));
    
    if(playerType == 1 && ns){ playMIDI = '<EMBED SRC= "' + midi + '" WIDTH=200 HEIGHT=55 AUTOSTART=TRUE></EMBED><BR>';}
    else { playMIDI = '<EMBED SRC= "' + midi + '" loop=TRUE AUTOSTART=TRUE></BGSOUND>';}
    
    document.write(playMIDI);
    What's wrong?

  • #2
    Regular Coder
    Join Date
    Oct 2005
    Location
    Arizona
    Posts
    336
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I would be surprise if FF return an application name of Netscape. I have also read on this forum and elsewhere that you should test for browser features and not browser names. I don't know the exact answer to your question. But I may try doing a little research and see if I can come up with one. You might want to do a little research on the embed tag and see how the different browsers handle this feature.

  • #3
    New Coder
    Join Date
    Feb 2005
    Posts
    32
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I can;t really find any info on the subject that actually works in FF but I did find something that checks the function only this doesnt work now. What's wrong with this part?

    Code:
    ns = ((navigator.appName == "Netscape" && navigator.plugins["LiveAudio"]));
    ie = ((navigator.appName == "Microsoft Internet Explorer"));
    
    audioenabled = ie || ns;
    if (!audioEnabled)
    alert("Your browser cannot play sound files.");
    
    if(playerType == 1 && ns){ playMIDI = '<EMBED SRC= "' + midi + '" WIDTH=200 HEIGHT=55 AUTOSTART=TRUE LOOP=TRUE></EMBED><BR>';}
    else { playMIDI = '<EMBED SRC= "' + midi + '" loop=TRUE AUTOSTART=TRUE></BGSOUND>';}

  • #4
    Supreme Master coder! _Aerospace_Eng_'s Avatar
    Join Date
    Dec 2004
    Location
    In a place far, far away...
    Posts
    19,291
    Thanks
    2
    Thanked 1,043 Times in 1,019 Posts
    Firefox doesn't have that plugin. It requires quicktime to play midis. Try this
    Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <title>Untitled Document</title>
    <style type="text/css">
    body {
    margin:0;
    padding:0;
    text-align:center;
    }
    </style>
    <script type="text/javascript">
    var detect = navigator.userAgent.toLowerCase();
    var OS,browser,thestring;
    var themidi="yourmidi.mid";
    function checkIt(string)
    {
    	place = detect.indexOf(string) + 1;
    	thestring = string;
    	return place;
    }
    </script>
    </head>
    
    <body>
    <div id="music">
    <script type="text/javascript">
    if (checkIt('msie')&&checkIt('windows')){
    document.getElementById('music').innerHTML='<object width="200" height="45" '
          +'classid="CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6" '
          +'codebase="http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701"'
          +'standby="Loading Microsoft Windows Media Player components..." type="application/x-oleobject">'
          +'<param name="url" value="'+themidi+'">'
          +'<param name="uiMode" value="full">'
          +'<param name="autoStart" value="true">'
          +'<param name="loop" value="true">'
    	  +'<\/object>';
    }
    else {
    document.getElementById('music').innerHTML='<embed src="'+themidi+'" style="width:200px;height:55px;" showcontrols="true" autostart="true"></embed>';
    }
    </script>
    </div>
    </body>
    </html>
    The above checks to see if the browser is IE and the OS is Windows. It then feeds it the WMP code, and for any other browser it will give them the embed code and let the browser decide what plugins to use.
    Last edited by _Aerospace_Eng_; 12-24-2005 at 09:43 PM.

  • #5
    New Coder
    Join Date
    Feb 2005
    Posts
    32
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Ok, I'm still having a few problems so I'm going to post the entire code. It works fine in IE still but I don't even get one of those jigsaw puzzle things for mozilla where I did in your exact code. The reason it might not be working is because I'm trying to make a midi playlist. Here's what I got...

    Code:
    <%@ LANGUAGE="VBSCRIPT" %>
    <%
    Option Explicit
    Dim sql,username,rscurrent,rsUser,rsmusic,rstheme,music,user,theme,song1,song2,song3,song4,song5,song6,song7,song8,song9,song10,track1,track2,track3,track4,track5,track6,track7,track8,track9,track10,title,titlelist
    
    username = Request.Cookies("username")
    %>
    
    <!--#include file="conn.asp"-->
    
    <%
    sql = "SELECT * FROM theme WHERE username = '" & username & "'"
      Set rstheme = Server.CreateObject("ADODB.Recordset")
      rstheme.Open sql, conn, 3, 3
    
    sql = "SELECT * FROM music WHERE username = '" & username & "'"
      Set rsmusic = Server.CreateObject("ADODB.Recordset")
      rsmusic.Open sql, conn, 3, 3
    
    sql = "SELECT * FROM Users WHERE username = '" & username & "'"
      Set rsUser = Server.CreateObject("ADODB.Recordset")
      rsUser.Open sql, conn, 3, 3
    
    sql = "SELECT * FROM users"
    Set rscurrent = Server.CreateObject("ADODB.Recordset")
    rscurrent.Open sql, conn, 3, 3
    %>
    
    
    <html>
    <head>
    <title>XT Midiplayer version 3.0</title>
    
    <style type="text/css">
    a:link {text-decoration: none; color: #999999}
    a:visited {text-decoration: none; color: #999999}
    a:hover {text-decoration: none; color: #ffffff;}
    </style>
    
    <script type="text/javascript">
    var detect = navigator.userAgent.toLowerCase();
    var OS,browser,thestring;
    function checkIt(string)
    {
    	place = detect.indexOf(string) + 1;
    	thestring = string;
    	return place;
    }
    </script>
    </head>
    <body bgcolor="black" text="#999999" hover="#ffffff" link="#999999" vlink="#999999" height="300" scrollbars="0">
    <div id="music">
    <SCRIPT type="text/javascript">
    midiList = new Array("","<%=rsmusic("song1")%>","<%=rsmusic("song2")%>","<%=rsmusic("song3")%>","<%=rsmusic("song4")%>","<%=rsmusic("song5")%>","<%=rsmusic("song6")%>","<%=rsmusic("song7")%>","<%=rsmusic("song8")%>","<%=rsmusic("song9")%>","<%=rsmusic("song10")%>");
    titleList = new Array("","<%=rsmusic("track1")%>","<%=rsmusic("track2")%>","<%=rsmusic("track3")%>","<%=rsmusic("track4")%>","<%=rsmusic("track5")%>","<%=rsmusic("track6")%>","<%=rsmusic("track7")%>","<%=rsmusic("track8")%>","<%=rsmusic("track9")%>","<%=rsmusic("track10")%>");
    
    playerType=1; 
    checkBold=1; 	 
    checkItalic=1;  
    checkUnder=0;  	
    fontColor='#F4692C'; 	
    fontFace='Verdana';  
    fontSize='-6'; 
    
    howMany = midiList.length-1;
    date = new Date();
    seed = date.getTime();
    randomNumber = parseInt(((seed - (parseInt(seed/1000,10) * 1000))/10)/100*howMany
    + 1,10);
    
    URL = location.href;
    QUERY_POS = URL.indexOf("?") + 1;
    QUERY_STRING = URL.substring(QUERY_POS); 
    QUERY_POS-=1;
    QUERY_POS2=QUERY_POS;
    QUERY_POS2+=1;
    if(QUERY_POS!=0) newLocation=URL.substring(0,QUERY_POS);
    if(QUERY_POS2==0) newLocation=QUERY_STRING;
    if(QUERY_STRING > 0) randomNumber=QUERY_STRING;
    
    midi=midiList[randomNumber];
    title=titleList[randomNumber];
    
    if(!title){ 
    midi=midiList[1];
    title=titleList[1];
    randomNumber=1;
    }
    
    window.defaultStatus="Now Playing... Track "+randomNumber+": "+title;
    
    if (checkIt('msie')&&checkIt('windows')){
    document.getElementById('music').innerHTML='<object width="200" height="45" '
          +'classid="CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6" '
          +'codebase="http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701"'
          +'standby="Loading Microsoft Windows Media Player components..." type="application/x-oleobject">'
          +'<param name="url" value="'+midi+'">'
          +'<param name="uiMode" value="full">'
          +'<param name="autoStart" value="true">'
          +'<param name="loop" value="true">'
    	  +'<\/object>';
    }
    else {
    document.getElementById('music').innerHTML='<embed src="'+midi+'" style="width:200px;height:55px;" showcontrols="true" autostart="true"></embed>';
    }
    
    bold=(checkBold==1)?"<B>":"";
    bold2=(checkBold==1)?"</B>":"";
    italic=(checkItalic==1)?"<I>":"";
    italic2=(checkItalic==1)?"</I>":"";
    under=(checkUnder==1)?"<U>":"";
    under2=(checkUnder==1)?"</U>":"";
    
    function listMIDI(){
    for(x=0;x<=howMany;x++){
    if(x==0)document.write("<br><B>Albums in Jukebox</B><BR>");
    if(x!=0 && x!=randomNumber)document.write("<font face="+fontFace+" size="+fontSize+"> <A HREF="+newLocation+"?"+x+">"+x+" - "+titleList[x]+"</A></font><BR>");
    if(x==randomNumber)document.write("<font color=\""+fontColor+"\" face="+fontFace+" size="+fontSize+">"+bold+""+italic+""+under+""+x+" - "+titleList[x]+""+under2+""+italic2+""+bold2+" - Now Playing...</font><BR>");
    }
    }
    </SCRIPT>
    </div>
    <SCRIPT type="text/javascript">
    
    	listMIDI();
    
    </SCRIPT>
    
    <b><a href="midiplayerv3.asp">Random Song</a></b><br>
    <font size="-2"><b><a href="music.asp">Edit Playlist</a></b></font>
    
    
    </body></html>

  • #6
    New Coder
    Join Date
    Feb 2005
    Posts
    32
    Thanks
    0
    Thanked 0 Times in 0 Posts
    anyone have any ideas?

  • #7
    New Coder
    Join Date
    Feb 2005
    Posts
    32
    Thanks
    0
    Thanked 0 Times in 0 Posts
    bump!

  • #8
    Supreme Master coder! _Aerospace_Eng_'s Avatar
    Join Date
    Dec 2004
    Location
    In a place far, far away...
    Posts
    19,291
    Thanks
    2
    Thanked 1,043 Times in 1,019 Posts
    Quit bumping, its not going to get your question answered faster. Read this post. Embedded Windows Media Player
    ||||If you are getting paid to do a job, don't ask for help on it!||||


  •  

    Posting Permissions

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