You can get the maximum volume level for system, notifications, alarm, media and so on. Also, you can change or get the current volume level.
For more information on the Sound features, see Sound Guide.
Since: 2.3
Interface | Method |
---|---|
SoundManagerObject | |
SoundManager |
SoundModeType getSoundMode () void setVolume (SoundType type, double volume) double getVolume (SoundType type) void setSoundModeChangeListener (SoundModeChangeCallback callback) void unsetSoundModeChangeListener () void setVolumeChangeListener (SoundVolumeChangeCallback callback) void unsetVolumeChangeListener () SoundDeviceInfo[] getConnectedDeviceList () SoundDeviceInfo[] getActivatedDeviceList () long addDeviceStateChangeListener (SoundDeviceStateChangeCallback callback) void removeDeviceStateChangeListener (long id) |
SoundDeviceInfo | |
SoundModeChangeCallback | void onsuccess (SoundModeType mode) |
SoundVolumeChangeCallback | void onsuccess (SoundType type, double volume) |
SoundDeviceStateChangeCallback | void onchanged (SoundDeviceInfo info) |
enum SoundType { "SYSTEM", "NOTIFICATION", "ALARM", "MEDIA", "VOICE", "RINGTONE" };
Since: 2.3
Remark : VOICE type might not be supported on a device which does not support voice recognition.
enum SoundModeType { "SOUND", "VIBRATE", "MUTE" };
Since: 2.3
enum SoundDeviceType { "SPEAKER", "RECEIVER", "AUDIO_JACK", "BLUETOOTH", "HDMI", "MIRRORING", "USB_AUDIO", "MIC" };
Since: 2.3.1
The possible types are:
[NoInterfaceObject] interface SoundManagerObject { readonly attribute SoundManager sound; };
Tizen implements SoundManagerObject;
Since: 2.3
There is a tizen.sound object that allows accessing the functionality of the Sound API.
[NoInterfaceObject] interface SoundManager { SoundModeType getSoundMode() raises(WebAPIException); void setVolume(SoundType type, double volume) raises(WebAPIException); double getVolume(SoundType type) raises(WebAPIException); void setSoundModeChangeListener(SoundModeChangeCallback callback) raises(WebAPIException); void unsetSoundModeChangeListener() raises(WebAPIException); void setVolumeChangeListener(SoundVolumeChangeCallback callback) raises(WebAPIException); void unsetVolumeChangeListener() raises(WebAPIException); SoundDeviceInfo[] getConnectedDeviceList() raises(WebAPIException); SoundDeviceInfo[] getActivatedDeviceList() raises(WebAPIException); long addDeviceStateChangeListener(SoundDeviceStateChangeCallback callback) raises(WebAPIException); void removeDeviceStateChangeListener(long id) raises(WebAPIException); };
Since: 2.3
getSoundMode
SoundModeType getSoundMode();
Since: 2.3
Return value:
SoundModeType The current sound modeExceptions:
with error type UnknownError in any error case.
setVolume
void setVolume(SoundType type, double volume);
Since: 2.3
Privilege level: public
Privilege: http://tizen.org/privilege/volume.set
Parameters:
Exceptions:
with error type NotSupportedError, if the given type is not supported. (e.g. when VOICE type is given on a Tizen wearable device).
with error type TypeMismatchError, if the input parameter is not compatible with the expected type.
with error type InvalidValuesError, if any of the input parameters contain an invalid value.
with error type UnknownError in any other error case.
getVolume
double getVolume(SoundType type);
Since: 2.3
Parameters:
Return value:
double The current volume levelExceptions:
with error type NotSupportedError, if the given type is not supported.
with error type TypeMismatchError, if the input parameter is not compatible with the expected type.
with error type UnknownError in any other error case.
setSoundModeChangeListener
void setSoundModeChangeListener(SoundModeChangeCallback callback);
Since: 2.3
Parameters:
Exceptions:
with error type TypeMismatchError, if the input parameter is not compatible with the expected type.
with error type UnknownError in any other error case.
unsetSoundModeChangeListener
void unsetSoundModeChangeListener();
Since: 2.3
Exceptions:
with error type UnknownError in any error case.
setVolumeChangeListener
void setVolumeChangeListener(SoundVolumeChangeCallback callback);
Since: 2.3
Parameters:
Exceptions:
with error type TypeMismatchError, if the input parameter is not compatible with the expected type.
with error type UnknownError in any other error case.
unsetVolumeChangeListener
void unsetVolumeChangeListener();
Since: 2.3
Exceptions:
with error type UnknownError in any other error case.
getConnectedDeviceList
SoundDeviceInfo[] getConnectedDeviceList();
Since: 2.3.1
Return value:
The list of connected sound devicesExceptions:
with error type UnknownError in any other error case.
Code example:
var infoArr = tizen.sound.getConnectedDeviceList(); for (var i = 0; i < infoArr.length; i++) { cosole.log( infoArr[i].device ); }
getActivatedDeviceList
SoundDeviceInfo[] getActivatedDeviceList();
Since: 2.3.1
Return value:
The list of activated sound devicesExceptions:
with error type UnknownError in any other error case.
Code example:
var infoArr = tizen.sound.getActivatedDeviceList(); for (var i = 0; i < infoArr.length; i++) { cosole.log( infoArr[i].device ); }
addDeviceStateChangeListener
long addDeviceStateChangeListener(SoundDeviceStateChangeCallback callback);
Since: 2.3.1
There are two types of device state changes:
Parameters:
Return value:
long ID of the listener that can be used to remove the listener later.Exceptions:
with error type TypeMismatchError, if the input parameter is not compatible with the expected type.
with error type UnknownError in any other error case.
Code example:
// A callback var onChanged = function(info) { // Some code to execute when a sound device state is changed if (info.isConnected) { // Some code to execute if the device is connected. console.log( info.device + " is connected" ); } else { // Some code to execute if the device is not connected. console.log( info.device + " is not connected" ); } if (info.isActivated) { // Some code to execute if the device is activated. console.log( info.device + " is activated" ); } else { // Some code to execute if the device is not activated. console.log( info.device + " is not activated" ); } } var id = tizen.sound.addDeviceStateChangeListener(onChanged);
removeDeviceStateChangeListener
void removeDeviceStateChangeListener(long id);
Since: 2.3.1
Parameters:
Exceptions:
with error type UnknownError in any error case.
Code example:
// If a listener to be called was registered previously. tizen.sound.removeDeviceStateChangeListener(id);
[NoInterfaceObject] interface SoundDeviceInfo { readonly attribute long id; readonly attribute DOMString name; readonly attribute SoundDeviceType device; readonly attribute SoundIOType direction; readonly attribute boolean isConnected; readonly attribute boolean isActivated; };
Since: 2.3.1
Since: 2.3.1
Since: 2.3.1
Since: 2.3.1
Since: 2.3.1
Since: 2.3.1
Since: 2.3.1
[Callback=FunctionOnly, NoInterfaceObject] interface SoundModeChangeCallback { void onsuccess(SoundModeType mode); };
Since: 2.3
onsuccess
void onsuccess(SoundModeType mode);
Since: 2.3
Parameters:
[Callback=FunctionOnly, NoInterfaceObject] interface SoundVolumeChangeCallback { void onsuccess(SoundType type, double volume); };
Since: 2.3
onsuccess
void onsuccess(SoundType type, double volume);
Since: 2.3
Parameters:
[Callback=FunctionOnly, NoInterfaceObject] interface SoundDeviceStateChangeCallback { void onchanged(SoundDeviceInfo info); };
Since: 2.3.1
onchanged
void onchanged(SoundDeviceInfo info);
Since: 2.3.1
Parameters:
module Sound { enum SoundType { "SYSTEM", "NOTIFICATION", "ALARM", "MEDIA", "VOICE", "RINGTONE" }; enum SoundModeType { "SOUND", "VIBRATE", "MUTE" }; enum SoundDeviceType { "SPEAKER", "RECEIVER", "AUDIO_JACK", "BLUETOOTH", "HDMI", "MIRRORING", "USB_AUDIO", "MIC" }; enum SoundIOType { "IN", "OUT", "BOTH" }; [NoInterfaceObject] interface SoundManagerObject { readonly attribute SoundManager sound; }; Tizen implements SoundManagerObject; [NoInterfaceObject] interface SoundManager { SoundModeType getSoundMode() raises(WebAPIException); void setVolume(SoundType type, double volume) raises(WebAPIException); double getVolume(SoundType type) raises(WebAPIException); void setSoundModeChangeListener(SoundModeChangeCallback callback) raises(WebAPIException); void unsetSoundModeChangeListener() raises(WebAPIException); void setVolumeChangeListener(SoundVolumeChangeCallback callback) raises(WebAPIException); void unsetVolumeChangeListener() raises(WebAPIException); SoundDeviceInfo[] getConnectedDeviceList() raises(WebAPIException); SoundDeviceInfo[] getActivatedDeviceList() raises(WebAPIException); long addDeviceStateChangeListener(SoundDeviceStateChangeCallback callback) raises(WebAPIException); void removeDeviceStateChangeListener(long id) raises(WebAPIException); }; [NoInterfaceObject] interface SoundDeviceInfo { readonly attribute long id; readonly attribute DOMString name; readonly attribute SoundDeviceType device; readonly attribute SoundIOType direction; readonly attribute boolean isConnected; readonly attribute boolean isActivated; }; [Callback=FunctionOnly, NoInterfaceObject] interface SoundModeChangeCallback { void onsuccess(SoundModeType mode); }; [Callback=FunctionOnly, NoInterfaceObject] interface SoundVolumeChangeCallback { void onsuccess(SoundType type, double volume); }; [Callback=FunctionOnly, NoInterfaceObject] interface SoundDeviceStateChangeCallback { void onchanged(SoundDeviceInfo info); }; };