WordPress/wp-includes/js/mediaelement/renderers/facebook.min.js
Weston Ruter 2e602a8560 Media: Add MediaElement.js 2.2 back-compat for MediaElement.js 4.2
* Introduces `mediaelement-migrate.js`.
* Upgrades ME.js from 4.2.5-74e01a40 to 4.2.6-78496d1.

Props rafa8626, bradyvercher.
See #39686.
Fixes #42189.

Built from https://develop.svn.wordpress.org/trunk@41877


git-svn-id: http://core.svn.wordpress.org/trunk@41711 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-10-16 18:07:52 +00:00

12 lines
5.5 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(o,s){if(!n[o]){if(!t[o]){var u="function"==typeof require&&require;if(!s&&u)return u(o,!0);if(a)return a(o,!0);var l=new Error("Cannot find module '"+o+"'");throw l.code="MODULE_NOT_FOUND",l}var d=n[o]={exports:{}};t[o][0].call(d.exports,function(e){var n=t[o][1][e];return i(n||e)},d,d.exports,e,t,n,r)}return n[o].exports}for(var a="function"==typeof require&&require,o=0;o<r.length;o++)i(r[o]);return i}({1:[function(e,t,n){"use strict";var r={promise:null,load:function(e){"undefined"!=typeof FB?r._createPlayer(e):(r.promise=r.promise||mejs.Utils.loadScript("https://connect.facebook.net/"+e.options.lang+"/sdk.js"),r.promise.then(function(){FB.init(e.options),setTimeout(function(){r._createPlayer(e)},50)}))},_createPlayer:function(e){window["__ready__"+e.id]()}},i={name:"facebook",options:{prefix:"facebook",facebook:{appId:"",xfbml:!0,version:"v2.10",lang:"en_US"}},canPlayType:function(e){return~["video/facebook","video/x-facebook"].indexOf(e.toLowerCase())},create:function(e,t,n){function i(t){for(var n=0,r=t.length;n<r;n++){var i=mejs.Utils.createEvent(t[n],o);e.dispatchEvent(i)}}var a=[],o={},s=!1,u=!0,l=!1,d=null,c="",f="",p=e.originalNode.autoplay;o.options=t,o.id=e.id+"_"+t.prefix,o.mediaElement=e,mejs.Features.isiPhone&&e.originalNode.getAttribute("poster")&&(f=e.originalNode.getAttribute("poster"),e.originalNode.removeAttribute("poster"));for(var m=mejs.html5media.properties,v=0,g=m.length;v<g;v++)!function(t){var n=""+t.substring(0,1).toUpperCase()+t.substring(1);o["get"+n]=function(){if(null!==d){switch(t){case"currentTime":return d.getCurrentPosition();case"duration":return d.getDuration();case"volume":return d.getVolume();case"paused":return u;case"ended":return l;case"muted":return d.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},o["set"+n]=function(n){if(null!==d)switch(t){case"src":var i="string"==typeof n?n:n[0].src;c=i,N.remove(),(N=document.createElement("div")).id=o.id,N.className="fb-video",N.setAttribute("data-href",i),N.setAttribute("data-allowfullscreen","true"),N.setAttribute("data-controls","false"),e.originalNode.parentNode.insertBefore(N,e.originalNode),e.originalNode.style.display="none",r.load({lang:o.options.lang,id:o.id}),FB.XFBML.parse(),p&&d.play();break;case"currentTime":d.seek(n);break;case"muted":n?d.mute():d.unmute(),setTimeout(function(){var t=mejs.Utils.createEvent("volumechange",o);e.dispatchEvent(t)},50);break;case"volume":d.setVolume(n),setTimeout(function(){var t=mejs.Utils.createEvent("volumechange",o);e.dispatchEvent(t)},50);break;case"readyState":var s=mejs.Utils.createEvent("canplay",o);e.dispatchEvent(s)}else a.push({type:"set",propName:t,value:n})}}(m[v]);for(var y=mejs.html5media.methods,b=0,h=y.length;b<h;b++)!function(e){o[e]=function(){if(null!==d)switch(e){case"play":return d.play();case"pause":return d.pause();case"load":return null}else a.push({type:"call",methodName:e})}}(y[b]);window["__ready__"+o.id]=function(){FB.Event.subscribe("xfbml.ready",function(t){if("video"===t.type&&o.id===t.id){e.fbPlayer=d=t.instance;var n=document.getElementById(o.id),r=n.offsetWidth,c=n.offsetHeight,f=["mouseover","mouseout"];o.setSize(r,c),e.originalNode.muted||d.unmute(),p&&d.play();for(var m=0,v=f.length;m<v;m++)n.addEventListener(f[m],function(t){var n=mejs.Utils.createEvent(t.type,o);e.dispatchEvent(n)});o.eventHandler={};for(var g=["startedPlaying","paused","finishedPlaying","startedBuffering","finishedBuffering"],y=0,b=g.length;y<b;y++){var h=g[y],N=o.eventHandler[h];void 0===N||null===N||mejs.Utils.isObjectEmpty(N)||"function"!=typeof N.removeListener||N.removeListener(h)}if(a.length)for(var E=0,w=a.length;E<w;E++){var k=a[E];if("set"===k.type){var _=k.propName,j=""+_.substring(0,1).toUpperCase()+_.substring(1);o["set"+j](k.value)}else"call"===k.type&&o[k.methodName]()}i(["rendererready","loadeddata","canplay","progress","loadedmetadata","timeupdate"]);var B=void 0;o.eventHandler.startedPlaying=d.subscribe("startedPlaying",function(){s||(s=!0),u=!1,l=!1,i(["play","playing","timeupdate"]),B=setInterval(function(){d.getCurrentPosition(),i(["timeupdate"])},250)}),o.eventHandler.paused=d.subscribe("paused",function(){u=!0,l=!1,i(["pause"])}),o.eventHandler.finishedPlaying=d.subscribe("finishedPlaying",function(){u=!0,l=!0,i(["ended"]),clearInterval(B),B=null}),o.eventHandler.startedBuffering=d.subscribe("startedBuffering",function(){i(["progress","timeupdate"])}),o.eventHandler.finishedBuffering=d.subscribe("finishedBuffering",function(){i(["progress","timeupdate"])})}})},c=n[0].src;var N=document.createElement("div");return N.id=o.id,N.className="fb-video",N.setAttribute("data-href",c),N.setAttribute("data-allowfullscreen",!0),N.setAttribute("data-controls",!!e.originalNode.controls),e.originalNode.parentNode.insertBefore(N,e.originalNode),e.originalNode.style.display="none",r.load({options:o.options.facebook,id:o.id}),o.hide=function(){o.pause(),d&&(N.style.display="none")},o.setSize=function(e){null===d||isNaN(e)||(N.style.width=e)},o.show=function(){d&&(N.style.display="")},o.destroy=function(){f&&e.originalNode.setAttribute("poster",f)},o}};mejs.Utils.typeChecks.push(function(e){return~e.toLowerCase().indexOf("//www.facebook")?"video/x-facebook":null}),mejs.Renderers.add(i)},{}]},{},[1]);