WordPress/wp-includes/js/mediaelement/renderers/facebook.min.js
2017-08-12 06:20:44 +00:00

12 lines
5.1 KiB
JavaScript

/*!
* MediaElement.js
* http://www.mediaelementjs.com/
*
* Wrapper that mimics native HTML5 MediaElement (audio and video)
* using a variety of technologies (pure JavaScript, Flash, iframe)
*
* Copyright 2010-2017, John Dyer (http://j.hn/)
* License: MIT
*
*/
!function e(t,n,r){function i(s,o){if(!n[s]){if(!t[s]){var u="function"==typeof require&&require;if(!o&&u)return u(s,!0);if(a)return a(s,!0);var l=new Error("Cannot find module '"+s+"'");throw l.code="MODULE_NOT_FOUND",l}var c=n[s]={exports:{}};t[s][0].call(c.exports,function(e){var n=t[s][1][e];return i(n||e)},c,c.exports,e,t,n,r)}return n[s].exports}for(var a="function"==typeof require&&require,s=0;s<r.length;s++)i(r[s]);return i}({1:[function(e,t,n){"use strict";var r={name:"facebook",options:{prefix:"facebook",facebook:{appId:"",xfbml:!0,version:"v2.10"}},canPlayType:function(e){return~["video/facebook","video/x-facebook"].indexOf(e.toLowerCase())},create:function(e,t,n){function r(t){for(var n=0,r=t.length;n<r;n++){var i=mejs.Utils.createEvent(t[n],a);e.dispatchEvent(i)}}function i(t,n){c=t,(m=document.createElement("div")).id=a.id,m.className="fb-video",m.setAttribute("data-href",t),m.setAttribute("data-allowfullscreen","true"),m.setAttribute("data-controls","false"),e.originalNode.parentNode.insertBefore(m,e.originalNode),e.originalNode.style.display="none",window.fbAsyncInit=function(){FB.init(n),FB.Event.subscribe("xfbml.ready",function(t){if("video"===t.type){v=t.instance;var n=m.getElementsByTagName("iframe")[0],i=n.offsetWidth,l=n.offsetHeight,c=["mouseover","mouseout"];a.setSize(i,l),u&&v.play();for(var g=0,h=c.length;g<h;g++)n.addEventListener(c[g],function(t){var n=mejs.Utils.createEvent(t.type,a);e.dispatchEvent(n)},!1);for(var b=["startedPlaying","paused","finishedPlaying","startedBuffering","finishedBuffering"],y=0,E=b.length;y<E;y++){var N=b[y],k=o[N];void 0===k||null===k||mejs.Utils.isObjectEmpty(k)||"function"!=typeof k.removeListener||k.removeListener(N)}if(s.length)for(var j=0,w=s.length;j<w;j++){var U=s[j];if("set"===U.type){var x=U.propName,B=""+x.substring(0,1).toUpperCase()+x.substring(1);a["set"+B](U.value)}else"call"===U.type&&a[U.methodName]()}r(["rendererready","loadeddata","canplay","progress","loadedmetadata","timeupdate"]);var P=void 0;o.startedPlaying=v.subscribe("startedPlaying",function(){p||(p=!0),f=!1,d=!1,r(["play","playing","timeupdate"]),P=setInterval(function(){v.getCurrentPosition(),r(["timeupdate"])},250)}),o.paused=v.subscribe("paused",function(){f=!0,d=!1,r(["pause"])}),o.finishedPlaying=v.subscribe("finishedPlaying",function(){f=!0,d=!0,r(["ended"]),clearInterval(P),P=null}),o.startedBuffering=v.subscribe("startedBuffering",function(){r(["progress","timeupdate"])}),o.finishedBuffering=v.subscribe("finishedBuffering",function(){r(["progress","timeupdate"])})}})},mejs.Utils.loadScript("https://connect.facebook.net/en_US/sdk.js")}var a={},s=[],o={},u=e.originalNode.autoplay,l="",c="",f=!0,d=!1,p=!1,v=null,m=null;mejs.Features.isiPhone&&e.originalNode.getAttribute("poster")&&(l=e.originalNode.getAttribute("poster"),e.originalNode.removeAttribute("poster")),t=Object.assign(t,e.options),a.options=t,a.id=e.id+"_"+t.prefix,a.mediaElement=e;for(var g=mejs.html5media.properties,h=0,b=g.length;h<b;h++)!function(n){var r=""+n.substring(0,1).toUpperCase()+n.substring(1);a["get"+r]=function(){if(null!==v){switch(n){case"currentTime":return v.getCurrentPosition();case"duration":return v.getDuration();case"volume":return v.getVolume();case"paused":return f;case"ended":return d;case"muted":return v.isMuted();case"buffered":return{start:function(){return 0},end:function(){return 0},length:1};case"src":return c;case"readyState":return 4}return null}return null},a["set"+r]=function(r){if(null!==v)switch(n){case"src":var o="string"==typeof r?r:r[0].src;m.remove(),i(o,t.facebook),FB.XFBML.parse(),u&&v.play();break;case"currentTime":v.seek(r);break;case"muted":r?v.mute():v.unmute(),setTimeout(function(){var t=mejs.Utils.createEvent("volumechange",a);e.dispatchEvent(t)},50);break;case"volume":v.setVolume(r),setTimeout(function(){var t=mejs.Utils.createEvent("volumechange",a);e.dispatchEvent(t)},50);break;case"readyState":var l=mejs.Utils.createEvent("canplay",a);e.dispatchEvent(l)}else s.push({type:"set",propName:n,value:r})}}(g[h]);for(var y=mejs.html5media.methods,E=0,N=y.length;E<N;E++)!function(e){a[e]=function(){if(null!==v)switch(e){case"play":return v.play();case"pause":return v.pause();case"load":return null}else s.push({type:"call",methodName:e})}}(y[E]);return n.length>0&&i(n[0].src,a.options.facebook),a.hide=function(){a.stopInterval(),a.pause(),m&&(m.style.display="none")},a.show=function(){m&&(m.style.display="")},a.setSize=function(e){null===v||isNaN(e)||(m.style.width=e)},a.destroy=function(){l&&e.originalNode.setAttribute("poster",l)},a.interval=null,a.startInterval=function(){a.interval=setInterval(function(){var t=mejs.Utils.createEvent("timeupdate",a);e.dispatchEvent(t)},250)},a.stopInterval=function(){a.interval&&clearInterval(a.interval)},a}};mejs.Utils.typeChecks.push(function(e){return~e.toLowerCase().indexOf("//www.facebook")?"video/x-facebook":null}),mejs.Renderers.add(r)},{}]},{},[1]);