From 2685219376ee9672f2ca87792d56e10112fcee61 Mon Sep 17 00:00:00 2001 From: Jeremy Mahieu Date: Wed, 22 Jul 2020 23:12:09 +0200 Subject: [PATCH] Pause audio, videos and iframe --- js/plugin-directive.js | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/js/plugin-directive.js b/js/plugin-directive.js index 4510f04..946c846 100644 --- a/js/plugin-directive.js +++ b/js/plugin-directive.js @@ -31,6 +31,24 @@ weechat.directive('plugin', ['$rootScope', 'settings', function($rootScope, sett $scope.hideContent = function() { $scope.plugin.visible = false; + // Pause noise makers + var element = $scope.plugin.getElement() + // If it's video we can pause it + var video = element.querySelector( 'video' ); + if ( video ) { + video.pause(); + } + // If it's audio we can pause it + var audio = element.querySelector( 'audio' ); + if ( audio ) { + audio.pause(); + } + // If it has an iframe, have to reload it so it would stop + var iframe = element.querySelector( 'iframe'); + if ( iframe ) { + var innerHTML = element.innerHTML; + element.innerHTML = innerHTML; + } }; $scope.showContent = function(automated) {