How to mute all sound when browser or apps minimize?

How to mute all sound when browser or apps minimize??
Thank you very musch

this.music = this.sound.add(“music”, {loop: true});
this.music2 = this.sound.add(“music2”, {loop: true});
this.music3 = this.sound.add(“music”, {loop: true});
this.music4= this.sound.add(“music2”, {loop: true});

web??
        window.onpageshow = function() {
            SomeOneSoundPlaying.play();
        }
        window.onpagehide = function() {
            AllSound.pause();
        }

PhoneGap/Cordova apps?

function onLoad() {
        document.addEventListener("deviceready", onDeviceReady, false);
    }

function onDeviceReady() {
        document.addEventListener("pause", onPause, false);
    }

function onPause() {
  AllSound.pause();
    }

?

You can use https://photonstorm.github.io/phaser3-docs/Phaser.Game.html#onBlur__anchor and onfocus events