[ACCEPTED]-Embedding Windows Media Player for all browsers-media
The following works for me in Firefox and 1 Internet Explorer:
<object id="mediaplayer" 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" width="320" height="310">
<param name="filename" value="./test.wmv">
<param name="animationatstart" value="true">
<param name="transparentatstart" value="true">
<param name="autostart" value="true">
<param name="showcontrols" value="true">
<param name="ShowStatusBar" value="true">
<param name="windowlessvideo" value="true">
<embed src="./test.wmv" autostart="true" showcontrols="true" showstatusbar="1" bgcolor="white" width="320" height="310">
</object>
May I suggest the jQuery Media Plugin? Provides embed code 4 for all kinds of video, not just WMV and 3 does browser detection, keeping all that 2 messy switch/case statements out of your 1 templates.
Use the following. It works in Firefox and 1 Internet Explorer.
<object id="MediaPlayer1" width="690" height="500" 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='<%= GetSource() %>' />
<param name="AutoStart" value="True" />
<param name="DefaultFrame" value="mainFrame" />
<param name="ShowStatusBar" value="0" />
<param name="ShowPositionControls" value="0" />
<param name="showcontrols" value="0" />
<param name="ShowAudioControls" value="0" />
<param name="ShowTracker" value="0" />
<param name="EnablePositionControls" value="0" />
<!-- BEGIN PLUG-IN HTML FOR FIREFOX-->
<embed type="application/x-mplayer2" pluginspage="http://www.microsoft.com/Windows/MediaPlayer/"
src='<%= GetSource() %>' align="middle" width="600" height="500" defaultframe="rightFrame"
id="MediaPlayer2" />
And in JavaScript,
function playVideo() {
try{
if(-1 != navigator.userAgent.indexOf("MSIE"))
{
var obj = document.getElementById("MediaPlayer1");
obj.Play();
}
else
{
var player = document.getElementById("MediaPlayer2");
player.controls.play();
}
}
catch(error) {
alert(error)
}
}
Elizabeth Castro has an interesting article 3 on this problem: Bye Bye Embed. Worth a read on how 2 she attacked this problem, as well as handling 1 QuickTime content.
You could use conditional comments to get 3 IE and Firefox to do different things
<![if !IE]>
<p> Firefox only code</p>
<![endif]>
<!--[if IE]>
<p>Internet Explorer only code</p>
<![endif]-->
The 2 browsers themselves will ignore code that 1 isn't meant for them to read.
The best way to deploy video on the web is using Flash - it's much easier to embed cleanly into a web page and will play on more or less any browser and platform combination. The only reason to use Windows Media Player is if you're streaming content and you need extraordinarily strong digital rights management, and even then providers are now starting to use Flash even for these. See BBC's iPlayer for a superb example.
I would suggest that you switch to Flash 11 even for internal use. You never know who 10 is going to need to access it in the future, and 9 this will give you the best possible future 8 compatibility.
EDIT - March 20 2013. Interesting 7 how these old questions resurface from time 6 to time! How different the world is today 5 and how dated this all seems. I would not 4 recommend a Flash only route today by any 3 means - best practice these days would probably 2 be to use HTML 5 to embed H264 encoded video, with 1 a Flash fallback as described here: http://diveintohtml5.info/video.html
Encoding flash video is actually very easy 21 with ffmpeg. You can use one command to 20 convert from just about any video format, ffmpeg 19 is smart enough to figure the rest out, and 18 it'll use every processor on your machine. Invoking 17 it is easy:
ffmpeg -i input.avi output.flv
ffmpeg will guess at the bitrate 16 you want, but if you'd like to specify one, you 15 can use the -b option, so -b 500000
is 500kbps for 14 example. There's a ton of options of course, but 13 I generally get good results without much 12 tinkering. This is a good place to start 11 if you're looking for more options: video options.
You 10 don't need a special web server to show 9 flash video. I've done just fine by simply 8 pushing .flv files up to a standard web 7 server, and linking to them with a good 6 swf player, like flowplayer.
WMVs are fine if you can 5 be sure that all of your users will always 4 use [a recent, up to date version of] Windows 3 only, but even then, Flash is often a better 2 fit for the web. The player is even extremely 1 skinnable and can be controlled with javascript.
I found a good article about using the WMP with Firefox on MSDN.
Based 11 on MSDN's article and after doing some trials 10 and errors, I found using JavaScript is 9 better than using conditional comments or 8 nested "EMBED/OBJECT" tags.
I made 7 a JS function that generate WMP object based 6 on given arguments:
<script type="text/javascript">
function generateWindowsMediaPlayer(
holderId, // String
height, // Number
width, // Number
videoUrl // String
// you can declare more arguments for more flexibility
) {
var holder = document.getElementById(holderId);
var player = '<object ';
player += 'height="' + height.toString() + '" ';
player += 'width="' + width.toString() + '" ';
videoUrl = encodeURI(videoUrl); // Encode for special characters
if (navigator.userAgent.indexOf("MSIE") < 0) {
// Chrome, Firefox, Opera, Safari
//player += 'type="application/x-ms-wmp" '; //Old Edition
player += 'type="video/x-ms-wmp" '; //New Edition, suggested by MNRSullivan (Read Comments)
player += 'data="' + videoUrl + '" >';
}
else {
// Internet Explorer
player += 'classid="clsid:6BF52A52-394A-11d3-B153-00C04F79FAA6" >';
player += '<param name="url" value="' + videoUrl + '" />';
}
player += '<param name="autoStart" value="false" />';
player += '<param name="playCount" value="1" />';
player += '</object>';
holder.innerHTML = player;
}
</script>
Then I used that function 5 by writing some markups and inline JS like 4 these:
<div id='wmpHolder'></div>
<script type="text/javascript">
window.addEventListener('load', generateWindowsMediaPlayer('wmpHolder', 240, 320, 'http://mysite.com/path/video.ext'));
</script>
You can use jQuery.ready instead of window load event to making 3 the codes more backward-compatible and cross-browser.
I 2 tested the codes over IE 9-10, Chrome 27, Firefox 1 21, Opera 12 and Safari 5, on Windows 7/8.
I have found something that Actually works 6 in both FireFox and IE, on Elizabeth Castro's 5 site (thanks to the link on this site) - I 4 have tried all other versions here, but 3 could not make them work in both the browsers
<object classid="CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6"
id="player" width="320" height="260">
<param name="url"
value="http://www.sarahsnotecards.com/catalunyalive/fishstore.wmv" />
<param name="src"
value="http://www.sarahsnotecards.com/catalunyalive/fishstore.wmv" />
<param name="showcontrols" value="true" />
<param name="autostart" value="true" />
<!--[if !IE]>-->
<object type="video/x-ms-wmv"
data="http://www.sarahsnotecards.com/catalunyalive/fishstore.wmv"
width="320" height="260">
<param name="src"
value="http://www.sarahsnotecards.com/catalunyalive/fishstore.wmv" />
<param name="autostart" value="true" />
<param name="controller" value="true" />
</object>
<!--<![endif]-->
</object>
Check 2 her site out: http://www.alistapart.com/articles/byebyeembed/ and the version with the 1 classid in the initial object tag
December 2020 :
- We have now Firefox 83.0 and Chrome 87.0
- Internet Explorer is dead, it has been replaced by the new Chromium-based Edge 87.0
- Silverlight is dead
- Windows XP is dead
- WMV is not a standard : https://www.w3schools.com/html/html_media.asp
To answer the question :
- You have to convert your WMV file to another format : MP4, WebM or Ogg video.
- Then embed it in your page with the HTML 5
<video>
element.
I 1 think this question should be closed.
More Related questions
We use cookies to improve the performance of the site. By staying on our site, you agree to the terms of use of cookies.