Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I found a good article about <a href="http://msdn.microsoft.com/en-us/library/windows/desktop/dd562847.aspx" rel="nofollow">using the WMP with Firefox</a> on MSDN.</p> <p>Based on MSDN's article and after doing some trials and errors, I found using JavaScript is better than using conditional comments or nested "EMBED/OBJECT" tags.</p> <p>I made a JS function that generate WMP object based on given arguments:</p> <pre><code>&lt;script type="text/javascript"&gt; 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 = '&lt;object '; player += 'height="' + height.toString() + '" '; player += 'width="' + width.toString() + '" '; videoUrl = encodeURI(videoUrl); // Encode for special characters if (navigator.userAgent.indexOf("MSIE") &lt; 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 + '" &gt;'; } else { // Internet Explorer player += 'classid="clsid:6BF52A52-394A-11d3-B153-00C04F79FAA6" &gt;'; player += '&lt;param name="url" value="' + videoUrl + '" /&gt;'; } player += '&lt;param name="autoStart" value="false" /&gt;'; player += '&lt;param name="playCount" value="1" /&gt;'; player += '&lt;/object&gt;'; holder.innerHTML = player; } &lt;/script&gt; </code></pre> <p>Then I used that function by writing some markups and inline JS like these:</p> <pre><code>&lt;div id='wmpHolder'&gt;&lt;/div&gt; &lt;script type="text/javascript"&gt; window.addEventListener('load', generateWindowsMediaPlayer('wmpHolder', 240, 320, 'http://mysite.com/path/video.ext')); &lt;/script&gt; </code></pre> <p>You can use <strong><em>jQuery.ready</em></strong> instead of <strong><em>window load event</em></strong> to making the codes more backward-compatible and cross-browser.</p> <p>I tested the codes over IE 9-10, Chrome 27, Firefox 21, Opera 12 and Safari 5, on Windows 7/8.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload