From: Guillaume Pellerin Date: Tue, 14 Mar 2017 17:40:42 +0000 (+0100) Subject: Add blank video, add JS counter X-Git-Url: https://git.parisson.com/?a=commitdiff_plain;h=4de87692f1c4149a360ebb1a8a0da6b6fd6c5669;p=mezzo.git Add blank video, add JS counter --- diff --git a/app/themes/base/static/src/js/modules/live-streaming-counter.js b/app/themes/base/static/src/js/modules/live-streaming-counter.js new file mode 100644 index 00000000..1af7d49d --- /dev/null +++ b/app/themes/base/static/src/js/modules/live-streaming-counter.js @@ -0,0 +1,85 @@ + +function switchVideo(id, url) { + var video = $('#'+id); + video.attr("src", url); +} + + +function failed(e) { + // video playback failed - show a message saying why + switch (e.target.error.code) { + case e.target.error.MEDIA_ERR_ABORTED: + alert('You aborted the video playback.'); + break; + case e.target.error.MEDIA_ERR_NETWORK: + alert('A network error caused the video download to fail part-way.'); + break; + case e.target.error.MEDIA_ERR_DECODE: + alert('The video playback was aborted due to a corruption problem or because the video used features your browser did not support.'); + break; + case e.target.error.MEDIA_ERR_SRC_NOT_SUPPORTED: + alert('The video could not be loaded, either because the server or network failed or because the format is not supported.'); + break; + default: + alert('An unknown error occurred.'); + break; + } +} + + +function cleanCounter() { + $('#countdown-title').html('

'); + $('#countdown').html('
'); +} + +function CountDownTimer(dt, id, video_id, video_url) + { + var end = new Date(dt); + + var _second = 1000; + var _minute = _second * 60; + var _hour = _minute * 60; + var _day = _hour * 24; + var timer; + + function showRemaining() { + + var now = new Date(); + var distance = end - now; + + if (distance < 0) { + clearInterval(timer); + $('#countdown-title').html('

'); + $('#'+id).html('
'); + $('#live').html('- Live !'); + switchVideo(video_id, video_url); + return; + } + + $('#countdown-title').html('Retransmission dans :'); + + var days = Math.floor(distance / _day); + var hours = Math.floor((distance % _day) / _hour); + var minutes = Math.floor((distance % _hour) / _minute); + var seconds = Math.floor((distance % _minute) / _second); + + document.getElementById(id).innerHTML = days + 'jours '; + document.getElementById(id).innerHTML += hours + 'hrs '; + document.getElementById(id).innerHTML += minutes + 'mins '; + document.getElementById(id).innerHTML += seconds + 'secs'; + + } + + timer = setInterval(showRemaining, 1000); + } + + +jQuery.fn.center = function () { + this.css("position","absolute"); + this.css("top", Math.max(0, (($(window).height() - $(this).outerHeight()) / 2) + + $(window).scrollTop()) + "px"); + this.css("left", Math.max(0, (($(window).width() - $(this).outerWidth()) / 2) + + $(window).scrollLeft()) + "px"); + return this; +} + diff --git a/app/themes/base/static/video/blank_480.webm b/app/themes/base/static/video/blank_480.webm new file mode 100644 index 00000000..2e097653 Binary files /dev/null and b/app/themes/base/static/video/blank_480.webm differ