JAVASCRIPT: alternate way to get a duration of the embed file?

Is there anyway or javascript class or function that I can used to get the duration on the embed file?

I know we can do it like this

<!DOCTYPE html> 
<html> 
<body> 

<button onclick="myFunction()" type="button">Get video length</button><br>

<video id="myVideo" width="320" height="176" controls>
  <source src="mov_bbb.mp4" type="video/mp4">
  <source src="mov_bbb.ogg" type="video/ogg">
  Your browser does not support HTML5 video.
</video>

<script>
var vid = document.getElementById("myVideo");

function myFunction() { 
    alert(vid.duration);
} 
</script> 

<p>Video courtesy of <a href="http://www.bigbuckbunny.org/" target="_blank">Big Buck Bunny</a>.</p>

</body> 
</html>

it only works on some supported browsers but not in ie8 below. Can anyone guide me how can I get the duration of the embed files? that can work on any crossbrowsers? or do I need to make a parser? please help thank you.


Source: javascript

Leave a Reply