video.js 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. /*!
  2. {
  3. "name": "HTML5 Video",
  4. "property": "video",
  5. "caniuse": "video",
  6. "tags": ["html5"],
  7. "knownBugs": ["Without QuickTime, `Modernizr.video.h264` will be `undefined`; https://github.com/Modernizr/Modernizr/issues/546"],
  8. "polyfills": [
  9. "html5media",
  10. "mediaelementjs",
  11. "sublimevideo",
  12. "videojs",
  13. "leanbackplayer",
  14. "videoforeverybody"
  15. ]
  16. }
  17. !*/
  18. /* DOC
  19. Detects support for the video element, as well as testing what types of content it supports.
  20. Subproperties are provided to describe support for `ogg`, `h264` and `webm` formats, e.g.:
  21. ```javascript
  22. Modernizr.video // true
  23. Modernizr.video.ogg // 'probably'
  24. ```
  25. */
  26. define(['Modernizr', 'createElement'], function(Modernizr, createElement) {
  27. // Codec values from : github.com/NielsLeenheer/html5test/blob/9106a8/index.html#L845
  28. // thx to NielsLeenheer and zcorpan
  29. // Note: in some older browsers, "no" was a return value instead of empty string.
  30. // It was live in FF3.5.0 and 3.5.1, but fixed in 3.5.2
  31. // It was also live in Safari 4.0.0 - 4.0.4, but fixed in 4.0.5
  32. Modernizr.addTest('video', function() {
  33. var elem = createElement('video');
  34. var bool = false;
  35. // IE9 Running on Windows Server SKU can cause an exception to be thrown, bug #224
  36. try {
  37. bool = !!elem.canPlayType;
  38. if (bool) {
  39. bool = new Boolean(bool);
  40. bool.ogg = elem.canPlayType('video/ogg; codecs="theora"').replace(/^no$/, '');
  41. // Without QuickTime, this value will be `undefined`. github.com/Modernizr/Modernizr/issues/546
  42. bool.h264 = elem.canPlayType('video/mp4; codecs="avc1.42E01E"').replace(/^no$/, '');
  43. bool.webm = elem.canPlayType('video/webm; codecs="vp8, vorbis"').replace(/^no$/, '');
  44. bool.vp9 = elem.canPlayType('video/webm; codecs="vp9"').replace(/^no$/, '');
  45. bool.hls = elem.canPlayType('application/x-mpegURL; codecs="avc1.42E01E"').replace(/^no$/, '');
  46. }
  47. } catch (e) {}
  48. return bool;
  49. });
  50. });