Languages

Menu
Sites
Language
How to get isMute using javascript?

Hi,

I want to know if the user allows sound or not on their gear device.

Currently the music plays nomather what but I dont want it that way. So how do I findout if they user has muted (optionally what volume hes using) only using javascript?

Responses

5 Replies
Marco Buettner

You have to ways

Easy method

HTML

<audio controls>
  <source src="horse.ogg" type="audio/ogg">
  <source src="horse.mp3" type="audio/mpeg">
  Your browser does not support the audio tag.
</audio>

JavaScript

function isMuted() {
    var audioElem = document.querySelector('audio');
    return audioElem.muted;
}

(function() {
    $(document).on("click", 'audio', function() {
        console.log("isMuted? := "+isMuted());
    });
})();

 

Otherwise you can setup up a eventhandler for volume changes (preferred)

HTML

same above ;)

JavaScript

(function() {
    var audioElem = document.querySelector('audio');
    audioElm.addEventListener("volumechange", function () {
      if (audioElm.muted)
        console.log("MUTED");
    else
        console.log("NOTE MUTED");
    }, false);
})();

 

Andreas Karlsson

Thanks for the tip!

Altho that did not work. I'm guessing it only checks wether the specified audio is muted, not if the device is on mute or vibrate.. :/

Derp.

AVSukhov

Hello,

Wearable SDK currently does not support the possibility to get System settings

Abdullah Al Monsur

Hi,

I want to silence the tizen mobile from web app or native, how it's possible?

AVSukhov

Hello,

For example using Audio Web API yuo can set volume to 0.