Solved

How Do I embed wmv files that works on all browsers ...

Posted on 2009-05-19
4
1,461 Views
Last Modified: 2013-12-07
Hello:

I would like to embed a wmv file into html code. My problem is that it works fine in IE but not in other brosers (FF, Safari). For FF and Safari, the window is basically blank ...

Attached is the js script I am using ...

P.S. This attached code is a modified version of the code that I found that will embed audio. However, I needed video, so I modified it. The original script (For Audio) is @
// Pop-Up Embedder Script by David Battino, www.batmosphere.com
// Version 2006-05-31  

function MyVideoPop(filedesc,filepath,WindowNumber) 
{
 
// Get Operating System 
var isWin = navigator.userAgent.toLowerCase().indexOf("windows") != -1
if (isWin) {
    // Use MIME type = "application/x-mplayer2";
	visitorOS="Windows";
} else {
    // Use MIME type = "audio/mpeg"; // or audio/x-wav or audio/x-ms-wma, etc.
	visitorOS="Other";
}
 
// Get the MIME type of the audio file from its extension (for non-Windows browsers)
var class_id = "CLSID:22D6F312-B0F6-11D0-94AB-0080C74C7E95";
var ttype = "video/x-ms-wmv";
var ttype2 = "application/x-oleobject";
var codebase = "codebase='http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=6,4,7,1112'";
 
  if (visitorOS != "Windows")
  { 
    class_id = ""; 	
  }
    PlayerWin = window.open('',WindowNumber,'width=675,height=675,top=0,left=0,screenX=0,screenY=0,resizable=1,scrollbars=0,titlebar=0,toolbar=0,menubar=0,status=1,directories=0');
 
    PlayerWin.focus();
    PlayerWin.document.writeln("<html><head><title>" + filedesc + "</title></head>");
    PlayerWin.document.writeln("<body bgcolor='#CEE1F7'>"); // specify background img if desired
    PlayerWin.document.writeln("<div align='center'>");
    PlayerWin.document.writeln("<p style ='color:green;font-size:20px;font-family:Lucida,sans-serif;'>" + filedesc + "</p><br />");
    
    if (visitorOS == "Windows")
     {
      PlayerWin.document.write("<object type='video/x-ms-wmv' classid='CLSID:22D6f312-B0F6-11D0-94AB-0080C74C7E95' ");
     }
    else
     {
      PlayerWin.document.write("<object data='" + filepath + "' ");     
     }
    PlayerWin.document.writeln(" standby='Loading Windows Media Component, Please wait ... ' height='500' width='500'>"); 
//    PlayerWin.document.writeln("<object ID='MediaPlayer' width='500' height='500' " + 
//                               "CLASSID='" + class_id + "'" + 
//                              " standby='Loading Windows Media Player Components...'" +
//                             " type='" + ttype + "'" +
//                               ">");
    PlayerWin.document.writeln("<param name='src' value='" +  filepath + "'>");
    PlayerWin.document.writeln("<param name='autostart' value='1'>");
    PlayerWin.document.writeln("<param name='showcontrols' value='1'>"); 
    PlayerWin.document.writeln("<param name='showstatusbar' value='1'>");
    PlayerWin.document.writeln("<param name='animationatStart' value='1'>");
    PlayerWin.document.writeln("<param name='transparentatStart' value='1'>");
    PlayerWin.document.writeln("<embed src ='" + filepath + " type='application/x-mplayer2'" + " autoplay='true'  height = '600' width = '600' controller='1' showstatusbar='1' bgcolor='#9999ff' kioskmode='true'>");
    PlayerWin.document.writeln("</embed></object></div>");
 //   PlayerWin.document.writeln("<p style='font-size:12px;font-family:Lucida,sans-serif;text-align:center'><a href='" + filepath +"'>Download this file</a> <span style='font-size:10px'>(right-click or Control-click)</span></p>");
    PlayerWin.document.writeln("<p style='color:green;font-size:20px;font-family:Lucida,sans-serif;text-align:center'>Double Click The Image To Make It Full Screen</p>");
    PlayerWin.document.writeln("<form><div align='center'><input type='button' value='Close this window' onclick='javascript:window.close();'></div></form>");
    PlayerWin.document.writeln("</body></html>");
 
    PlayerWin.document.close(); // "Finalizes" new window
}

Open in new window

0
Comment
Question by:MohammadAliQureshi
  • 3
4 Comments
 
LVL 31

Accepted Solution

by:
Frosty555 earned 500 total points
ID: 24428445
There's a good discussion on this here:
http://forums.techguy.org/web-design-development/425529-embedded-wmv-video-not-working.html

Make sure your code conforms to the standard shown in that thread.

Also, make sure you have an appropriate plug in for playing WMV files in firefox. Otherwise nothing will work no matter what HTML you put in. More on that here:

http://forums.mozillazine.org/viewtopic.php?t=206213
0
 

Author Comment

by:MohammadAliQureshi
ID: 24428606
Hello Frosty555:

I did visit http://forums.techguy.org/web-design-development/425529-embedded-wmv-video-not-working.html.

Is the code in the website HTML?

My code snippet is my attempt to implement what his website has in javascript.

I am still reading the info in the other website you mentioned (foruns.mozillazine). So far, it looks like that my FF should dipaly the wmv correctly. I will keep you uptodate ..

Thanks,

<< Ali >>>
0
 

Author Comment

by:MohammadAliQureshi
ID: 24489284
Hello:
Just to inform how did I solve the embed problem ...

I called a Javascript function to open a new window - I learned from  Pop-Up Embedder Script by David Battino, www.batmosphere.com Version 2006-05-31 -
with html code mentioned in the following link provided by Frosty555 (Thanks). Now it works in all three browsers (IE, Safari and FireFox) - I did not try it on Mac!!).

Thanks,
<<< Ali >>>
0
 

Author Closing Comment

by:MohammadAliQureshi
ID: 31583342
Thanks for the help ... Please refer to my last post to see how I implemented thesolution ...

Thanks
<<< Ali >>>
0

Featured Post

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

This article discusses the difference between strict equality operator and equality operator in JavaScript. The Need: Because JavaScript performs an implicit type conversion when performing comparisons, we have to take this into account when wri…
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
Google currently has a new report that is in beta and coming soon to Webmaster Tool accounts. This Micro Tutorial will highlight new features for Google Webmaster Tools.

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question