Is there any JavaScript or any other way of checking for html5 video support?
Answer: On the page with the video, press Ctrl+U to View the source. Now, look for a tag like <object> that is used by the flash video player or <video> tag used by HTML5, and accordingly, it can be known if the video is using Flash or HTML5.
The getContext method is checked by accessing it on the created input object. The result of this expression is checked with an if-statement. If the result is true, it means that HTML5 is supported by the browser.
The HTML5 video format capabilities include three options to play: MP4, WebM, and Ogg. You should note that the Safari browser does not support Ogg, WebM is supported by only 58% of browsers, and MP4 is disabled by default in Firefox 24.
If your browser error "HTML5 video file not found", it means that your browser is not up to date or website pages does not have a suitable video codec. It would help if you communicated with the developer to solve the issue and install all the required codecs.
I use a slight variation of @sweets-BlingBling's answer, which is:
var hasVideo = !!document.createElement('video').canPlayType &&
!!document.createElement('video').canPlayType('video/mp4')
This also checks whether the media type 'video/mp4'
is actually playable (change this if your video has another media type, like 'video/webm'
or 'video/ogg'
). The method returns an empty String if the video definitely cannot be played and 'probably'
or 'maybe'
(actually, both results mean yes
in most instances) otherwise. I had to add this for Chrome 41 (seemingly used in google crawler), which has canPlayType
, but cannot play mp4
videos.
use:
<script>
alert(!!document.createElement('video').canPlayType);
</script>
if it alerts true implies that your browser supports HTML5 video tag
Here is the url to check HTML5 Browser compatibility http://www.html5test.com/ Open the url in your browser to test how well your browser supports html5
Just a little refinement of sweets-BlingBling's answer : sorry - I can't comment yet :(
var isHTML5Video = (typeof(document.createElement('video').canPlayType) != 'undefined') ? true : false;
or even simpler (thanks digitalBath - as always I can't see the wood for the trees :) )
var isHTML5Video = (typeof(document.createElement('video').canPlayType) != 'undefined');
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With