From ce13110b2cbca73443bedd55d4ec1019c47b0b09 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Je=CC=81re=CC=81my=20Fabre?= Date: Tue, 21 Feb 2017 16:35:56 +0100 Subject: [PATCH] Dispose video player when closing overlay --- app/static/src/js/modules/video-overlay.js | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/app/static/src/js/modules/video-overlay.js b/app/static/src/js/modules/video-overlay.js index b9f199a2..d4cff613 100644 --- a/app/static/src/js/modules/video-overlay.js +++ b/app/static/src/js/modules/video-overlay.js @@ -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); -- 2.39.5