From 51df8e25b0d5d9b1e68a3026e54a69368f20894e Mon Sep 17 00:00:00 2001
From: uhensler <urs.hensler@frentix.com>
Date: Mon, 3 Jun 2019 14:28:12 +0200
Subject: [PATCH] OO-4043: Show custom message if live stream is not available

---
 .../ui/LiveStreamVideoController.java         | 41 +++++++++++++++----
 .../nodes/livestream/ui/_content/video.html   | 14 +++++--
 .../nodes/livestream/ui/_content/viewer.html  |  2 +-
 .../ui/_i18n/LocalStrings_de.properties       |  2 +
 .../ui/_i18n/LocalStrings_en.properties       |  2 +
 src/main/webapp/static/movie/player.js        | 14 +++++--
 src/main/webapp/static/movie/player.min.js    |  2 +-
 7 files changed, 59 insertions(+), 18 deletions(-)

diff --git a/src/main/java/org/olat/course/nodes/livestream/ui/LiveStreamVideoController.java b/src/main/java/org/olat/course/nodes/livestream/ui/LiveStreamVideoController.java
index 7e70902eec6..2035525f278 100644
--- a/src/main/java/org/olat/course/nodes/livestream/ui/LiveStreamVideoController.java
+++ b/src/main/java/org/olat/course/nodes/livestream/ui/LiveStreamVideoController.java
@@ -19,12 +19,16 @@
  */
 package org.olat.course.nodes.livestream.ui;
 
+import org.apache.logging.log4j.Logger;
 import org.olat.core.gui.UserRequest;
 import org.olat.core.gui.components.Component;
+import org.olat.core.gui.components.link.Link;
+import org.olat.core.gui.components.link.LinkFactory;
 import org.olat.core.gui.components.velocity.VelocityContainer;
 import org.olat.core.gui.control.Event;
 import org.olat.core.gui.control.WindowControl;
 import org.olat.core.gui.control.controller.BasicController;
+import org.olat.core.logging.Tracing;
 import org.olat.core.util.CodeHelper;
 import org.olat.core.util.StringHelper;
 import org.olat.course.nodes.livestream.LiveStreamEvent;
