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

12 lines
5.9 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,a){function i(s,o){if(!n[s]){if(!t[s]){var d="function"==typeof require&&require;if(!o&&d)return d(s,!0);if(r)return r(s,!0);var u=new Error("Cannot find module '"+s+"'");throw u.code="MODULE_NOT_FOUND",u}var l=n[s]={exports:{}};t[s][0].call(l.exports,function(e){var n=t[s][1][e];return i(n||e)},l,l.exports,e,t,n,a)}return n[s].exports}for(var r="function"==typeof require&&require,s=0;s<a.length;s++)i(a[s]);return i}({1:[function(e,t,n){"use strict";var a={isSDKStarted:!1,isSDKLoaded:!1,iframeQueue:[],enqueueIframe:function(e){a.isLoaded?a.createIframe(e):(a.loadIframeApi(),a.iframeQueue.push(e))},loadIframeApi:function(){a.isSDKStarted||(mejs.Utils.loadScript("https://api.dmcdn.net/all.js"),a.isSDKStarted=!0)},apiReady:function(){for(a.isLoaded=!0,a.isSDKLoaded=!0;a.iframeQueue.length>0;){var e=a.iframeQueue.pop();DM.init({apiKey:e.apiKey,status:e.status,cookie:e.cookie}),a.createIframe(e)}},createIframe:function(e){var t=DM.player(e.container,{height:e.height||"100%",width:e.width||"100%",video:e.videoId,params:Object.assign({api:!0},e.params),origin:location.host});t.addEventListener("apiready",function(){window["__ready__"+e.id](t,{paused:!0,ended:!1})})},getDailyMotionId:function(e){var t=e.split("/");return t[t.length-1].split("_")[0]}},i={name:"dailymotion_iframe",options:{prefix:"dailymotion_iframe",dailymotion:{width:"100%",height:"100%",params:{autoplay:!1,chromeless:1,info:0,logo:0,related:0},apiKey:null,status:!0,cookie:!0}},canPlayType:function(e){return~["video/dailymotion","video/x-dailymotion"].indexOf(e.toLowerCase())},create:function(e,t,n){var i={},r=[],s=void 0,o=null,d=null;i.options=t,i.id=e.id+"_"+t.prefix,i.mediaElement=e;for(var u=mejs.html5media.properties,l=0,c=u.length;l<c;l++)!function(t){var n=""+t.substring(0,1).toUpperCase()+t.substring(1);i["get"+n]=function(){if(null!==o){switch(t){case"currentTime":return o.currentTime;case"duration":return isNaN(o.duration)?0:o.duration;case"volume":return o.volume;case"paused":return o.paused;case"ended":return o.ended;case"muted":return o.muted;case"buffered":var n=o.bufferedTime,a=o.duration;return{start:function(){return 0},end:function(){return n/a},length:1};case"src":return e.originalNode.getAttribute("src");case"readyState":return 4}return null}return null},i["set"+n]=function(n){if(null!==o)switch(t){case"src":var s="string"==typeof n?n:n[0].src;o.load(a.getDailyMotionId(s));break;case"currentTime":o.seek(n);break;case"muted":o.setMuted(n),setTimeout(function(){var t=mejs.Utils.createEvent("volumechange",i);e.dispatchEvent(t)},50);break;case"volume":o.setVolume(n),setTimeout(function(){var t=mejs.Utils.createEvent("volumechange",i);e.dispatchEvent(t)},50);break;case"readyState":var d=mejs.Utils.createEvent("canplay",i);e.dispatchEvent(d)}else r.push({type:"set",propName:t,value:n})}}(u[l]);for(var m=mejs.html5media.methods,p=0,v=m.length;p<v;p++)!function(e){i[e]=function(){if(null!==o)switch(e){case"play":return o.play();case"pause":return o.pause();case"load":return null}else r.push({type:"call",methodName:e})}}(m[p]);window["__ready__"+i.id]=function(t){if(e.dmPlayer=o=t,r.length)for(var n=0,a=r.length;n<a;n++){var u=r[n];if("set"===u.type){var l=u.propName,c=""+l.substring(0,1).toUpperCase()+l.substring(1);i["set"+c](u.value)}else"call"===u.type&&i[u.methodName]()}d=document.getElementById(i.id);for(var m=0,p=(s=["mouseover","mouseout"]).length;m<p;m++)d.addEventListener(s[m],function(t){var n=mejs.Utils.createEvent(t.type,i);e.dispatchEvent(n)},!1);e.originalNode.muted&&(o.setMuted(!0),o.setVolume(0)),s=mejs.html5media.events;for(var v=0,f=(s=s.concat(["click","mouseover","mouseout"])).length;v<f;v++)!function(t){"ended"!==t&&o.addEventListener(t,function(t){var n=mejs.Utils.createEvent(t.type,o);e.dispatchEvent(n)})}(s[v]);o.addEventListener("ad_start",function(){var t=mejs.Utils.createEvent("play",o);e.dispatchEvent(t),t=mejs.Utils.createEvent("progress",o),e.dispatchEvent(t),t=mejs.Utils.createEvent("timeupdate",o),e.dispatchEvent(t)}),o.addEventListener("ad_timeupdate",function(){var t=mejs.Utils.createEvent("timeupdate",o);e.dispatchEvent(t)}),o.addEventListener("ad_pause",function(){var t=mejs.Utils.createEvent("pause",o);e.dispatchEvent(t)}),o.addEventListener("ad_end",function(){var t=mejs.Utils.createEvent("ended",o);e.dispatchEvent(t)}),o.addEventListener("start",function(){e.originalNode.muted&&o.setMuted(!0)}),o.addEventListener("video_start",function(){var t=mejs.Utils.createEvent("play",o);e.dispatchEvent(t)}),o.addEventListener("ad_timeupdate",function(){var t=mejs.Utils.createEvent("timeupdate",o);e.dispatchEvent(t)}),o.addEventListener("video_end",function(){var t=mejs.Utils.createEvent("ended",o);e.dispatchEvent(t),e.originalNode.getAttribute("loop")&&o.play()});for(var h=["rendererready","loadedmetadata","loadeddata","canplay"],y=0,g=h.length;y<g;y++){var E=mejs.Utils.createEvent(h[y],i);e.dispatchEvent(E)}};var f=document.createElement("div");f.id=i.id,e.appendChild(f),e.originalNode&&(f.style.width=e.originalNode.style.width,f.style.height=e.originalNode.style.height),e.originalNode.style.display="none";var h=a.getDailyMotionId(n[0].src),y=Object.assign({id:i.id,container:f,videoId:h},i.options.dailymotion);return e.originalNode.autoplay&&(y.params.autoplay=!0),e.originalNode.muted&&(y.params.mute=!0),a.enqueueIframe(y),i.hide=function(){i.pause(),d&&(d.style.display="none")},i.show=function(){d&&(d.style.display="")},i.setSize=function(e,t){d&&(d.width=e,d.height=t)},i.destroy=function(){o.destroy()},i}};mejs.Utils.typeChecks.push(function(e){return/\/\/((www\.)?dailymotion\.com|dai\.ly)/i.test(e)?"video/x-dailymotion":null}),window.dmAsyncInit=function(){a.apiReady()},mejs.Renderers.add(i)},{}]},{},[1]);