Skip to content
Snippets Groups Projects
Commit 7f7b2a3d authored by Florian Gnägi's avatar Florian Gnägi
Browse files

OO-4380 Supportfor Vimeo videos shared as "Private link", hide controls

parent 17dbe5f2
No related branches found
No related tags found
No related merge requests found
......@@ -19,12 +19,14 @@
*/
package org.olat.modules.video.ui;
import java.net.URISyntaxException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.apache.http.client.utils.URIBuilder;
import org.olat.core.commons.services.commentAndRating.CommentAndRatingDefaultSecurityCallback;
import org.olat.core.commons.services.commentAndRating.CommentAndRatingSecurityCallback;
import org.olat.core.commons.services.commentAndRating.ReadOnlyCommentsSecurityCallback;
......@@ -348,6 +350,28 @@ public class VideoDisplayController extends BasicController {
}
private void loadVideo(UserRequest ureq, String url, VideoFormat format) {
mainVC.contextPut("externalUrlOriginal", url);
URIBuilder uriBuilder;
try {
uriBuilder = new URIBuilder(url);
// Check if this is a vimeo video
if (uriBuilder.getHost().indexOf("vimeo") != -1) {
// Vimeo allows removing the controls when using the payed service. It ignores the parameter
// for the free service, so it is save to use it. We use the URIBuilder method in case the
// user already added that parameter or if he uses some other parameters
uriBuilder.setParameter("controls", "0");
// Check if this is a Vimeo with the settings "Only people with the private link". In this case
// the second parameter needs to be removed for mediaelementjs to work properly.
// Example: https://vimeo.com/123922956/05ad0e2cbf
if (uriBuilder.getPathSegments().size() == 2) {
uriBuilder.setPath(uriBuilder.getPathSegments().get(0));
}
url = uriBuilder.build().toString();
}
} catch (URISyntaxException e) {
logWarn("Error while parsing URL from external video source URL::" + url, e);
}
mainVC.contextPut("externalUrl", url);
mainVC.contextPut("sourceType", format.mimeType());
......
......@@ -52,6 +52,16 @@
},
#end
## Set JS callback to retreive user selected video url or fixed url for external services that can not be changed.
## Triggers error for Vimeo private URLs otherwise
#if($r.isNotEmpty($externalUrlOriginal))
#set($mediaSrc = "'$externalUrlOriginal'")
#else
#set($mediaSrc = "mediaElement.src")
#end
## Callback to communicate with the server
success: function (mediaElement, domObject, player) {
jQuery('#$r.getId("o_vid")').data('player', player);
......@@ -60,19 +70,19 @@
## listen to play events, fired when movie is finished
mediaElement.addEventListener('play', function(e) {
if (!o_info.linkbusy) {
$r.openNoResponseJavaScriptCommand("play"), 'currentTime', mediaElement.currentTime, 'src', mediaElement.src, 'duration', mediaElement.duration);
$r.openNoResponseJavaScriptCommand("play"), 'currentTime', mediaElement.currentTime, 'src', $mediaSrc, 'duration', mediaElement.duration);
}
}, false);
## listen to pause events, fired when movie is paused by user
mediaElement.addEventListener('pause', function(e) {
if (!o_info.linkbusy) {
$r.openNoResponseJavaScriptCommand("pause"), 'currentTime', mediaElement.currentTime, 'src', mediaElement.src, 'duration', mediaElement.duration);
$r.openNoResponseJavaScriptCommand("pause"), 'currentTime', mediaElement.currentTime, 'src', $mediaSrc, 'duration', mediaElement.duration);
}
}, false);
## listen to seeked events, fired when user uses the slider in the movie
mediaElement.addEventListener('seeked', function(e) {
if (!o_info.linkbusy) {
$r.openNoResponseJavaScriptCommand("seeked"), 'currentTime', mediaElement.currentTime, 'src', mediaElement.src, 'duration', mediaElement.duration);
$r.openNoResponseJavaScriptCommand("seeked"), 'currentTime', mediaElement.currentTime, 'src', $mediaSrc, 'duration', mediaElement.duration);
}
}, false);
......@@ -80,7 +90,7 @@
mediaElement.addEventListener('timeupdate', function(e) {
#if($r.isTrue($listenTimeUpdate))
if (!o_info.linkbusy) {
$r.openNoResponseJavaScriptCommand("timeupdate"), 'currentTime', mediaElement.currentTime, 'src', mediaElement.src, 'duration', mediaElement.duration);
$r.openNoResponseJavaScriptCommand("timeupdate"), 'currentTime', mediaElement.currentTime, 'src', $mediaSrc, 'duration', mediaElement.duration);
}
#end
if(jQuery('#$r.getId("o_vid")').length == 0) {
......@@ -96,7 +106,7 @@
## listen to end events, fired when movie is finished
mediaElement.addEventListener('ended', function(e) {
if (!o_info.linkbusy) {
$r.openNoResponseJavaScriptCommand("ended"), 'currentTime', mediaElement.currentTime, 'src', mediaElement.src, 'duration', mediaElement.duration);
$r.openNoResponseJavaScriptCommand("ended"), 'currentTime', mediaElement.currentTime, 'src', $sourcesSrc, 'duration', mediaElement.duration);
}
}, false);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment