Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Ok, I found out some really weird stuff (who would have guessed, its MS).</p> <p>First thing, I was always getting errors that Player.controls is not available. Maybe it has something to do with that I use the <code>CLASSID="CLSID:22D6F312-B0F6-11D0-94AB-0080C74C7E95"</code> in my code rather than <code>CLASSID="CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6"</code> as described in the <code>"docs"</code>. This is because using any other classid would cause the wmp not to load/play the video, so I'd have to go with that classid.</p> <pre><code>var player = document.getElementById("player"); </code></pre> <p>So, no matter what I did, any of the <a href="http://msdn.microsoft.com/en-us/library/windows/desktop/dd563945%28v=vs.85%29.aspx" rel="nofollow">objects listed here</a> were not available in my player object, like <code>player.controls</code> or <code>player.media</code>, none of them.</p> <p>So I tried to just log the whole player object to see what actually is there: <code>console.log(player)</code>. IE8, awesome as it is, gracefully printed this in the log: <code>[object]</code>. What a surprise, really. Debugging did not work (how could it...). So, I did a <code>for (a in player)</code> log :) IE crashes. Awesome.</p> <p>Strangely, after opening a new tab, the console showed up with all the logs. I found out, and this is the strange but awesome-since-works-now part: all the properties, methods and stuff are directly put into the player var, so it's not <code>player.controls.currentPosition</code> but rather <code>player.currentPosition</code>. Booya.</p> <p>This is my working code:</p> <pre><code> var obj = '&lt;object id="wmp" CLASSID="CLSID:22D6F312-B0F6-11D0-94AB-0080C74C7E95" TYPE="application/x-oleobject" width="' + parseInt(parsed.width) + '" height="' + (parseInt(parsed.height) + 0) + '" codebase="http://www.microsoft.com/Windows/MediaPlayer/"&gt;'; .. obj += '&lt;/object&gt;'; $('#wrapper').html(obj); var wmp = document.getElementById("wmp"); wmp.attachEvent('playStateChange', function(a) { if (a == 8 || a === 0 || a === '0' || parseInt(a) === 0 || a == 'MediaEnded') { // check if playback has really finished var cpos = wmp.currentPosition, dur = wmp.duration; if (dur - cpos &gt;= dur - 0.1 ) { console.log('the video has ended'); } } }); </code></pre> <p><a href="http://msdn.microsoft.com/en-us/library/windows/desktop/dd564085%28v=vs.85%29.aspx" rel="nofollow">This page here suggests</a> to use the state 8 when the video has finished playback which actually never is 8, ever. It's rather randomly 0, 2 or 3. Mostly 0.</p> <p>Hope this helps anybody!</p>
    singulars
    1. This table or related slice is empty.
    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. 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