WordPress/wp-includes/js/mediaelement/renderers/soundcloud.min.js

12 lines
4.4 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 a(s,o){if(!n[s]){if(!t[s]){var u="function"==typeof require&&require;if(!o&&u)return u(s,!0);if(i)return i(s,!0);var c=new Error("Cannot find module '"+s+"'");throw c.code="MODULE_NOT_FOUND",c}var d=n[s]={exports:{}};t[s][0].call(d.exports,function(e){var n=t[s][1][e];return a(n||e)},d,d.exports,e,t,n,r)}return n[s].exports}for(var i="function"==typeof require&&require,s=0;s<r.length;s++)a(r[s]);return a}({1:[function(e,t,n){"use strict";var r={promise:null,load:function(e){"undefined"!=typeof SC?r._createPlayer(e):(r.promise=r.promise||mejs.Utils.loadScript("https://w.soundcloud.com/player/api.js"),r.promise.then(function(){r._createPlayer(e)}))},_createPlayer:function(e){var t=SC.Widget(e.iframe);window["__ready__"+e.id](t)}},a={name:"soundcloud_iframe",options:{prefix:"soundcloud_iframe"},canPlayType:function(e){return~["video/soundcloud","video/x-soundcloud"].indexOf(e.toLowerCase())},create:function(e,t,n){var a={},i=[],s=e.originalNode.autoplay,o=0,u=0,c=0,d=!0,l=!1,p=null,f=null;a.options=t,a.id=e.id+"_"+t.prefix,a.mediaElement=e;for(var v=mejs.html5media.properties,m=0,h=v.length;m<h;m++)!function(t){var n=""+t.substring(0,1).toUpperCase()+t.substring(1);a["get"+n]=function(){if(null!==p){switch(t){case"currentTime":return u;case"duration":return o;case"volume":return 1;case"paused":return d;case"ended":return l;case"muted":return!1;case"buffered":return{start:function(){return 0},end:function(){return c*o},length:1};case"src":return f?f.src:"";case"readyState":return 4}return null}return null},a["set"+n]=function(n){if(null!==p)switch(t){case"src":var r="string"==typeof n?n:n[0].src;p.load(r),s&&p.play();break;case"currentTime":p.seekTo(1e3*n);break;case"muted":n?p.setVolume(0):p.setVolume(1),setTimeout(function(){var t=mejs.Utils.createEvent("volumechange",a);e.dispatchEvent(t)},50);break;case"volume":p.setVolume(n),setTimeout(function(){var t=mejs.Utils.createEvent("volumechange",a);e.dispatchEvent(t)},50);break;case"readyState":var o=mejs.Utils.createEvent("canplay",a);e.dispatchEvent(o)}else i.push({type:"set",propName:t,value:n})}}(v[m]);for(var y=mejs.html5media.methods,E=0,g=y.length;E<g;E++)!function(e){a[e]=function(){if(null!==p)switch(e){case"play":return p.play();case"pause":return p.pause();case"load":return null}else i.push({type:"call",methodName:e})}}(y[E]);window["__ready__"+a.id]=function(t){if(e.scPlayer=p=t,s&&p.play(),i.length)for(var n=0,r=i.length;n<r;n++){var f=i[n];if("set"===f.type){var v=f.propName,m=""+v.substring(0,1).toUpperCase()+v.substring(1);a["set"+m](f.value)}else"call"===f.type&&a[f.methodName]()}p.bind(SC.Widget.Events.PLAY_PROGRESS,function(){d=!1,l=!1,p.getPosition(function(t){u=t/1e3;var n=mejs.Utils.createEvent("timeupdate",a);e.dispatchEvent(n)})}),p.bind(SC.Widget.Events.PAUSE,function(){d=!0;var t=mejs.Utils.createEvent("pause",a);e.dispatchEvent(t)}),p.bind(SC.Widget.Events.PLAY,function(){d=!1,l=!1;var t=mejs.Utils.createEvent("play",a);e.dispatchEvent(t)}),p.bind(SC.Widget.Events.FINISHED,function(){d=!1,l=!0;var t=mejs.Utils.createEvent("ended",a);e.dispatchEvent(t)}),p.bind(SC.Widget.Events.READY,function(){p.getDuration(function(t){o=t/1e3;var n=mejs.Utils.createEvent("loadedmetadata",a);e.dispatchEvent(n)})}),p.bind(SC.Widget.Events.LOAD_PROGRESS,function(){p.getDuration(function(t){if(o>0){c=o*t;var n=mejs.Utils.createEvent("progress",a);e.dispatchEvent(n)}}),p.getDuration(function(t){o=t;var n=mejs.Utils.createEvent("loadedmetadata",a);e.dispatchEvent(n)})});for(var h=["rendererready","loadeddata","loadedmetadata","canplay"],y=0,E=h.length;y<E;y++){var g=mejs.Utils.createEvent(h[y],a);e.dispatchEvent(g)}},(f=document.createElement("iframe")).id=a.id,f.width=10,f.height=10,f.frameBorder=0,f.style.visibility="hidden",f.src=n[0].src,f.scrolling="no",e.appendChild(f),e.originalNode.style.display="none";var S={iframe:f,id:a.id};return r.load(S),a.setSize=function(){},a.hide=function(){a.pause(),f&&(f.style.display="none")},a.show=function(){f&&(f.style.display="")},a.destroy=function(){p.destroy()},a}};mejs.Utils.typeChecks.push(function(e){return/\/\/(w\.)?soundcloud.com/i.test(e)?"video/x-soundcloud":null}),mejs.Renderers.add(a)},{}]},{},[1]);