By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,190 Members | 783 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,190 IT Pros & Developers. It's quick & easy.

switching an Iframe media player with plugin decection

riptide2049
P: 2
I really have a problem here. I have a code that is suppost to take the href of a link from the right class;value of a link maked toreturn false. the value is a Media file the file is sent to quicktime or windows meida player depending on which plugin was found. after the plug in is found a iframe with the right player is created.


here is the code. for some reason In IE the plug in doesnt work and in fire fox it crashes

Expand|Select|Wrap|Line Numbers
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  5. <title>Untitled Document</title>
  6. <script language="javascript"  type="text/javascript">
  7.  
  8.  
  9. /*if you have windows media player*/
  10. function WMPFrame() { 
  11. var iframe = document.createElement("iframe"); 
  12. iframe.setAttribute("src", "WMPIframe.html"); 
  13. iframe.setAttribute("id", "playerframe"); 
  14. iframe.setAttribute("scrolling", "no"); 
  15. iframe.setAttribute("frameBorder", "0"); 
  16. iframe.setAttribute( "width", "200" );
  17. iframe.setAttribute( "height", "200" );
  18. document.getElementById('misterioProgram').appendChild(iframe); 
  19.  
  20. /*if you have quicktime*/
  21. function QUIFrame() { 
  22. var Frame = document.createElement("iframe"); 
  23. Frame.setAttribute("src", "QuicktimeIfram.html"); 
  24. Frame.setAttribute("id", "timeframe"); 
  25. Frame.setAttribute("scrolling", "no"); 
  26. Frame.setAttribute("frameBorder", "0"); 
  27. Frame.setAttribute( "width", "200" );
  28. Frame.setAttribute( "height", "200" );
  29. document.getElementById('misterioProgram').appendChild(Frame); 
  30.  
  31. /*if you have no plugins*/
  32.  
  33. function read(){
  34. var answer = confirm ("Please click on OK to continue loading my page, or CANCEL to be directed to the Yahoo site.")
  35. if (answer)
  36.  
  37. var MKDIV = document.createElement( 'div' );
  38. MKDIV.setAttribute('id','pluginsite');
  39. MKDIV.style.backgroundColor="#F0CCF0";
  40. MKDIV.style.border = '1px solid blue'; 
  41. MKDIV.style.left = '35%'
  42. MKDIV.style.top = '200px'
  43. MKDIV.style.width = '300px'
  44. MKDIV.style.heigh = '200px'
  45. MKDIV.style.font = '14px arial #FF6666'
  46. MKDIV.style.position='absolute' 
  47. document.getElementsByTagName( 'body' )[0].appendChild( MKDIV );
  48. MKDIV.appendChild(document.createTextNode("To download quick time \u00a0 "))
  49.  
  50. var lQT=document.createElement('a');
  51.  lQT.setAttribute('href','http://www.apple.com/qtactivex/qtplugin.cab' );
  52.  lQT.appendChild( document.createTextNode( 'QuickTime' ) );
  53.  MKDIV.appendChild(lQT); 
  54.  
  55.  MKDIV.appendChild(document.createTextNode("\u00a0 or go to windows media player's download page \u00a0"));
  56.  
  57.  var lWMP=document.createElement('a');
  58.  lWMP.setAttribute('href','http://www.microsoft.com/windows/windowsmedia/download/AllDownloads.aspx' );
  59.  lWMP.appendChild( document.createTextNode( 'WMP' ) );
  60.  MKDIV.appendChild(lWMP);
  61.  
  62.  window.setTimeout("stopdiv();", 12000)
  63. }
  64.  
  65. function stopdiv ( )
  66. {
  67. document.body.removeChild(document.getElementById('pluginsite'))
  68.  
  69. }
  70. /*end of no plugin and Iframes.*/
  71.  
  72.  
  73.  
  74.  
  75. /*start os detection script that I got from someone else*/
  76.  
  77. // create a multidimensional associative array to store our plugin names and datatypes
  78.  
  79. $plugin_type = {    
  80. 'SVG Viewer': {        
  81. 'ieAndWin': 'Adobe.SVGCtl',        
  82. 'nsOrMac': 'image/svg-xml'    },    
  83.  
  84. 'Shockwave Director': {        
  85. 'ieAndWin': 'SWCtl.SWCtl.1',        
  86. 'nsOrMac': 'application/x-director'    },    
  87.  
  88. 'Flash': {        
  89. 'ieAndWin': 'ShockwaveFlash.ShockwaveFlash.1',        
  90. 'nsOrMac': 'application/x-shockwave-flash'    },    
  91.  
  92. 'RealPlayer': {        
  93. 'ieAndWin': 'rmocx.RealPlayer G2 Control.1',        
  94. 'nsOrMac': 'audio/x-pn-realaudio-plugin'    },    
  95.  
  96. 'QuickTime': {        
  97. 'ieAndWin': 'QuickTimeCheckObject.QuickTimeCheck.1',        
  98. 'nsOrMac': 'video/quicktime'    },    
  99.  
  100. 'Windows Media Player': {        
  101. 'ieAndWin': 'MediaPlayer.MediaPlayer.1',        
  102. 'nsOrMac': 'application/x-mplayer2'    },    
  103.  
  104. 'Acrobat Reader': {        
  105. 'ieAndWin': 'PDF.PdfCtrl.5',        
  106. 'nsOrMac': 'application/pdf'    }}; function detectPlugin( $inPluginName ){    
  107. var agt = navigator.userAgent.toLowerCase();    
  108. var ie  = ( agt.indexOf('msie') != -1 );    
  109. var ns  = ( navigator.appName.indexOf('Netscape') != -1 );    
  110. var win = ( ( agt.indexOf('win') != -1 ) || ( agt.indexOf('32bit') != -1 ) );    
  111. var mac = ( agt.indexOf('mac') != -1 );     
  112.  
  113. $pluginEnabled = false;     
  114.  
  115. if( $inPluginName != 'Java' )    {       
  116.  
  117.       if( ie && win )        
  118.       {            $pluginEnabled = detectIE( $plugin_type[$inPluginName]['ieAndWin'] );        }         
  119.  
  120.       if( ns || !win )        {            nse = '';            
  121.  
  122.              for( var i = 0; i < navigator.mimeTypes.length; i++ )            
  123.              {                nse += navigator.mimeTypes[i].type.toLowerCase();            }             $pluginEnabled = detectNS( $plugin_type[$inPluginName]['nsOrMac'] );        }    }    
  124.  
  125.       else    {        $pluginEnabled = navigator.javaEnabled() ? true : false;    }    
  126.  
  127.  
  128.        return $pluginEnabled ;}  
  129.  
  130.  
  131.        function detectNS( ClassID ){    n = '';    
  132.        if( nse.indexOf( ClassID ) != -1 )    {        
  133.  
  134.        if( navigator.mimeTypes[ClassID].enabledPlugin != null )        {   return true;  }        
  135.  
  136.        else        {     return false;   }    }} 
  137.  
  138.  
  139.  
  140.        function detectIE( ClassID ){    result = false;     
  141.        // this line needs to be broken to prevent errors in internet explorer, hence the strangeness in the middle of</SC' + 'RIPT>    
  142. document.write( '<SCRIPT LANGUAGE=VBScript>\n on error resume next \n result = IsObject( CreateObject("' + ClassID + '") )</SC' + 'RIPT>' );    
  143.  if( result )    {        return true;    }    
  144.  
  145.  else    {        return false;    }} 
  146.  // ==========================================================
  147. //  this portion determines what to do
  148. // ==========================================================
  149.  if( detectPlugin( 'QuickTime' ) == true ){QUIFrame()}
  150.  
  151.  else if( detectPlugin( 'Windows Media Player' ) == true ){WMPFrame()}
  152.  
  153.  else{read()}
  154.  
  155. /*end of detection script*/
  156.  
  157. window.onload = function() {  var links = document.getElementsByTagName('a');  for (var i = 0; i < links.length; i++) {    if (links[i].className == 'movieloader') { /*find links with class="movieloader"      */
  158.  links[i].onclick = function(e) { /* attach function to each */       
  159.  if (window.event) window.event.returnValue = false;        else e.preventDefault();  /*stop browser from going to link href */       
  160. var mP = document.getElementById('misterioProgram');        mP.style.display = 'block';  if( detectPlugin( 'QuickTime' ) == true ){frames['timeframe'].document.getElementById('misterioProgram').getElementsByTagName('embed')[0].src = this.href;        
  161.  
  162.  frames['timeframe'].document.getElementById('misterioProgram').getElementsByTagName('param')[0].value = this.href; }
  163.  else if( detectPlugin( 'Windows Media Player' ) == true ){frames['playerframe'].document.getElementById('misterioProgram').getElementsByTagName('embed')[0].src = this.href;        
  164.  
  165. frames['playerframe'].document.getElementById('misterioProgram').getElementsByTagName('param')[0].value = this.href;   }     }    }  }}
  166.  
  167.  
  168.  
  169.  </script>
  170.  
  171.  
  172.  
  173.  
  174.  
  175. <style type="text/css">
  176. <!--
  177. #misterioProgram {
  178.     background-color: #666666;
  179.     display: none;
  180.     position: absolute;
  181.     z-index: 4;
  182.     height: 400px;
  183.     width: 400px;
  184.     left: 200px;
  185.     top: 200px;
  186. }
  187. -->
  188. </style>
  189. </head>
  190.  
  191. <body>
  192.  
  193.  
  194.  
  195. <a class="movieloader" href="http://www.fileden.com/files/2006/11/20/398972/lupe%20fiasco%20-%20kick%20push.mp3">clickhere </a>
  196.  
  197.  
  198.  
  199.  
  200.  
  201.  
  202. <div id="misterioProgram">
  203.  
  204.  
  205. <h1 id="vidh">the video page</h1> 
  206. <p id="vidp">it will take some time to load</p>
  207. <div id="MTVplayer">
  208.  
  209. </div>
  210.  
  211.  
  212. <!--the big div-->
  213. <div id="ChooseSeason" align="left" > 
  214. <!--the div of the navi-->
  215.    <div id="Mtt1" class="theSeasons">
  216.       <!--the div for teen titans season one Mtt one-->    
  217.       <ul> 
  218.          <li> Teen Titans Season 3   </li>   
  219.  
  220.                 <a href="http://www.fileden.com/files/2006/11/20/398972/Seal%20-%20Kiss%20From%20A%20Rose.mp3" onclick="misterio(); return false;">
  221. the end part one</a>
  222.  
  223.  
  224.       </ul>
  225.  
  226.     </div>
  227.                    <!--end of the teen titans div-->
  228.   </div>
  229.                    <!--end of nav div-->
  230.  
  231.  
  232.  
  233.  
  234.  
  235. </div>
  236.  
  237.  
  238. </body>
  239. </html>
  240.  
QT frame
[HTML]<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>

<body>
WMP Iframe



<OBJECT classid='clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B' width='320' height='240' codebase='http://www.apple.com/qtactivex/qtplugin.cab'>
<param name='src' value=''>
<param name='autoplay' value='true'>
<param name='controller' value='true'>
<param name='loop' value='false'>
<EMBED src='' width='320' height='240' autoplay='true'
controller='true' loop='false' bgcolor='#000000' pluginspage='http://www.apple.com/quicktime/download/'>
</EMBED>
</OBJECT>

</body>
</html>
[/HTML]

quictime frame
[HTML]<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>

<body>
Windows media player page. will be an Iframe.



<OBJECT id='mediaPlayer' width="320" height="240"
classid='CLSID:22d6f312-b0f6-11d0-94ab-0080c74c7e95'
codebase='http://activex.microsoft.com/activex/controls/ mplayer/en/nsmp2inf.cab#Version=5,1,52,701'
standby='this will take some time<img src='misterioloder'' type='application/x-oleobject'>
<param name='fileName' value="">
<param name='animationatStart' value='1'>
<param name='transparentatStart' value='1'>
<param name='autoStart' value='1'>
<param name='ShowControls' value='1'>
<param name='ShowStatusBar' value='0'>
<param name='loop' value='0'>
<EMBED type='application/x-mplayer2'
pluginspage='http://microsoft.com/windows/mediaplayer/ en/download/'
id='mediaPlayer2' name='mediaPlayer' displaysize='4' autosize='0'
bgcolor='darkblue' showcontrols='true' showtracker='true'
showdisplay='0' showstatusbar='0' videoborder3d='0' width="320" height="240"
src='' autostart='1' designtimesp='5311' loop='0'>
</EMBED>
</OBJECT>



</body>
</html>
[/HTML]
Jul 14 '07 #1
Share this Question
Share on Google+
2 Replies


riptide2049
P: 2
...please help I've ran out of ideas.
Jul 15 '07 #2

acoder
Expert Mod 15k+
P: 16,027
What error messages do you see?
Jul 17 '07 #3

Post your reply

Sign in to post your reply or Sign up for a free account.