Merge pull request #1151 from AStove/PauseNoise2

Pause audio, videos and iframe when hiding plugin
This commit is contained in:
Lorenz Hübschle-Schneider 2020-08-04 13:43:26 +02:00 committed by GitHub
commit 0e13bd68b1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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) {