Advertisement
Guest User

EmbedMovie (2006)

a guest
Jun 20th, 2022
37
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. var mtype = new Array (".avi.mp3", ".qt.mov.mpg.mpeg.mpe.mp4.m4v.aiff", ".wmv.wma.asf", ".swf", ".flv", ".divx.xvid" );
  3. var cheight = new Array (0, 16, 64, 0, 18, 20);
  4. var audio = ".mp3.wav.wma.aiff.mid.rm.ram";
  5.  
  6. function addParam(name, value) {
  7.   return '<param name="' + name + '" value="' + value + '" />\n';
  8. }
  9.  
  10. function embedMovie(src, width, height, autoplay, hide, scaletofit) {
  11.   var isExplorer = (navigator.appName.indexOf('Explorer') != -1);
  12.   var ext = src.substr(src.lastIndexOf('.')).toLowerCase();
  13.   var isAudio = (audio.indexOf(ext) != -1);
  14.  
  15.   for(i = 0; i < mtype.length; i++)
  16.     if(mtype[i].indexOf(ext) != -1) break;
  17.  
  18.   if(i == 0) { i = (navigator.userAgent.indexOf('Macintosh') != -1)? 1 : 2; }
  19.  
  20.   if(!scaletofit && audio.indexOf(ext) != -1) height = 0;
  21.    
  22.   if(hide) width = height = 0;
  23.   else height += (i < mtype.length)? cheight[i] : 45;
  24.  
  25.   switch (i) {
  26.  
  27.   case 1: // QuickTime Movie
  28.  
  29.     if(isExplorer) {
  30.       document.write('<object classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B" ');
  31.       document.write('codebase="http://www.apple.com/qtactivex/qtplugin.cab#version=6,0,2,0" '); }
  32.     else
  33.       document.write('<object type="video/quicktime" data="' + src + '"');
  34.  
  35.     document.write(' width="' + width + '" height="' + height + '" id="QuickTimePlayer">\n');
  36.     document.write(addParam("src", src));
  37.     document.write(addParam("autoplay", autoplay? 'true':'false'));
  38.     document.write(addParam("bgcolor", "black"));
  39.     if(scaletofit) document.write(addParam("scale", "tofit"));
  40.     document.write('</object>\n');
  41.     break;
  42.  
  43.   case 2: // Windows Media Player
  44.  
  45.     //if(src.indexOf('/') == -1) src = './' + src;
  46.  
  47.     if(isExplorer)
  48.       document.write('<object classid="CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6" ');
  49.     else
  50.       document.write('<object type="video/x-ms-wmv" data="' + src + '" ');
  51.  
  52.     document.write('width="' + width + '" height="' + height + '" id="MediaPlayer">\n');
  53.     if(isExplorer) document.write(addParam("URL", src));
  54.     document.write(addParam("src", src));
  55.     document.write(addParam("AutoStart", autoplay? '1':'0'));
  56.     if(scaletofit) document.write(addParam("StretchToFit", '1'));
  57.     document.write(addParam(isExplorer? "ShowControls":"Controller", '1'));
  58.     document.write('</object>\n');
  59.     break;
  60.  
  61.   case 3: // Flash Animation
  62.     if(isExplorer) {
  63.       document.write('<object classid="CLSID:D27CDB6E-AE6D-11CF-96B8-444553540000" ');
  64.       document.write('codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" '); }
  65.     else
  66.       document.write('<object type="application/x-shockwave-flash" data="' + src + '" ');
  67.  
  68.     document.write('width="' + width + '" height="' + height + '" id="FlashPlayer" align="middle" />\n');
  69.     document.write(addParam("movie", src));
  70.     document.write(addParam("allowScriptAccess", "sameDomain"));
  71.     document.write('</object>\n');
  72.     break;
  73.  
  74.   case 4: // Flash movie
  75.     if(isExplorer) {
  76.       document.write('<object classid="CLSID:D27CDB6E-AE6D-11CF-96B8-444553540000" ');
  77.       document.write('codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" '); }
  78.     else
  79.       document.write('<object type="application/x-shockwave-flash" data="' + src + '&autoStart=' + (autoplay? 'true':'false') + '" ');
  80.  
  81.     document.write('width="' + width + '" height="' + height + '" id="FlashPlayer" align="middle" />\n');
  82.     document.write(addParam("movie", src + '&autoStart=' + (autoplay? 'true':'false')));
  83.     document.write(addParam("allowScriptAccess", "sameDomain"));
  84.     document.write(addParam("quality", "high"));
  85.     document.write('</object>\n');
  86.     break;
  87.  
  88.   case 5: // DivX Movie
  89.     if(isExplorer) {
  90.       document.write('<object classid="CLSID:67DABFBF-D0AB-41fa-9C46-CC0F21721616" ');
  91.       document.write('codebase="http://go.divx.com/plugin/DivXBrowserPlugin.cab" '); }
  92.     else
  93.       document.write('<object type="video/divx" data="' + src + '" ');
  94.  
  95.     document.write('width="' + width + '" height="' + height + '" pluginspage="http://go.divx.com/plugin/download/" id="DivxPlayer">\n');
  96.     document.write(addParam("mode", "zero"));
  97.     document.write(addParam("autoPlay", autoplay? 'true':'false'));
  98.     document.write(addParam("allowContextMenu", "false"));
  99.     if(src.charAt(0) == "." || src.charAt(0) == "/" || src.indexOf("http:") == 0)
  100.       document.write(addParam("src", src));
  101.     else
  102.       document.write(addParam("src", "./" + src));
  103.     document.write('</object>\n');
  104.     break;
  105.    
  106.   default: // Undefined
  107.     document.write('<embed src="' + src + '" autostart="' + (autoplay? 'true':'false') + '" width="' + width + '" height="' + height + '" loop="false"></embed>');
  108.   }
  109. }
  110.  
  111.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement