How to check if the browser can play mp4 via html5 video tag?

Coepr picture Coepr · Aug 26, 2010 · Viewed 45.2k times · Source

How to check if the browser can play mp4 via html5 video tag?

Answer

Alex Polo picture Alex Polo · Aug 27, 2010

This might help you:

<script type="text/javascript">'.
   var canPlay = false;
   var v = document.createElement('video');
   if(v.canPlayType && v.canPlayType('video/mp4').replace(/no/, '')) {
       canPlay = true;
   }

   alert(canPlay);

</script>