Commit ac9ef2a5 authored by Rodriguez Nyiringabo's avatar Rodriguez Nyiringabo Committed by luci
Browse files

[FIX][REM] PluginVimeo: Remove Vimeo froogaloop dependency (library) and its...

[FIX][REM] PluginVimeo: Remove Vimeo froogaloop dependency (library) and its use in the plugin Vimeo because it's no longer supported by Vimeo and no longer necessary to play standard Vimeo videos in a wiki page
parent 53b0eb52
Pipeline #502272828 passed with stages
in 14 minutes and 9 seconds
(function(){
// Listen for the ready event for any vimeo video players on the page
var vimeoPlayers = document.querySelectorAll('iframe'),
player;
for (var i = 0, length = vimeoPlayers.length; i < length; i++) {
player = vimeoPlayers[i];
$f(player).addEvent('ready', ready);
}
/**
* Utility function for adding an event. Handles the inconsistencies
* between the W3C method for adding events (addEventListener) and
* IE's (attachEvent).
*/
function addEvent(element, eventName, callback) {
if (element.addEventListener) {
element.addEventListener(eventName, callback, false);
}
else {
element.attachEvent(eventName, callback, false);
}
}
/**
* Called once a vimeo player is loaded and ready to receive
* commands. You can add events and make api calls only after this
* function has been called.
*/
function ready(player_id) {
// Keep a reference to Froogaloop for this player
froogaloop = $f(player_id);
/**
* Adds listeners for the events that are checked. Adding an event
* through Froogaloop requires the event name and the callback method
* that is called once the event fires.
*/
function setupEventListeners() {
function onPlayProgress() {
var inc = 0;
froogaloop.addEvent('playProgress', function(data, pid) {
if(data.percent.toFixed(2) != inc && (data.percent.toFixed(2) == 0.20 || data.percent.toFixed(2) == 0.40 || data.percent.toFixed(2) == 0.60 || data.percent.toFixed(2) == 0.80)) {
inc = data.percent.toFixed(2);
post_player_info(data, pid, 'play', 'playProgress');
}
});
}
function onPlay() {
froogaloop.addEvent('play', function(data) {
calculate(data, 'play', 'play');
});
}
function onPause() {
froogaloop.addEvent('pause', function(data) {
calculate(data, 'pause', 'pause');
});
}
function onFinish() {
froogaloop.addEvent('finish', function(data) {
calculate(data, 'finish', 'finish');
});
}
function onSeek() {
froogaloop.addEvent('seek', function(data, player_id) {
calculate(player_id, 'seek', 'seek', data);
});
}
function calculate(player_id, action, eventname, seekdata) {
froogaloops = $f(player_id);
froogaloops.api('getCurrentTime', function (value) {
froogaloops.api('getDuration', function (value1) {
var dataplay = new Object();
dataplay.seconds = parseFloat(value);
temptime = value/value1;
dataplay.percent = parseFloat(temptime.toFixed(3));
dataplay.duration = parseFloat(value1);
if(eventname == 'seek') {
dataplay.secondsto = parseFloat(seekdata.seconds);
dataplay.percentto = parseFloat(seekdata.percent);
dataplay.durationto = parseFloat(seekdata.duration);
}
post_player_info(dataplay, player_id, action, eventname);
});
});
}
//onLoadProgress();
onPlayProgress();
onPlay();
onPause();
onFinish();
onSeek();
}
function post_player_info(data, cid, action, eventname){
$.post('tiki-vimeo-track_'+action, {eventname: eventname, playerId: cid,fileId: $("#"+cid).data('fileid'), url: $("#"+cid).attr('src').split("?")[0], time: JSON.stringify(data)});
}
setupEventListeners();
}
})();
\ No newline at end of file
......@@ -113,20 +113,6 @@ function wikiplugin_vimeo_info()
'filter' => 'int',
'advanced' => true
],
'useFroogaloopApi' => [
'required' => false,
'name' => tra('Froogaloop API'),
'description' => tra('Use Vimeo Froogaloop API'),
'since' => '14.0',
'filter' => 'alpha',
'options' => [
['text' => '', 'value' => ''],
['text' => tra('Yes'), 'value' => 'true'],
['text' => tra('No'), 'value' => 'false'],
],
'default' => '',
'advanced' => true,
],
'showTitle' => [
'required' => false,
'name' => tra('Show Title'),
......@@ -221,19 +207,12 @@ function wikiplugin_vimeo($data, $params)
static $instance = 0;
$instance++;
if ($params['useFroogaloopApi']) {
TikiLib::lib('header')->add_jsfile('vendor_bundled/vendor/vimeo/froogaloop/javascript/froogaloop.min.js', true);
TikiLib::lib('header')->add_jsfile('lib/jquery_tiki/tiki-vimeo.js');
}
if (isset($params['url'])) {
$params['vimeo'] = $params['url'];
$params['player_id'] = "pid_" . uniqid();
$params['vimeo_fileId'] = 0;
unset($params['url']);
if ($params['useFroogaloopApi']) {
$params['vimeo'] .= "?api=1&player_id=" . $params['player_id'];
}
return vimeo_iframe($data, $params);
} elseif (isset($params['fileId'])) {
$fileIds = preg_split('/\D+/', $params['fileId'], -1, PREG_SPLIT_NO_EMPTY);
......@@ -247,9 +226,6 @@ function wikiplugin_vimeo($data, $params)
$params['vimeo'] = $attributes['tiki.content.url'];
$params['player_id'] = "pid_" . uniqid();
$params['vimeo_fileId'] = $fileId;
if ($params['useFroogaloopApi']) {
$params['vimeo'] .= "?api=1&player_id=" . $params['player_id'];
}
$out .= vimeo_iframe($data, $params);
} else {
Feedback::error(tr('Vimeo video not found for file #%0', $fileId));
......
......@@ -154,7 +154,6 @@
"tikiwiki/ilp-client": "^1.0",
"twbs/bootstrap": "^4.1",
"undojs/undojs": "1",
"vimeo/froogaloop": "1.0",
"zbateson/mail-mime-parser": "^1.3.1",
"zendframework/zendservice-akismet": "~2.0",
"gidkom/php-openfire-restapi": "dev-master",
......
......@@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "e31ae963ded19495627cf88b1d98e9a7",
"content-hash": "31cbc9b12bfd71d82c99ec3121296884",
"packages": [
{
"name": "Sam152/Javascript-Equal-Height-Responsive-Rows",
......@@ -11259,16 +11259,6 @@
},
"type": "library"
},
{
"name": "vimeo/froogaloop",
"version": "1.0",
"dist": {
"type": "zip",
"url": "https://composer.tiki.org/dist/vimeo/froogaloop/vimeo-froogaloop-1.0.zip",
"shasum": "4cf4e5ca02b2a79c58f02b08c50164ecb8164bef"
},
"type": "library"
},
{
"name": "voku/portable-ascii",
"version": "1.5.6",
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment