]> git.parisson.com Git - mezzo.git/commitdiff
Add blank video, add JS counter
authorGuillaume Pellerin <guillaume.pellerin@ircam.fr>
Tue, 14 Mar 2017 17:40:42 +0000 (18:40 +0100)
committerGuillaume Pellerin <guillaume.pellerin@ircam.fr>
Tue, 14 Mar 2017 17:40:42 +0000 (18:40 +0100)
app/themes/base/static/src/js/modules/live-streaming-counter.js [new file with mode: 0644]
app/themes/base/static/video/blank_480.webm [new file with mode: 0644]

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 (file)
index 0000000..1af7d49
--- /dev/null
@@ -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('<br /><br />');
+    $('#countdown').html('<br />');
+}
+
+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('<br /><br />');
+                $('#'+id).html('<br />');
+                $('#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 (file)
index 0000000..2e09765
Binary files /dev/null and b/app/themes/base/static/video/blank_480.webm differ