@@ -36,27 +40,39 @@ import org.olat.course.nodes.livestream.LiveStreamEvent;
  *
  */
 public class LiveStreamVideoController extends BasicController {
+
+	private static final Logger log = Tracing.createLoggerFor(LiveStreamVideoController.class);
 	
 	private final VelocityContainer mainVC;
+	private Link retryLink;
 	
-	private String runningUrl;
+	private String url;
+	private boolean error = false;
 
 	protected LiveStreamVideoController(UserRequest ureq, WindowControl wControl) {
 		super(ureq, wControl);
 		mainVC = createVelocityContainer("video");
-		updateUI(null);
+		updateUI();
 		putInitialPanel(mainVC);
 	}
 	
 	public void setEvent(LiveStreamEvent event) {
-		String url = event != null? event.getLiveStreamUrl(): null;
-		updateUI(url);
+		String newUrl = event != null? event.getLiveStreamUrl(): null;
+		if (newUrl == null || !newUrl.equalsIgnoreCase(url)) {
+			url = newUrl;
+			error = Boolean.FALSE;
+			updateUI();
+		}
 	}
 
-	private void updateUI(String url) {
-		if (url == null || !url.equalsIgnoreCase(runningUrl)) {
-			runningUrl = url;
-			if (StringHelper.containsNonWhitespace(runningUrl)) {
+	private void updateUI() {
+		if (error) {
+			mainVC.contextRemove("id");
+			mainVC.contextPut("error", error);
+			retryLink = LinkFactory.createButton("viewer.retry", mainVC, this);
+		} else {
+			mainVC.contextRemove("error");
+			if (StringHelper.containsNonWhitespace(url)) {
 				mainVC.contextPut("id", CodeHelper.getRAMUniqueID());
 				mainVC.contextPut("src", url);
 			} else {
@@ -67,7 +83,14 @@ public class LiveStreamVideoController extends BasicController {
 
 	@Override
 	protected void event(UserRequest ureq, Component source, Event event) {
-		//
+		if ("error".equals(event.getCommand())) {
+			log.debug("Error when open a video from {}", url);
+			error = true;
+			updateUI();
+		} else if (source == retryLink) {
+			error = false;
+			updateUI();
+		}
 	}
 
 	@Override
diff --git a/src/main/java/org/olat/course/nodes/livestream/ui/_content/video.html b/src/main/java/org/olat/course/nodes/livestream/ui/_content/video.html
index 913c8b3df55..e036d985ddc 100644
--- a/src/main/java/org/olat/course/nodes/livestream/ui/_content/video.html
+++ b/src/main/java/org/olat/course/nodes/livestream/ui/_content/video.html
@@ -1,9 +1,17 @@
-#if($r.isNotNull($id))
+#if($r.isNotNull($error))
+	<div class="o_instruction">
+		$r.translate("viewer.error.stream")
+		<div class="o_button_group">
+			$r.render("viewer.retry")
+		</div>
+	</div>
+#elseif($r.isNotNull($id))
 	<div>
 		## height / width does not matter, because the size is streched responsive.
 		<p><span id="o_livestream_${id}" class="olatFlashMovieViewer" style="display:block;border:solid 1px #000;">
-			<script type="text/javascript" defer>
-				BPlayer.insertPlayer("$src","o_livestream_${id}",400,'100%',0,0,"video",undefined,true,true,false);
+			<script>
+				var errorCallback_$id = function(mediaElement, originalNode, player) {$r.openJavaScriptCommand("error"));};
+				BPlayer.insertPlayer("$src","o_livestream_${id}",400,'100%',0,0,"video",undefined,true,true,false, null, errorCallback_$id);
 			</script>
 		</span></p>
 	</div>
diff --git a/src/main/java/org/olat/course/nodes/livestream/ui/_content/viewer.html b/src/main/java/org/olat/course/nodes/livestream/ui/_content/viewer.html
index 691b46d7395..cda63470b2c 100644
--- a/src/main/java/org/olat/course/nodes/livestream/ui/_content/viewer.html
+++ b/src/main/java/org/olat/course/nodes/livestream/ui/_content/viewer.html
@@ -1,2 +1,2 @@
 $r.render("video")
-$r.render("metadata")
+$r.render("metadata")
\ No newline at end of file
diff --git a/src/main/java/org/olat/course/nodes/livestream/ui/_i18n/LocalStrings_de.properties b/src/main/java/org/olat/course/nodes/livestream/ui/_i18n/LocalStrings_de.properties
index cdd55674587..5401196541f 100644
--- a/src/main/java/org/olat/course/nodes/livestream/ui/_i18n/LocalStrings_de.properties
+++ b/src/main/java/org/olat/course/nodes/livestream/ui/_i18n/LocalStrings_de.properties
@@ -16,4 +16,6 @@ table.header.description=$org.olat.commons.calendar\:cal.form.description
 table.header.end=$org.olat.commons.calendar\:cal.form.end
 table.header.location=$org.olat.commons.calendar\:cal.form.location
 table.header.subject=$org.olat.commons.calendar\:cal.form.subject
+viewer.error.stream=Der Livestream kann nicht angezeigt werden. Vermutlich wird der Livestream noch nicht ausgestrahlt.
 viewer.no.stream=Aktuell wird kein Livestream ausgestrahlt.
+viewer.retry=Erneut starten
diff --git a/src/main/java/org/olat/course/nodes/livestream/ui/_i18n/LocalStrings_en.properties b/src/main/java/org/olat/course/nodes/livestream/ui/_i18n/LocalStrings_en.properties
index a56c2a45b05..8a75569a9dd 100644
--- a/src/main/java/org/olat/course/nodes/livestream/ui/_i18n/LocalStrings_en.properties
+++ b/src/main/java/org/olat/course/nodes/livestream/ui/_i18n/LocalStrings_en.properties
@@ -15,4 +15,6 @@ table.header.description=$org.olat.commons.calendar\:cal.form.description
 table.header.end=$org.olat.commons.calendar\:cal.form.end
 table.header.location=$org.olat.commons.calendar\:cal.form.location
 table.header.subject=$org.olat.commons.calendar\:cal.form.subject
+viewer.error.stream=It is not possible to show the live stream. Probably is the live stream not broadcasted yet.
 viewer.no.stream=Currently no live stream is broadcasted.
+viewer.retry=Try again
diff --git a/src/main/webapp/static/movie/player.js b/src/main/webapp/static/movie/player.js
index 5d3ba81bcd8..7e6e89a901c 100644
--- a/src/main/webapp/static/movie/player.js
+++ b/src/main/webapp/static/movie/player.js
@@ -2,14 +2,14 @@ var BPlayer = {
 	/**
 	 * Create a video player within the given DOM element with the given parameters. Same as insertHTML5Player() 
 	 */
-	insertPlayer: function (address,domId,width,height,start,duration,provider,streamer,autostart,repeat,controlbar,poster) {
-		BPlayer.insertHTML5Player(address,domId,width,height,start,duration,provider,streamer,autostart,repeat,controlbar,poster);
+	insertPlayer: function (address,domId,width,height,start,duration,provider,streamer,autostart,repeat,controlbar,poster,errorCallback) {
+		BPlayer.insertHTML5Player(address,domId,width,height,start,duration,provider,streamer,autostart,repeat,controlbar,poster,errorCallback);
 	},
 	
 	/**
 	 * Create a video player within the given DOM element with the given parameters
 	 */
-	insertHTML5Player : function (address, domId, width, height, start, duration, provider, streamer, autostart, repeat, controlbar, poster) {
+	insertHTML5Player : function (address, domId, width, height, start, duration, provider, streamer, autostart, repeat, controlbar, poster, errorCallback) {
 		// Calculate relative video URL
 		var videoUrl = address;
 		if(address.indexOf('://') < 0 && (address.indexOf('/raw/static/') == 0 || address.indexOf('/secstatic/qtieditor/') >= 0 || address.indexOf('/secstatic/qti/') >= 0)) {
@@ -58,9 +58,14 @@ var BPlayer = {
 		if(typeof controlbar != 'undefined' && !controlbar) {
 			args.controlbar = "none";
 		}
-		if(typeof poster != 'undefined') {
+		if(typeof poster != 'undefined' && poster) {
 			args.image = poster;
 		}
+		if(typeof errorCallback != 'undefined') {
+			args.errorCallback = errorCallback;
+		} else {
+			args.errorCallback = function(mediaElement, originalNode, player){};
+		}
 
 		// Finally, load player library and play video
 		if(BPlayer._needJWPlayerFallback(args)) {
@@ -221,6 +226,7 @@ var BPlayer = {
 		        path: mediaElementBaseUrl + 'flv/flv.min.js',
 		        withCredentials: true
 		    },
+			error: config.errorCallback,
 			success: function(mediaElement, originalNode, player) {
 				if(config.start) {
 					player.load();
diff --git a/src/main/webapp/static/movie/player.min.js b/src/main/webapp/static/movie/player.min.js
index 6d3e1cebe1c..2bb609eaa21 100644
--- a/src/main/webapp/static/movie/player.min.js
+++ b/src/main/webapp/static/movie/player.min.js
@@ -1 +1 @@
-var BPlayer={insertPlayer:function(k,d,c,l,b,e,h,g,m,a,f,j){BPlayer.insertHTML5Player(k,d,c,l,b,e,h,g,m,a,f,j)},insertHTML5Player:function(c,g,m,l,e,a,o,s,q,j,n,k){var f=c;if(c.indexOf("://")<0&&(c.indexOf("/raw/static/")==0||c.indexOf("/secstatic/qtieditor/")>=0||c.indexOf("/secstatic/qti/")>=0)){f=c}else{if(c.indexOf("://")<0&&((o!="rtmp"&&o!="http")||((o=="rtmp"||o=="http")&&(s==undefined||s.length==0)))){var d=document.location.href;f=d.substring(0,d.lastIndexOf("/"));if(c.indexOf("/")!=0){f+="/"}f+=c}}var b={file:f,width:m,height:l,controlbar:{position:"bottom"}};if(typeof o!="undefined"){b.provider=o}if(o=="rtmp"||o=="http"){b.streamer=s}if(typeof e!="undefined"){var h=BPlayer._convertInSeconds(e);if(h>0){b.start=h}}if(typeof a!="undefined"){var r=BPlayer._convertInSeconds(a);if(r>0){b.duration=r}}if(typeof q!="undefined"&&q){b.autostart=true}if(typeof j!="undefined"&&j){b.repeat="single"}if(typeof n!="undefined"&&!n){b.controlbar="none"}if(typeof k!="undefined"){b.image=k}if(BPlayer._needJWPlayerFallback(b)){b.flashplayer=BPlayer._jwPlayerBaseUrl()+"movieViewer.swf";var p=function(){jwplayer(g).setup(b)};BPlayer._loadJWPlayer(p)}else{if(o=="nanoo"||f.indexOf("nanoo.tv/")>=0){BPlayer._loadNanooTv(g,b)}else{var p=function(){BPlayer._insertHTML5MediaElementPlayerWorker(g,b)};BPlayer.loadMediaelementJsPlayer(p)}}},loadMediaelementJsPlayer:function(d){var a=BPlayer._mediaElementBaseUrl();var c=a+(BPlayer.debugEnabled?"mediaelementplayer.css":"mediaelementplayer.min.css");var b=a+(BPlayer.debugEnabled?"mediaelement-and-player.js":"mediaelement-and-player.min.js");if(jQuery("#mediaelementplayercss").length==0){jQuery("<link>").appendTo("head").attr({id:"mediaelementplayercss",type:"text/css",rel:"stylesheet"}).attr("href",c)}if(typeof jQuery("body").mediaelementplayer!="undefined"){if(d){d()}}else{jQuery.ajax({dataType:"script",cache:true,async:false,url:b}).done(function(){if(d){d()}})}},_loadNanooTv:function(c,b){var a=c+"_frame";for(i=jQuery("#"+a).length;i-->0;){jQuery("#"+a).remove()}if(b.image===undefined||b.image===null||b.image.length==0){BPlayer._loadNanooTvFrame(c,a,b)}else{BPlayer._loadNanooTvPoster(c,a,b)}},_loadNanooTvPoster:function(e,a,b){if(jQuery("#mediaelementplayercss").length==0){var c=BPlayer._mediaElementBaseUrl();var d=c+(BPlayer.debugEnabled?"mediaelementplayer.css":"mediaelementplayer.min.css");jQuery("<link>").appendTo("head").attr({id:"mediaelementplayercss",type:"text/css",rel:"stylesheet"}).attr("href",d)}var f="<div id='"+a+"' class='mejs__container' role='application' style='width:"+b.width+"px; height:"+b.height+"px; overflow:hidden; overflow-x:hidden; overflow-y:hidden;'><div class='mejs__layers'><div class='mejs__poster mejs__layer' style='background-image: url("+b.image+"); width: 100%; height: 100%;'><img src='"+b.image+"' width='0' height='0'></img></div><div class='mejs__overlay mejs__layer mejs__overlay-play' style='width: 100%; height: 100%; z-index:10;'><div class='mejs__overlay-button' style='z-index:10;' role='button' tabindex='0' aria-label='Play' aria-pressed='false'></div></div></div></div>";jQuery("#"+e).append(jQuery(f));jQuery("#"+e).css("border","none");jQuery("#"+e+" div.mejs__overlay-button").on("click",function(j,h){var g={file:b.file,width:b.width,height:b.height,autostart:true};BPlayer._loadNanooTvFrame(e,a,g)})},_loadNanooTvFrame:function(g,b,d){for(i=jQuery("#"+b).length;i-->0;){jQuery("#"+b).remove()}var c=d.file;var f=c.split("?");var a=f[0].substring(c.lastIndexOf("/")+1);if(d.autostart){c="https://www.nanoo.tv/link/w/"+a}else{c="https://www.nanoo.tv/link/n/"+a}var e='<iframe name="'+b+'" id="'+b+'" src="'+c+'" style="width:'+d.width+"px; height:"+d.height+'px; overflow:hidden;" frameborder="0" allow="fullscreen" allowfullscreen="true"></iframe>';jQuery("#"+g).append(jQuery(e));jQuery("#"+g).css("border","none")},_loadJWPlayer:function(a){if(BPlayer._isIE8()&&domId!="prev_container"&&jQuery("#"+domId).is("span")){alert("This is video is not supported on Internet Explorer 8. Sorry for the inconvenience")}else{jQuery.getScript(BPlayer._jwPlayerBaseUrl()+"player.jw.js",function(){if(a){a()}})}},_needJWPlayerFallback:function(a){if(a.provider=="rtmp"){if(a.file.match(/(.*)\/((flv|mp4|mp3):.*)/)){return false}else{return true}}return false},_insertHTML5MediaElementPlayerWorker:function(e,d){var k=BPlayer._mediaElementBaseUrl();var l={loop:d.repeat,pluginPath:k,stretching:"responsive",hls:{path:k+"hls/hls.min.js"},flv:{path:k+"flv/flv.min.js",withCredentials:true},success:function(o,q,p){if(d.start){p.load();o.addEventListener("canplay",function(){try{o.removeEventListener("canplay");p.setCurrentTime(d.start);p.play();if(!d.autostart){setTimeout(function(){p.pause()},100)}}catch(s){if(window.console){console.log(s)}}})}else{if(d.autostart){try{p.load();p.play()}catch(r){if(window.console){console.log(r)}}}}}};var a=null;var n=d.file.split(".").pop().toLowerCase().split("&").shift();if(d.provider=="sound"){if(n=="mp3"){a="audio/mp3"}else{if(n=="aac"){a="audio/aac"}else{if(n=="m4a"){a="audio/mp4"}}}}else{if(d.provider=="youtube"){a="video/youtube"}else{if(d.provider=="vimeo"){a="video/vimeo"}else{if(d.provider=="rtmp"){l.flashStreamer=d.streamer;a="video/rtmp"}else{if(d.provider=="http"){d.enablePseudoStreaming=true;if(n=="flv"){a="video/flv";l.renderers=["flash_video","native_flv"]}else{a="video/mp4"}}else{if(n=="flv"){a="video/flv";l.renderers=["flash_video","native_flv"]}else{if(n=="f4v"){a="video/flv"}else{if(n=="mp4"){a="video/mp4"}else{if(n=="m4v"){a="video/mp4"}else{if(n=="m3u8"){a="application/x-mpegURL"}else{if(n=="aac"){a="audio/mp4";d.provider="sound"}else{if(n=="mp3"){a="audio/mp3";d.provider="sound"}else{if(n=="m4a"){a="audio/mp4";d.provider="sound"}else{if(d.file.indexOf("vimeo.com")>-1){a="video/vimeo"}else{if(d.file.indexOf("youtube.com")>-1||d.file.indexOf("youtu.be")>-1||d.file.indexOf("youtube.be")>-1){a="video/youtube"}else{if(n.indexOf("mp4?")==0){a="video/mp4"}else{if(d.file.indexOf("openmeetings/recording")>0){a="video/mp4"}else{alert("Something go badly wrong!"+d.provider+"  "+n)}}}}}}}}}}}}}}}}}var j;var c=e+"_oo"+Math.floor(Math.random()*1000000)+"vid";var f=e+"_oo"+Math.floor(Math.random()*1000000)+"obj";if(d.provider=="sound"){if(d.height){l.audioHeight=d.height}if(d.width){l.audioWidth=d.width}j="<audio id='"+c+"' controls='controls' oncontextmenu='return false;'";if(typeof d.repeat!="undefined"&&d.repeat){j+=" loop='loop'"}var b="<object id='"+f+"' type='application/x-shockwave-flash'";if(typeof d.height!="undefined"){j+=" height='"+d.height+"'";b+=" height='"+d.height+"'";l.videoHeight=d.height}if(typeof d.width!="undefined"){j+=" width='"+d.width+"'";b+=" width='"+d.width+"'";l.videoWidth=d.width}if(typeof d.image!="undefined"){j+=" poster='"+d.image+"'"}j+="><source type='"+a+"' src='"+d.file+"'>";var g="mediaelement-flash-video.swf";if(a=="audio/mp3"){g="mediaelement-flash-audio.swf"}else{if(a=="audio/ogg"){g="mediaelement-flash-audio-ogg.swf"}}j+=b+" data='"+k+g+"'>";j+="<param name='movie' value='"+k+g+"' />";j+="<param name='flashvars' value='controls=true&amp;";if(typeof d.streamer!="undefined"){j+="&amp;streamer="+d.streamer}j+="&amp;file="+d.file+"' /></object>";j+="</audio>"}else{j="<video id='"+c+"' controls='controls' preload='none' oncontextmenu='return false;'";if(typeof d.repeat!="undefined"&&d.repeat){j+=" loop='loop'"}var b="<object id='"+f+"' type='application/x-shockwave-flash'";if(typeof d.height!="undefined"){l.videoHeight=d.height}if(typeof d.width!="undefined"){l.videoWidth=d.width}if(typeof d.image!="undefined"){j+=" poster='"+d.image+"'"}j+="><source type='"+a+"' src='"+d.file+"' />";j+=b+" data='"+k+"mediaelement-flash-video.swf'>";j+="<param name='movie' value='"+k+"mediaelement-flash-video.swf' />";j+="<param name='flashvars' value='controls=true";if(typeof d.streamer!="undefined"){j+="&amp;streamer="+d.streamer}j+="&amp;file="+d.file+"' /></object></video>"}var h=jQuery("#"+e);h.css({height:""});h.css({border:"none"});if(jQuery(window).width()<=d.width){h.css({width:""})}h.html(j);if(a=="video/vimeo"){var k=BPlayer._mediaElementBaseUrl();var m=k+(BPlayer.debugEnabled?"renderers/vimeo.js":"renderers/vimeo.min.js");jQuery.ajax({dataType:"script",cache:true,async:false,url:m}).done(function(){jQuery("#"+c).mediaelementplayer(l)})}else{jQuery("#"+c).mediaelementplayer(l)}},_mediaElementBaseUrl:function(){var a=BPlayer._findBaseUrl(window);if(a==null){a="/olat/raw/_noversion_/"}a+="movie/mediaelementjs/";return a},_isIE8:function(){return(jQuery.support.opacity==false)},_jwPlayerBaseUrl:function(){var a=BPlayer._findBaseUrl(window);if(a==null){a="/olat/raw/_noversion_/"}a+="movie/jw/";return a},_findBaseUrl:function(a){if(a.o_info){return a.o_info.o_baseURI}else{if(a.opener){return BPlayer._findBaseUrl(a.opener)}else{if(a.parent){return BPlayer._findBaseUrl(a.parent)}else{return null}}}},_convertInSeconds:function(d){if(typeof d=="undefined"||d==null){return 0}if(!d.length){return d}if(d.length==0){return 0}if(d.indexOf(".")>0){d=d.substring(0,d.indexOf("."))}var e=d.lastIndexOf(":");if(e>0){var c=d.substring(e+1,d.length);var a=parseInt(c);d=d.substring(0,e);e=d.lastIndexOf(":");if(e>0){var b=d.substring(e+1,d.length);a+=60*parseInt(b)}d=d.substring(0,e);if(d.length>0){a+=60*60*parseInt(d)}return a}else{return d}},_isOODebug:function(a){if(a.o_info){return a.o_info.debug}else{if(a.opener){return BPlayer._isOODebug(a.opener)}else{if(a.parent){return BPlayer._isOODebug(a.parent)}else{return false}}}}};BPlayer.debugEnabled=BPlayer._isOODebug(window);
\ No newline at end of file
+var BPlayer={insertPlayer:function(l,d,c,m,b,e,j,h,n,a,g,k,f){BPlayer.insertHTML5Player(l,d,c,m,b,e,j,h,n,a,g,k,f)},insertHTML5Player:function(c,g,n,m,e,a,p,t,s,k,o,l,j){var f=c;if(c.indexOf("://")<0&&(c.indexOf("/raw/static/")==0||c.indexOf("/secstatic/qtieditor/")>=0||c.indexOf("/secstatic/qti/")>=0)){f=c}else{if(c.indexOf("://")<0&&((p!="rtmp"&&p!="http")||((p=="rtmp"||p=="http")&&(t==undefined||t.length==0)))){var d=document.location.href;f=d.substring(0,d.lastIndexOf("/"));if(c.indexOf("/")!=0){f+="/"}f+=c}}var b={file:f,width:n,height:m,controlbar:{position:"bottom"}};if(typeof p!="undefined"){b.provider=p}if(p=="rtmp"||p=="http"){b.streamer=t}if(typeof e!="undefined"){var h=BPlayer._convertInSeconds(e);if(h>0){b.start=h}}if(typeof a!="undefined"){var r=BPlayer._convertInSeconds(a);if(r>0){b.duration=r}}if(typeof s!="undefined"&&s){b.autostart=true}if(typeof k!="undefined"&&k){b.repeat="single"}if(typeof o!="undefined"&&!o){b.controlbar="none"}if(typeof l!="undefined"&&l){b.image=l}if(typeof j!="undefined"){b.errorCallback=j}else{b.errorCallback=function(u,w,v){}}if(BPlayer._needJWPlayerFallback(b)){b.flashplayer=BPlayer._jwPlayerBaseUrl()+"movieViewer.swf";var q=function(){jwplayer(g).setup(b)};BPlayer._loadJWPlayer(q)}else{if(p=="nanoo"||f.indexOf("nanoo.tv/")>=0){BPlayer._loadNanooTv(g,b)}else{var q=function(){BPlayer._insertHTML5MediaElementPlayerWorker(g,b)};BPlayer.loadMediaelementJsPlayer(q)}}},loadMediaelementJsPlayer:function(d){var a=BPlayer._mediaElementBaseUrl();var c=a+(BPlayer.debugEnabled?"mediaelementplayer.css":"mediaelementplayer.min.css");var b=a+(BPlayer.debugEnabled?"mediaelement-and-player.js":"mediaelement-and-player.min.js");if(jQuery("#mediaelementplayercss").length==0){jQuery("<link>").appendTo("head").attr({id:"mediaelementplayercss",type:"text/css",rel:"stylesheet"}).attr("href",c)}if(typeof jQuery("body").mediaelementplayer!="undefined"){if(d){d()}}else{jQuery.ajax({dataType:"script",cache:true,async:false,url:b}).done(function(){if(d){d()}})}},_loadNanooTv:function(c,b){var a=c+"_frame";for(i=jQuery("#"+a).length;i-->0;){jQuery("#"+a).remove()}if(b.image===undefined||b.image===null||b.image.length==0){BPlayer._loadNanooTvFrame(c,a,b)}else{BPlayer._loadNanooTvPoster(c,a,b)}},_loadNanooTvPoster:function(e,a,b){if(jQuery("#mediaelementplayercss").length==0){var c=BPlayer._mediaElementBaseUrl();var d=c+(BPlayer.debugEnabled?"mediaelementplayer.css":"mediaelementplayer.min.css");jQuery("<link>").appendTo("head").attr({id:"mediaelementplayercss",type:"text/css",rel:"stylesheet"}).attr("href",d)}var f="<div id='"+a+"' class='mejs__container' role='application' style='width:"+b.width+"px; height:"+b.height+"px; overflow:hidden; overflow-x:hidden; overflow-y:hidden;'><div class='mejs__layers'><div class='mejs__poster mejs__layer' style='background-image: url("+b.image+"); width: 100%; height: 100%;'><img src='"+b.image+"' width='0' height='0'></img></div><div class='mejs__overlay mejs__layer mejs__overlay-play' style='width: 100%; height: 100%; z-index:10;'><div class='mejs__overlay-button' style='z-index:10;' role='button' tabindex='0' aria-label='Play' aria-pressed='false'></div></div></div></div>";jQuery("#"+e).append(jQuery(f));jQuery("#"+e).css("border","none");jQuery("#"+e+" div.mejs__overlay-button").on("click",function(j,h){var g={file:b.file,width:b.width,height:b.height,autostart:true};BPlayer._loadNanooTvFrame(e,a,g)})},_loadNanooTvFrame:function(g,b,d){for(i=jQuery("#"+b).length;i-->0;){jQuery("#"+b).remove()}var c=d.file;var f=c.split("?");var a=f[0].substring(c.lastIndexOf("/")+1);if(d.autostart){c="https://www.nanoo.tv/link/w/"+a}else{c="https://www.nanoo.tv/link/n/"+a}var e='<iframe name="'+b+'" id="'+b+'" src="'+c+'" style="width:'+d.width+"px; height:"+d.height+'px; overflow:hidden;" frameborder="0" allow="fullscreen" allowfullscreen="true"></iframe>';jQuery("#"+g).append(jQuery(e));jQuery("#"+g).css("border","none")},_loadJWPlayer:function(a){if(BPlayer._isIE8()&&domId!="prev_container"&&jQuery("#"+domId).is("span")){alert("This is video is not supported on Internet Explorer 8. Sorry for the inconvenience")}else{jQuery.getScript(BPlayer._jwPlayerBaseUrl()+"player.jw.js",function(){if(a){a()}})}},_needJWPlayerFallback:function(a){if(a.provider=="rtmp"){if(a.file.match(/(.*)\/((flv|mp4|mp3):.*)/)){return false}else{return true}}return false},_insertHTML5MediaElementPlayerWorker:function(e,d){var k=BPlayer._mediaElementBaseUrl();var l={loop:d.repeat,pluginPath:k,stretching:"responsive",hls:{path:k+"hls/hls.min.js"},flv:{path:k+"flv/flv.min.js",withCredentials:true},error:d.errorCallback,success:function(o,q,p){if(d.start){p.load();o.addEventListener("canplay",function(){try{o.removeEventListener("canplay");p.setCurrentTime(d.start);p.play();if(!d.autostart){setTimeout(function(){p.pause()},100)}}catch(s){if(window.console){console.log(s)}}})}else{if(d.autostart){try{p.load();p.play()}catch(r){if(window.console){console.log(r)}}}}}};var a=null;var n=d.file.split(".").pop().toLowerCase().split("&").shift();if(d.provider=="sound"){if(n=="mp3"){a="audio/mp3"}else{if(n=="aac"){a="audio/aac"}else{if(n=="m4a"){a="audio/mp4"}}}}else{if(d.provider=="youtube"){a="video/youtube"}else{if(d.provider=="vimeo"){a="video/vimeo"}else{if(d.provider=="rtmp"){l.flashStreamer=d.streamer;a="video/rtmp"}else{if(d.provider=="http"){d.enablePseudoStreaming=true;if(n=="flv"){a="video/flv";l.renderers=["flash_video","native_flv"]}else{a="video/mp4"}}else{if(n=="flv"){a="video/flv";l.renderers=["flash_video","native_flv"]}else{if(n=="f4v"){a="video/flv"}else{if(n=="mp4"){a="video/mp4"}else{if(n=="m4v"){a="video/mp4"}else{if(n=="m3u8"){a="application/x-mpegURL"}else{if(n=="aac"){a="audio/mp4";d.provider="sound"}else{if(n=="mp3"){a="audio/mp3";d.provider="sound"}else{if(n=="m4a"){a="audio/mp4";d.provider="sound"}else{if(d.file.indexOf("vimeo.com")>-1){a="video/vimeo"}else{if(d.file.indexOf("youtube.com")>-1||d.file.indexOf("youtu.be")>-1||d.file.indexOf("youtube.be")>-1){a="video/youtube"}else{if(n.indexOf("mp4?")==0){a="video/mp4"}else{if(d.file.indexOf("openmeetings/recording")>0){a="video/mp4"}else{alert("Something go badly wrong!"+d.provider+"  "+n)}}}}}}}}}}}}}}}}}var j;var c=e+"_oo"+Math.floor(Math.random()*1000000)+"vid";var f=e+"_oo"+Math.floor(Math.random()*1000000)+"obj";if(d.provider=="sound"){if(d.height){l.audioHeight=d.height}if(d.width){l.audioWidth=d.width}j="<audio id='"+c+"' controls='controls' oncontextmenu='return false;'";if(typeof d.repeat!="undefined"&&d.repeat){j+=" loop='loop'"}var b="<object id='"+f+"' type='application/x-shockwave-flash'";if(typeof d.height!="undefined"){j+=" height='"+d.height+"'";b+=" height='"+d.height+"'";l.videoHeight=d.height}if(typeof d.width!="undefined"){j+=" width='"+d.width+"'";b+=" width='"+d.width+"'";l.videoWidth=d.width}if(typeof d.image!="undefined"){j+=" poster='"+d.image+"'"}j+="><source type='"+a+"' src='"+d.file+"'>";var g="mediaelement-flash-video.swf";if(a=="audio/mp3"){g="mediaelement-flash-audio.swf"}else{if(a=="audio/ogg"){g="mediaelement-flash-audio-ogg.swf"}}j+=b+" data='"+k+g+"'>";j+="<param name='movie' value='"+k+g+"' />";j+="<param name='flashvars' value='controls=true&amp;";if(typeof d.streamer!="undefined"){j+="&amp;streamer="+d.streamer}j+="&amp;file="+d.file+"' /></object>";j+="</audio>"}else{j="<video id='"+c+"' controls='controls' preload='none' oncontextmenu='return false;'";if(typeof d.repeat!="undefined"&&d.repeat){j+=" loop='loop'"}var b="<object id='"+f+"' type='application/x-shockwave-flash'";if(typeof d.height!="undefined"){l.videoHeight=d.height}if(typeof d.width!="undefined"){l.videoWidth=d.width}if(typeof d.image!="undefined"){j+=" poster='"+d.image+"'"}j+="><source type='"+a+"' src='"+d.file+"' />";j+=b+" data='"+k+"mediaelement-flash-video.swf'>";j+="<param name='movie' value='"+k+"mediaelement-flash-video.swf' />";j+="<param name='flashvars' value='controls=true";if(typeof d.streamer!="undefined"){j+="&amp;streamer="+d.streamer}j+="&amp;file="+d.file+"' /></object></video>"}var h=jQuery("#"+e);h.css({height:""});h.css({border:"none"});if(jQuery(window).width()<=d.width){h.css({width:""})}h.html(j);if(a=="video/vimeo"){var k=BPlayer._mediaElementBaseUrl();var m=k+(BPlayer.debugEnabled?"renderers/vimeo.js":"renderers/vimeo.min.js");jQuery.ajax({dataType:"script",cache:true,async:false,url:m}).done(function(){jQuery("#"+c).mediaelementplayer(l)})}else{jQuery("#"+c).mediaelementplayer(l)}},_mediaElementBaseUrl:function(){var a=BPlayer._findBaseUrl(window);if(a==null){a="/olat/raw/_noversion_/"}a+="movie/mediaelementjs/";return a},_isIE8:function(){return(jQuery.support.opacity==false)},_jwPlayerBaseUrl:function(){var a=BPlayer._findBaseUrl(window);if(a==null){a="/olat/raw/_noversion_/"}a+="movie/jw/";return a},_findBaseUrl:function(a){if(a.o_info){return a.o_info.o_baseURI}else{if(a.opener){return BPlayer._findBaseUrl(a.opener)}else{if(a.parent){return BPlayer._findBaseUrl(a.parent)}else{return null}}}},_convertInSeconds:function(d){if(typeof d=="undefined"||d==null){return 0}if(!d.length){return d}if(d.length==0){return 0}if(d.indexOf(".")>0){d=d.substring(0,d.indexOf("."))}var e=d.lastIndexOf(":");if(e>0){var c=d.substring(e+1,d.length);var a=parseInt(c);d=d.substring(0,e);e=d.lastIndexOf(":");if(e>0){var b=d.substring(e+1,d.length);a+=60*parseInt(b)}d=d.substring(0,e);if(d.length>0){a+=60*60*parseInt(d)}return a}else{return d}},_isOODebug:function(a){if(a.o_info){return a.o_info.debug}else{if(a.opener){return BPlayer._isOODebug(a.opener)}else{if(a.parent){return BPlayer._isOODebug(a.parent)}else{return false}}}}};BPlayer.debugEnabled=BPlayer._isOODebug(window);
\ No newline at end of file
-- 
GitLab