summaryrefslogtreecommitdiffstats
path: root/wp-includes/js/mediaelement/renderers
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 07:56:49 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 07:56:49 +0000
commita415c29efee45520ae252d2aa28f1083a521cd7b (patch)
treef4ade4b6668ecc0765de7e1424f7c1427ad433ff /wp-includes/js/mediaelement/renderers
parentInitial commit. (diff)
downloadwordpress-a415c29efee45520ae252d2aa28f1083a521cd7b.tar.xz
wordpress-a415c29efee45520ae252d2aa28f1083a521cd7b.zip
Adding upstream version 6.4.3+dfsg1.upstream/6.4.3+dfsg1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'wp-includes/js/mediaelement/renderers')
-rw-r--r--wp-includes/js/mediaelement/renderers/vimeo.js432
-rw-r--r--wp-includes/js/mediaelement/renderers/vimeo.min.js12
2 files changed, 444 insertions, 0 deletions
diff --git a/wp-includes/js/mediaelement/renderers/vimeo.js b/wp-includes/js/mediaelement/renderers/vimeo.js
new file mode 100644
index 0000000..a517434
--- /dev/null
+++ b/wp-includes/js/mediaelement/renderers/vimeo.js
@@ -0,0 +1,432 @@
+/*!
+ * 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(){function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s}return e})()({1:[function(_dereq_,module,exports){
+'use strict';
+
+var VimeoApi = {
+
+ promise: null,
+
+ load: function load(settings) {
+
+ if (typeof Vimeo !== 'undefined') {
+ VimeoApi._createPlayer(settings);
+ } else {
+ VimeoApi.promise = VimeoApi.promise || mejs.Utils.loadScript('https://player.vimeo.com/api/player.js');
+ VimeoApi.promise.then(function () {
+ VimeoApi._createPlayer(settings);
+ });
+ }
+ },
+
+ _createPlayer: function _createPlayer(settings) {
+ var player = new Vimeo.Player(settings.iframe);
+ window['__ready__' + settings.id](player);
+ },
+
+ getVimeoId: function getVimeoId(url) {
+ if (url == null) {
+ return null;
+ }
+
+ var parts = url.split('?');
+ url = parts[0];
+
+ var playerLinkMatch = url.match(/https:\/\/player.vimeo.com\/video\/(\d+)$/);
+ if (playerLinkMatch) {
+ return parseInt(playerLinkMatch[1], 10);
+ }
+
+ var vimeoLinkMatch = url.match(/https:\/\/vimeo.com\/(\d+)$/);
+ if (vimeoLinkMatch) {
+ return parseInt(vimeoLinkMatch[1], 10);
+ }
+
+ var privateVimeoLinkMatch = url.match(/https:\/\/vimeo.com\/(\d+)\/\w+$/);
+ if (privateVimeoLinkMatch) {
+ return parseInt(privateVimeoLinkMatch[1], 10);
+ }
+
+ return NaN;
+ }
+};
+
+var vimeoIframeRenderer = {
+
+ name: 'vimeo_iframe',
+ options: {
+ prefix: 'vimeo_iframe'
+ },
+
+ canPlayType: function canPlayType(type) {
+ return ~['video/vimeo', 'video/x-vimeo'].indexOf(type.toLowerCase());
+ },
+
+ create: function create(mediaElement, options, mediaFiles) {
+ var apiStack = [],
+ vimeo = {},
+ readyState = 4;
+
+ var paused = true,
+ volume = 1,
+ oldVolume = volume,
+ currentTime = 0,
+ bufferedTime = 0,
+ ended = false,
+ duration = 0,
+ vimeoPlayer = null,
+ url = '';
+
+ vimeo.options = options;
+ vimeo.id = mediaElement.id + '_' + options.prefix;
+ vimeo.mediaElement = mediaElement;
+
+ var errorHandler = function errorHandler(error) {
+ mediaElement.generateError('Code ' + error.name + ': ' + error.message, mediaFiles);
+ };
+
+ var props = mejs.html5media.properties,
+ assignGettersSetters = function assignGettersSetters(propName) {
+
+ var capName = '' + propName.substring(0, 1).toUpperCase() + propName.substring(1);
+
+ vimeo['get' + capName] = function () {
+ if (vimeoPlayer !== null) {
+ var value = null;
+
+ switch (propName) {
+ case 'currentTime':
+ return currentTime;
+ case 'duration':
+ return duration;
+ case 'volume':
+ return volume;
+ case 'muted':
+ return volume === 0;
+ case 'paused':
+ return paused;
+ case 'ended':
+ return ended;
+ case 'src':
+ vimeoPlayer.getVideoUrl().then(function (_url) {
+ url = _url;
+ }).catch(function (error) {
+ return errorHandler(error);
+ });
+ return url;
+ case 'buffered':
+ return {
+ start: function start() {
+ return 0;
+ },
+ end: function end() {
+ return bufferedTime * duration;
+ },
+ length: 1
+ };
+ case 'readyState':
+ return readyState;
+ }
+ return value;
+ } else {
+ return null;
+ }
+ };
+
+ vimeo['set' + capName] = function (value) {
+ if (vimeoPlayer !== null) {
+ switch (propName) {
+ case 'src':
+ var _url2 = typeof value === 'string' ? value : value[0].src,
+ videoId = VimeoApi.getVimeoId(_url2);
+
+ vimeoPlayer.loadVideo(videoId).then(function () {
+ if (mediaElement.originalNode.autoplay) {
+ vimeoPlayer.play();
+ }
+ }).catch(function (error) {
+ return errorHandler(error);
+ });
+ break;
+ case 'currentTime':
+ vimeoPlayer.setCurrentTime(value).then(function () {
+ currentTime = value;
+ setTimeout(function () {
+ var event = mejs.Utils.createEvent('timeupdate', vimeo);
+ mediaElement.dispatchEvent(event);
+ }, 50);
+ }).catch(function (error) {
+ return errorHandler(error);
+ });
+ break;
+ case 'volume':
+ vimeoPlayer.setVolume(value).then(function () {
+ volume = value;
+ oldVolume = volume;
+ setTimeout(function () {
+ var event = mejs.Utils.createEvent('volumechange', vimeo);
+ mediaElement.dispatchEvent(event);
+ }, 50);
+ }).catch(function (error) {
+ return errorHandler(error);
+ });
+ break;
+ case 'loop':
+ vimeoPlayer.setLoop(value).catch(function (error) {
+ return errorHandler(error);
+ });
+ break;
+ case 'muted':
+ if (value) {
+ vimeoPlayer.setVolume(0).then(function () {
+ volume = 0;
+ setTimeout(function () {
+ var event = mejs.Utils.createEvent('volumechange', vimeo);
+ mediaElement.dispatchEvent(event);
+ }, 50);
+ }).catch(function (error) {
+ return errorHandler(error);
+ });
+ } else {
+ vimeoPlayer.setVolume(oldVolume).then(function () {
+ volume = oldVolume;
+ setTimeout(function () {
+ var event = mejs.Utils.createEvent('volumechange', vimeo);
+ mediaElement.dispatchEvent(event);
+ }, 50);
+ }).catch(function (error) {
+ return errorHandler(error);
+ });
+ }
+ break;
+ case 'readyState':
+ var event = mejs.Utils.createEvent('canplay', vimeo);
+ mediaElement.dispatchEvent(event);
+ break;
+ default:
+
+ break;
+ }
+ } else {
+ apiStack.push({ type: 'set', propName: propName, value: value });
+ }
+ };
+ };
+
+ for (var i = 0, total = props.length; i < total; i++) {
+ assignGettersSetters(props[i]);
+ }
+
+ var methods = mejs.html5media.methods,
+ assignMethods = function assignMethods(methodName) {
+ vimeo[methodName] = function () {
+ if (vimeoPlayer !== null) {
+ switch (methodName) {
+ case 'play':
+ paused = false;
+ return vimeoPlayer.play();
+ case 'pause':
+ paused = true;
+ return vimeoPlayer.pause();
+ case 'load':
+ return null;
+ }
+ } else {
+ apiStack.push({ type: 'call', methodName: methodName });
+ }
+ };
+ };
+
+ for (var _i = 0, _total = methods.length; _i < _total; _i++) {
+ assignMethods(methods[_i]);
+ }
+
+ window['__ready__' + vimeo.id] = function (_vimeoPlayer) {
+
+ mediaElement.vimeoPlayer = vimeoPlayer = _vimeoPlayer;
+
+ if (apiStack.length) {
+ for (var _i2 = 0, _total2 = apiStack.length; _i2 < _total2; _i2++) {
+ var stackItem = apiStack[_i2];
+
+ if (stackItem.type === 'set') {
+ var propName = stackItem.propName,
+ capName = '' + propName.substring(0, 1).toUpperCase() + propName.substring(1);
+
+ vimeo['set' + capName](stackItem.value);
+ } else if (stackItem.type === 'call') {
+ vimeo[stackItem.methodName]();
+ }
+ }
+ }
+
+ if (mediaElement.originalNode.muted) {
+ vimeoPlayer.setVolume(0);
+ volume = 0;
+ }
+
+ var vimeoIframe = document.getElementById(vimeo.id);
+ var events = void 0;
+
+ events = ['mouseover', 'mouseout'];
+
+ var assignEvents = function assignEvents(e) {
+ var event = mejs.Utils.createEvent(e.type, vimeo);
+ mediaElement.dispatchEvent(event);
+ };
+
+ for (var _i3 = 0, _total3 = events.length; _i3 < _total3; _i3++) {
+ vimeoIframe.addEventListener(events[_i3], assignEvents, false);
+ }
+
+ vimeoPlayer.on('loaded', function () {
+ vimeoPlayer.getDuration().then(function (loadProgress) {
+ duration = loadProgress;
+ if (duration > 0) {
+ bufferedTime = duration * loadProgress;
+ if (mediaElement.originalNode.autoplay) {
+ paused = false;
+ ended = false;
+ var event = mejs.Utils.createEvent('play', vimeo);
+ mediaElement.dispatchEvent(event);
+ }
+ }
+ }).catch(function (error) {
+ errorHandler(error, vimeo);
+ });
+ });
+ vimeoPlayer.on('progress', function () {
+ vimeoPlayer.getDuration().then(function (loadProgress) {
+ duration = loadProgress;
+
+ if (duration > 0) {
+ bufferedTime = duration * loadProgress;
+ if (mediaElement.originalNode.autoplay) {
+ var initEvent = mejs.Utils.createEvent('play', vimeo);
+ mediaElement.dispatchEvent(initEvent);
+
+ var playingEvent = mejs.Utils.createEvent('playing', vimeo);
+ mediaElement.dispatchEvent(playingEvent);
+ }
+ }
+
+ var event = mejs.Utils.createEvent('progress', vimeo);
+ mediaElement.dispatchEvent(event);
+ }).catch(function (error) {
+ return errorHandler(error);
+ });
+ });
+ vimeoPlayer.on('timeupdate', function () {
+ vimeoPlayer.getCurrentTime().then(function (seconds) {
+ currentTime = seconds;
+ var event = mejs.Utils.createEvent('timeupdate', vimeo);
+ mediaElement.dispatchEvent(event);
+ }).catch(function (error) {
+ return errorHandler(error);
+ });
+ });
+ vimeoPlayer.on('play', function () {
+ paused = false;
+ ended = false;
+ var event = mejs.Utils.createEvent('play', vimeo);
+ mediaElement.dispatchEvent(event);
+
+ var playingEvent = mejs.Utils.createEvent('playing', vimeo);
+ mediaElement.dispatchEvent(playingEvent);
+ });
+ vimeoPlayer.on('pause', function () {
+ paused = true;
+ ended = false;
+
+ var event = mejs.Utils.createEvent('pause', vimeo);
+ mediaElement.dispatchEvent(event);
+ });
+ vimeoPlayer.on('ended', function () {
+ paused = false;
+ ended = true;
+
+ var event = mejs.Utils.createEvent('ended', vimeo);
+ mediaElement.dispatchEvent(event);
+ });
+
+ events = ['rendererready', 'loadedmetadata', 'loadeddata', 'canplay'];
+
+ for (var _i4 = 0, _total4 = events.length; _i4 < _total4; _i4++) {
+ var event = mejs.Utils.createEvent(events[_i4], vimeo);
+ mediaElement.dispatchEvent(event);
+ }
+ };
+
+ var height = mediaElement.originalNode.height,
+ width = mediaElement.originalNode.width,
+ vimeoContainer = document.createElement('iframe'),
+ standardUrl = 'https://player.vimeo.com/video/' + VimeoApi.getVimeoId(mediaFiles[0].src);
+
+ var queryArgs = ~mediaFiles[0].src.indexOf('?') ? '?' + mediaFiles[0].src.slice(mediaFiles[0].src.indexOf('?') + 1) : '';
+ var args = [];
+
+ if (mediaElement.originalNode.autoplay && queryArgs.indexOf('autoplay') === -1) {
+ args.push('autoplay=1');
+ }
+ if (mediaElement.originalNode.loop && queryArgs.indexOf('loop') === -1) {
+ args.push('loop=1');
+ }
+
+ queryArgs = '' + queryArgs + (queryArgs ? '&' : '?') + args.join('&');
+
+ vimeoContainer.setAttribute('id', vimeo.id);
+ vimeoContainer.setAttribute('width', width);
+ vimeoContainer.setAttribute('height', height);
+ vimeoContainer.setAttribute('frameBorder', '0');
+ vimeoContainer.setAttribute('src', '' + standardUrl + queryArgs);
+ vimeoContainer.setAttribute('webkitallowfullscreen', 'true');
+ vimeoContainer.setAttribute('mozallowfullscreen', 'true');
+ vimeoContainer.setAttribute('allowfullscreen', 'true');
+ vimeoContainer.setAttribute('allow', 'autoplay');
+
+ mediaElement.originalNode.parentNode.insertBefore(vimeoContainer, mediaElement.originalNode);
+ mediaElement.originalNode.style.display = 'none';
+
+ VimeoApi.load({
+ iframe: vimeoContainer,
+ id: vimeo.id
+ });
+
+ vimeo.hide = function () {
+ vimeo.pause();
+ if (vimeoPlayer) {
+ vimeoContainer.style.display = 'none';
+ }
+ };
+ vimeo.setSize = function (width, height) {
+ vimeoContainer.setAttribute('width', width);
+ vimeoContainer.setAttribute('height', height);
+ };
+ vimeo.show = function () {
+ if (vimeoPlayer) {
+ vimeoContainer.style.display = '';
+ }
+ };
+
+ vimeo.destroy = function () {};
+
+ return vimeo;
+ }
+};
+
+mejs.Utils.typeChecks.push(function (url) {
+ return (/(\/\/player\.vimeo|vimeo\.com)/i.test(url) ? 'video/x-vimeo' : null
+ );
+});
+
+mejs.Renderers.add(vimeoIframeRenderer);
+
+},{}]},{},[1]);
diff --git a/wp-includes/js/mediaelement/renderers/vimeo.min.js b/wp-includes/js/mediaelement/renderers/vimeo.min.js
new file mode 100644
index 0000000..fa958f6
--- /dev/null
+++ b/wp-includes/js/mediaelement/renderers/vimeo.min.js
@@ -0,0 +1,12 @@
+/*!
+ * 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 a(o,s,u){function c(n,e){if(!s[n]){if(!o[n]){var t="function"==typeof require&&require;if(!e&&t)return t(n,!0);if(l)return l(n,!0);var r=new Error("Cannot find module '"+n+"'");throw r.code="MODULE_NOT_FOUND",r}var i=s[n]={exports:{}};o[n][0].call(i.exports,function(e){var t=o[n][1][e];return c(t||e)},i,i.exports,a,o,s,u)}return s[n].exports}for(var l="function"==typeof require&&require,e=0;e<u.length;e++)c(u[e]);return c}({1:[function(e,t,n){"use strict";var T={promise:null,load:function(e){"undefined"!=typeof Vimeo?T._createPlayer(e):(T.promise=T.promise||mejs.Utils.loadScript("https://player.vimeo.com/api/player.js"),T.promise.then(function(){T._createPlayer(e)}))},_createPlayer:function(e){var t=new Vimeo.Player(e.iframe);window["__ready__"+e.id](t)},getVimeoId:function(e){if(null==e)return null;var t=(e=e.split("?")[0]).match(/https:\/\/player.vimeo.com\/video\/(\d+)$/);if(t)return parseInt(t[1],10);var n=e.match(/https:\/\/vimeo.com\/(\d+)$/);if(n)return parseInt(n[1],10);var r=e.match(/https:\/\/vimeo.com\/(\d+)\/\w+$/);return r?parseInt(r[1],10):NaN}},r={name:"vimeo_iframe",options:{prefix:"vimeo_iframe"},canPlayType:function(e){return~["video/vimeo","video/x-vimeo"].indexOf(e.toLowerCase())},create:function(f,e,t){var v=[],h={},y=!0,g=1,a=g,E=0,j=0,U=!1,b=0,w=null,n="";h.options=e,h.id=f.id+"_"+e.prefix,h.mediaElement=f;for(var N=function(e){f.generateError("Code "+e.name+": "+e.message,t)},r=mejs.html5media.properties,i=function(i){var e=""+i.substring(0,1).toUpperCase()+i.substring(1);h["get"+e]=function(){if(null!==w){switch(i){case"currentTime":return E;case"duration":return b;case"volume":return g;case"muted":return 0===g;case"paused":return y;case"ended":return U;case"src":return w.getVideoUrl().then(function(e){n=e}).catch(function(e){return N(e)}),n;case"buffered":return{start:function(){return 0},end:function(){return j*b},length:1};case"readyState":return 4}return null}return null},h["set"+e]=function(e){if(null!==w)switch(i){case"src":var t="string"==typeof e?e:e[0].src,n=T.getVimeoId(t);w.loadVideo(n).then(function(){f.originalNode.autoplay&&w.play()}).catch(function(e){return N(e)});break;case"currentTime":w.setCurrentTime(e).then(function(){E=e,setTimeout(function(){var e=mejs.Utils.createEvent("timeupdate",h);f.dispatchEvent(e)},50)}).catch(function(e){return N(e)});break;case"volume":w.setVolume(e).then(function(){a=g=e,setTimeout(function(){var e=mejs.Utils.createEvent("volumechange",h);f.dispatchEvent(e)},50)}).catch(function(e){return N(e)});break;case"loop":w.setLoop(e).catch(function(e){return N(e)});break;case"muted":e?w.setVolume(0).then(function(){g=0,setTimeout(function(){var e=mejs.Utils.createEvent("volumechange",h);f.dispatchEvent(e)},50)}).catch(function(e){return N(e)}):w.setVolume(a).then(function(){g=a,setTimeout(function(){var e=mejs.Utils.createEvent("volumechange",h);f.dispatchEvent(e)},50)}).catch(function(e){return N(e)});break;case"readyState":var r=mejs.Utils.createEvent("canplay",h);f.dispatchEvent(r)}else v.push({type:"set",propName:i,value:e})}},o=0,s=r.length;o<s;o++)i(r[o]);for(var u=mejs.html5media.methods,c=function(e){h[e]=function(){if(null!==w)switch(e){case"play":return y=!1,w.play();case"pause":return y=!0,w.pause();case"load":return null}else v.push({type:"call",methodName:e})}},l=0,d=u.length;l<d;l++)c(u[l]);window["__ready__"+h.id]=function(e){if(f.vimeoPlayer=w=e,v.length)for(var t=0,n=v.length;t<n;t++){var r=v[t];if("set"===r.type){var i=r.propName,a=""+i.substring(0,1).toUpperCase()+i.substring(1);h["set"+a](r.value)}else"call"===r.type&&h[r.methodName]()}f.originalNode.muted&&(w.setVolume(0),g=0);for(var o=document.getElementById(h.id),s=void 0,u=function(e){var t=mejs.Utils.createEvent(e.type,h);f.dispatchEvent(t)},c=0,l=(s=["mouseover","mouseout"]).length;c<l;c++)o.addEventListener(s[c],u,!1);w.on("loaded",function(){w.getDuration().then(function(e){if(0<(b=e)&&(j=b*e,f.originalNode.autoplay)){U=y=!1;var t=mejs.Utils.createEvent("play",h);f.dispatchEvent(t)}}).catch(function(e){N(e)})}),w.on("progress",function(){w.getDuration().then(function(e){if(0<(b=e)&&(j=b*e,f.originalNode.autoplay)){var t=mejs.Utils.createEvent("play",h);f.dispatchEvent(t);var n=mejs.Utils.createEvent("playing",h);f.dispatchEvent(n)}var r=mejs.Utils.createEvent("progress",h);f.dispatchEvent(r)}).catch(function(e){return N(e)})}),w.on("timeupdate",function(){w.getCurrentTime().then(function(e){E=e;var t=mejs.Utils.createEvent("timeupdate",h);f.dispatchEvent(t)}).catch(function(e){return N(e)})}),w.on("play",function(){U=y=!1;var e=mejs.Utils.createEvent("play",h);f.dispatchEvent(e);var t=mejs.Utils.createEvent("playing",h);f.dispatchEvent(t)}),w.on("pause",function(){y=!0,U=!1;var e=mejs.Utils.createEvent("pause",h);f.dispatchEvent(e)}),w.on("ended",function(){y=!1,U=!0;var e=mejs.Utils.createEvent("ended",h);f.dispatchEvent(e)});for(var d=0,p=(s=["rendererready","loadedmetadata","loadeddata","canplay"]).length;d<p;d++){var m=mejs.Utils.createEvent(s[d],h);f.dispatchEvent(m)}};var p=f.originalNode.height,m=f.originalNode.width,_=document.createElement("iframe"),x="https://player.vimeo.com/video/"+T.getVimeoId(t[0].src),A=~t[0].src.indexOf("?")?"?"+t[0].src.slice(t[0].src.indexOf("?")+1):"",V=[];return f.originalNode.autoplay&&-1===A.indexOf("autoplay")&&V.push("autoplay=1"),f.originalNode.loop&&-1===A.indexOf("loop")&&V.push("loop=1"),A=A+(A?"&":"?")+V.join("&"),_.setAttribute("id",h.id),_.setAttribute("width",m),_.setAttribute("height",p),_.setAttribute("frameBorder","0"),_.setAttribute("src",""+x+A),_.setAttribute("webkitallowfullscreen","true"),_.setAttribute("mozallowfullscreen","true"),_.setAttribute("allowfullscreen","true"),_.setAttribute("allow","autoplay"),f.originalNode.parentNode.insertBefore(_,f.originalNode),f.originalNode.style.display="none",T.load({iframe:_,id:h.id}),h.hide=function(){h.pause(),w&&(_.style.display="none")},h.setSize=function(e,t){_.setAttribute("width",e),_.setAttribute("height",t)},h.show=function(){w&&(_.style.display="")},h.destroy=function(){},h}};mejs.Utils.typeChecks.push(function(e){return/(\/\/player\.vimeo|vimeo\.com)/i.test(e)?"video/x-vimeo":null}),mejs.Renderers.add(r)},{}]},{},[1]); \ No newline at end of file