X-Git-Url: http://git.cyclocoop.org/?a=blobdiff_plain;f=www%2Fplugins-dist%2Fmedias%2Flib%2Fmejs%2Frenderers%2Fvimeo.js;fp=www%2Fplugins-dist%2Fmedias%2Flib%2Fmejs%2Frenderers%2Fvimeo.js;h=a28524d33d6ef333e6db2168c78119d2854fbafa;hb=4f443dce95ff6f8221c189880a70c74ce1c1f238;hp=0000000000000000000000000000000000000000;hpb=4a628e9b277d3617535f99d663ca79fa2e891177;p=lhc%2Fweb%2Fwww.git diff --git a/www/plugins-dist/medias/lib/mejs/renderers/vimeo.js b/www/plugins-dist/medias/lib/mejs/renderers/vimeo.js new file mode 100644 index 00000000..a28524d3 --- /dev/null +++ b/www/plugins-dist/medias/lib/mejs/renderers/vimeo.js @@ -0,0 +1,405 @@ +/*! + * 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 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 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 event = mejs.Utils.createEvent('progress', vimeo); + mediaElement.dispatchEvent(event); + }).catch(function (error) { + errorHandler(error, vimeo); + }); + }); + vimeoPlayer.on('timeupdate', function () { + vimeoPlayer.getCurrentTime().then(function (seconds) { + currentTime = seconds; + + var event = mejs.Utils.createEvent('timeupdate', vimeo); + mediaElement.dispatchEvent(event); + }).catch(function (error) { + errorHandler(error, vimeo); + }); + }); + vimeoPlayer.on('play', function () { + paused = false; + ended = false; + var event = mejs.Utils.createEvent('play', vimeo); + mediaElement.dispatchEvent(event); + }); + 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) : ''; + if (queryArgs && mediaElement.originalNode.autoplay && queryArgs.indexOf('autoplay') === -1) { + queryArgs += '&autoplay=1'; + } + if (queryArgs && mediaElement.originalNode.loop && queryArgs.indexOf('loop') === -1) { + queryArgs += '&loop=1'; + } + + 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', ''); + vimeoContainer.setAttribute('mozallowfullscreen', ''); + vimeoContainer.setAttribute('allowfullscreen', ''); + + 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]);