]> git.parisson.com Git - mezzo.git/commitdiff
Dispose video player when closing overlay
authorJérémy Fabre <blackmagik88@gmail.com>
Tue, 21 Feb 2017 15:35:56 +0000 (16:35 +0100)
committerJérémy Fabre <blackmagik88@gmail.com>
Tue, 21 Feb 2017 15:35:56 +0000 (16:35 +0100)
app/static/src/js/modules/video-overlay.js

index b9f199a2067e575cfcf1072b9d76cae585b4a229..d4cff613972635645874932a3ca5e026b9736c6d 100644 (file)
@@ -8,6 +8,9 @@ var VideoOverlay = function() {
     this.$overlayClose = $('#overlayClose');
     this.$overlayLoader = $('#overlayLoader');
 
+    this.player = null;
+    this.type = null;
+
     //
     // Init
     //
@@ -59,13 +62,15 @@ VideoOverlay.prototype.openOverlay = function(url) {
     that.$overlayContent.load(url, function() {
 
         if($('video', that.$overlay).length > 0) {
-            var player = new Video(that.$overlay);
+            that.player = new Video(that.$overlay);
+            that.type = 'video';
         } else {
-            var player = new Audio(that.$overlay);
+            that.player = new Audio(that.$overlay);
+            that.type = 'audio';
         }
 
         setTimeout(function() {
-            player.play();
+            that.player.play();
             that.$overlayLoader.hide();
             that.$overlayContent.addClass('loaded');
         }, 2000);
@@ -80,6 +85,11 @@ VideoOverlay.prototype.closeOverlay = function(url) {
 
     that.$overlayContent.removeClass('loaded');
     setTimeout(function() {
+        if(that.type == 'video') {
+            that.player.player.dispose();
+        } else {
+
+        }
         that.$overlayContent.html('');
         that.$overlay.removeClass('open');
     }, 1000);