# Embedded WMV video not working in Firefox



## dmurfitt

I have embedded a wmv file into a webpage which works no problems on Internet Explorer, however it won't work on FireFox, you just get a black square. Any ideas how to fix this? Here's the code:



Code:


<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='Loading Microsoft Windows Media Player components' type='application/x-oleobject'>
<param name='fileName' value="http://mydomain.com/video.wmv">
<param name='animationatStart' value='1'>
<param name='transparentatStart' value='1'>
<param name='autoStart' value='1'>
<param name='ShowControls' value='0'>
<param name='ShowDisplay' value='0'>
<param name='ShowStatusBar' value='0'>
<param name='loop' value='0'>
<EMBED type='application/x-mplayer2'
pluginspage='http://microsoft.com/windows/mediaplayer/ en/download/'
id='mediaPlayer' name='mediaPlayer' displaysize='4' autosize='0'
bgcolor='darkblue' showcontrols='0' showtracker='1'
showdisplay='0' showstatusbar='0' videoborder3d='0' width="320" height="240"
src="http://mydomain.com/video.wmv" autostart='1' designtimesp='5311' loop='0'>
</EMBED>
</OBJECT>

Thanks


----------



## Shadow2531

Try this:

Just edit each part where there's a .wmv URI.



Code:


<!--[if !IE]> <-->
    <object type="video/x-ms-wmv" data="http://mydomain.com/video.wmv" width="320px" height="240px">
        <param name="src" value="http://mydomain.com/video.wmv" valuetype="ref" type="http://mydomain.com/video.wmv">
        <param name="animationatStart" value="1">
        <param name="transparentatStart" value="1">
        <param name="autoStart" value="1">
        <param name="ShowControls" value="0">
        <param name="ShowDisplay" value="0">
        <param name="ShowStatusBar" value="0">
        <param name="loop" value="0">
        <param name="displaysize" value="0">
        <strong>Error:</strong> Embedding <a href="http://mydomain.com/video.wmv">http://mydomain.com/video.wmv</a> with the <a href="http://www.microsoft.com/windows/windowsmedia/download/plugin.aspx">Windows Media Plugin</a> failed.
    </object>
<!--> <![endif]-->
<!--[if IE]>
    <object type="video/x-ms-wmv" classid="CLSID:22D6f312-B0F6-11D0-94AB-0080C74C7E95" width="320px" height="240px">
        <param name="src" value="http://mydomain.com/video.wmv" valuetype="ref" type="video/x-ms-wmv">
        <param name="animationatStart" value="1">
        <param name="transparentatStart" value="1">
        <param name="autoStart" value="1">
        <param name="ShowControls" value="0">
        <param name="ShowDisplay" value="0">
        <param name="ShowStatusBar" value="0">
        <param name="loop" value="0">
        <param name="displaysize" value="0">
        <strong>Error:</strong> Embedding <a href="http://mydomain.com/video.wmv">http://mydomain.com/video.wmv</a> with the Windows Media Plugin failed.  Make sure you have <a href="http://www.microsoft.com/windows/windowsmedia/default.aspx">Windows Media Player</a>.
    </object>
<![endif]-->


----------



## dmurfitt

What does that do? Will it work on Firefox then?


----------



## Shadow2531

The first part is for standard compliant browsers like Firefox, Opera and Safari. The second part is for IE becuase IE doesn't use the netscape windows media plugin. It uses ActiveX.

In standard compliant browsers, all the *if* stuff and the second part will be considered a comment and ignored. Only the first part will be used.

In IE, the *if* stuff is treated as a conditional and it's set up so IE only uses the second part.

It should work across the board, which includes Firefox. If you upload a wmv file and give us the link, we can test the code to make sure.


----------



## dmurfitt

It's strange though because I thought as long as a PC has Windows Media Player it can play WMV files in whatever browser displaying an embedded video. Does my embed code point ot the correct plug in for other browsers?

Thanks,


----------



## Shadow2531

It doesn't really work that way. In other browsers besides IE, you need to have a plugin, which allows the browser to embed windows media player.
http://www.microsoft.com/windows/windowsmedia/download/plugin.aspx

The type attribute for the object tag tells the browser what plugin to use to load the file. video-/x-ms-wmv is a type associated with the windows media plugin. The data attribute tells the browser what file to load with the plugin. (Because of some browser quirks sometimes you need to add a src param that specifies the same file as the data attribute.)

The classid attribute should not be used for most plugins for other browsers. It's most of the time, just an IE activeX thing.

The method you use for the object tag is setup for use with ActiveX (The classid and ole object stuff. You should only need to do the ole object way for internet explorer if you plan on controlling stuff with javascript.

Since the object tag isn't setup right for other browsers, other browsers must fall back on the embed tag. The embed tag is pretty much set up right and should probably still work with type="application/x-mplayer2" in Firefxo. However, it should really be video/x-ms-wmv.

Now, for Firefox, there is a windows media plugin that can use activeX. If you have that, then the activeX way you do things for the object tag might work, but that all depends.

Also, the embed tag isn't a standard tag. The object tag is.

Here's the standard way of embedding things:


Code:


<object type="mime_type" data="file.ext" width="width" height="height">
    <param name="name" value="value" />
    Alternate content
</object>

That's what you start off with, Then work around the bugs in each browser, and there are bugs in each browser!

In addition though, people on other operating systems don't have windows media player, so by using a windows media format and counting on the windows media plugin, people will be missing out.

Since IE does things in a non-standard way, it's better to separate the IE code whenever possible.

A real player format might be a better idea so it reaches a broader audience. Although there are bugs in browsers with it too.


----------

