Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* HTML5 local video file player example */
- /* Modernizr 2.5.3 (Custom Build) | MIT & BSD
- * Build: http://www.modernizr.com/download/#-prefixed-testprop-testallprops-domprefixes
- */
- ;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);
- /* /Modernizr 2.5.3 */
- (function localFileVideoPlayerInit(win) {
- var Modernizr = win.Modernizr,
- URL = Modernizr.prefixed('URL', win),
- displayMessage = (function displayMessageInit() {
- var node = document.querySelector('#message');
- return function displayMessage(message, isError) {
- node.innerHTML = message;
- node.className = isError ? 'error' : 'info';
- };
- }()),
- playSelectedFile = function playSelectedFileInit(event) {
- var file = this.files[0];
- var type = file.type;
- var videoNode = document.querySelector('video');
- var canPlay = videoNode.canPlayType(type);
- canPlay = (canPlay === '' ? 'no' : canPlay);
- var message = 'Can play type "' + type + '": ' + canPlay;
- var isError = canPlay === 'no';
- displayMessage(message, isError);
- if (isError) {
- return;
- }
- var fileURL = URL.createObjectURL(file);
- videoNode.src = fileURL;
- },
- inputNode = document.querySelector('input');
- if (!URL) {
- displayMessage('Your browser is not ' +
- '<a href="http://caniuse.com/bloburls">supported</a>!', true);
- return;
- }
- inputNode.addEventListener('change', playSelectedFile, false);
- }(window));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement