Languages

Menu
Sites
Language
How to mute a sound in the web App.

This is a Game app. and i want to onclick a button sound is mute and press agin the button then sound is unmute.
 

Responses

7 Replies
AVSukhov

Hello,

You can try to use Sound API and setVolume for MEDIA type to 0:

tizen.sound.setVolume("MEDIA", 0);

 

ashish kumar

Hi,thank's but again i am clicking the button then i want unmute the sound how it is possible..

AVSukhov

Hello,

You need to store current volume state (for a specific sound type) before mute.

You can do it using getVolume() method from Sound API.

And when unmute - restore this volume state.

Vikram

Hi,

You can refer to https://developer.tizen.org/development/api-references/web-application?redirect=https%3A//developer.tizen.org/dev-guide/2.3.1/org.tizen.web.apireference/html/web_api_reference.htm

and get more information. The volume level to set 0 is indicate mute.

Palitsyna

Hello,

try following code:

tizen.sound.setVolume("MEDIA", 0);

use one of the following parameters according to your purpose:

  • SYSTEM - for system sounds
  • NOTIFICATION - for notifications
  • ALARM - for alarm
  • MEDIA - for media playback
  • VOICE - for voice
  • RINGTONE - for the phone ring

 

More info here: https://developer.tizen.org/dev-guide/2.4b/org.tizen.web.apireference/html/device_api/mobile/tizen/sound.html

Palitsyna

tizen.sound.setVolume() method has two parameters. 

tizen.sound.setVolume(SoundType type, double volume);
  • type: The sound type
  • volume: The volume level to set. The level ranges from 0 to 1.

So, to mute set the volume parameter as 0 and to unmute - 1 or other value from 0 to 1.

And don't forget to add volume.set privilege tp your config.xml file as written below.

<tizen:privilege name="http://tizen.org/privilege/volume.set"/>

 

Vikram

Hi,

Just sample code to complete click button to mute and click again to unmute.

function mute(){
    var type = tizen.sound.getSoundMode();
	var volume = tizen.sound.getVolume("MEDIA");
	if(type === "SOUND" && volume!== 0)
	{
		tizen.sound.setVolume("MEDIA", 0);	
	}
	else
	{
		tizen.sound.setVolume("MEDIA", volume+0.3);
	}
}