Advertisement
Guest User

modernizr

a guest
May 10th, 2012
182
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /* HTML5 local video file player example */
  2.  
  3. /* Modernizr 2.5.3 (Custom Build) | MIT & BSD
  4.  * Build: http://www.modernizr.com/download/#-prefixed-testprop-testallprops-domprefixes
  5.  */
  6. ;window.Modernizr=function(a,b,c){function w(a){i.cssText=a}function x(a,b){return w(prefixes.join(a+";")+(b||""))}function y(a,b){return typeof a===b}function z(a,b){return!!~(""+a).indexOf(b)}function A(a,b){for(var d in a)if(i[a[d]]!==c)return b=="pfx"?a[d]:!0;return!1}function B(a,b,d){for(var e in a){var f=b[a[e]];if(f!==c)return d===!1?a[e]:y(f,"function")?f.bind(d||b):f}return!1}function C(a,b,c){var d=a.charAt(0).toUpperCase()+a.substr(1),e=(a+" "+m.join(d+" ")+d).split(" ");return y(b,"string")||y(b,"undefined")?A(e,b):(e=(a+" "+n.join(d+" ")+d).split(" "),B(e,b,c))}var d="2.5.3",e={},f=b.documentElement,g="modernizr",h=b.createElement(g),i=h.style,j,k={}.toString,l="Webkit Moz O ms",m=l.split(" "),n=l.toLowerCase().split(" "),o={},p={},q={},r=[],s=r.slice,t,u={}.hasOwnProperty,v;!y(u,"undefined")&&!y(u.call,"undefined")?v=function(a,b){return u.call(a,b)}:v=function(a,b){return b in a&&y(a.constructor.prototype[b],"undefined")},Function.prototype.bind||(Function.prototype.bind=function(b){var c=this;if(typeof c!="function")throw new TypeError;var d=s.call(arguments,1),e=function(){if(this instanceof e){var a=function(){};a.prototype=c.prototype;var f=new a,g=c.apply(f,d.concat(s.call(arguments)));return Object(g)===g?g:f}return c.apply(b,d.concat(s.call(arguments)))};return e});for(var D in o)v(o,D)&&(t=D.toLowerCase(),e[t]=o[D](),r.push((e[t]?"":"no-")+t));return w(""),h=j=null,e._version=d,e._domPrefixes=n,e._cssomPrefixes=m,e.testProp=function(a){return A([a])},e.testAllProps=C,e.prefixed=function(a,b,c){return b?C(a,b,c):C(a,"pfx")},e}(this,this.document);
  7. /* /Modernizr 2.5.3 */
  8.  
  9. (function localFileVideoPlayerInit(win) {
  10.     var Modernizr = win.Modernizr,
  11.         URL = Modernizr.prefixed('URL', win),
  12.         displayMessage = (function displayMessageInit() {
  13.             var node = document.querySelector('#message');
  14.  
  15.             return function displayMessage(message, isError) {
  16.                 node.innerHTML = message;
  17.                 node.className = isError ? 'error' : 'info';
  18.             };
  19.         }()),
  20.         playSelectedFile = function playSelectedFileInit(event) {
  21.             var file = this.files[0];
  22.  
  23.             var type = file.type;
  24.  
  25.             var videoNode = document.querySelector('video');
  26.  
  27.             var canPlay = videoNode.canPlayType(type);
  28.  
  29.             canPlay = (canPlay === '' ? 'no' : canPlay);
  30.  
  31.             var message = 'Can play type "' + type + '": ' + canPlay;
  32.  
  33.             var isError = canPlay === 'no';
  34.  
  35.             displayMessage(message, isError);
  36.  
  37.             if (isError) {
  38.                 return;
  39.             }
  40.  
  41.             var fileURL = URL.createObjectURL(file);
  42.  
  43.             videoNode.src = fileURL;
  44.         },
  45.         inputNode = document.querySelector('input');
  46.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          
  47.     if (!URL) {
  48.         displayMessage('Your browser is not ' +
  49.            '<a href="http://caniuse.com/bloburls">supported</a>!', true);
  50.        
  51.         return;
  52.     }                
  53.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          
  54.     inputNode.addEventListener('change', playSelectedFile, false);
  55. }(window));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement