Check If Browser Supports HTML5 Videos – isVideo.js

Category: Javascript | February 19, 2019
Author:flouthoc
Views Total:143 views
Official Page:Go to website
Last Update:February 19, 2019
License:MIT

Preview:

Check If Browser Supports HTML5 Videos – isVideo.js

Description:

isVideo.js is a small JavaScript library used to detect if your browser supports videos in the specified format.

A typical use of this library is to dynamically embed HTML5 videos in the document based on the browser.

Supported videos:

  • Mp4
  • Ogg
  • Webm

How to use it:

Download and import the isVideo.js library into the document.

<script src="index.js"></script>

Fire events when the browser supports or does not support video in the specified format.

window.onload = function(){
  if(isVideo("mp4")){
    alert('Your browser supports MP4.');
  }else{
    alert('Your browser does not support MP4.')
  }
}
window.onload = function(){
  if(isVideo("ogg")){
    alert('Your browser supports ogg.');
  }else{
    alert('Your browser does not support ogg.')
  }
}
window.onload = function(){
  if(isVideo("webm")){
    alert('Your browser supports webm.');
  }else{
    alert('Your browser does not support webm.')
  }
}

You Might Be Interested In:


Leave a Reply