toast.tvaudiocontrol provides audio control such as volume or mute.
- browser
- sectv-orsay (sectv-orsay)
- sectv-tizen (sectv-tizen)
- Privilege
<tizen:privilege name="http://tizen.org/privilege/tv.audio"/>
must be declared in the config.xml of tizen package.
- Privilege
- tv-webos (tv-webos)
Method Name | Browser | Legacy Samsung Smart TV | Tizen Samsung Smart TV | WebOS LG Smart TV | |||
Emulator (ver 5.1) | Device ('12 - '14) | Emulator (ver 2.3.1) | Device ('15 - '16) | Emulator (ver 3.0.0) | Device ('14 - '16) | ||
setMute | O | O | O | O | O | O | O |
isMute | O | O | O | O | O | O | O |
setVolume | O | X | O | O | O | O | O |
setVolumeUp | O | O | O | O | O | O | O |
setVolumeDown | O | O | O | O | O | O | O |
getVolume | O | O | O | O | O | O | O |
setVolumeChangeListener | O | O | O | O | O | O | O |
unsetVulumeChangeListener | O | O | O | O | O | O | O |
module TVAudioControl {
[NoInterfaceObject] interface TVAudioControlManagerObject {
readonly attribute TVAudioControlManagerObject tvaudiocontrol;
};
Toast implements TVAudioControlManagerObject;
[NoInterfaceObject] interface TVAudioControlManager {
void setMute(boolean mute, DOMStringCallback successCallback, optional ErrorCallback? errorCallback);
void isMute(DOMStringCallback successCallback, optional ErrorCallback? errorCallback);
void setVolume(unsigned short volume, DOMStringCallback successCallback, optional ErrorCallback? errorCallback);
void setVolumeUp(DOMStringCallback successCallback, optional ErrorCallback? errorCallback);
void setVolumeDown(DOMStringCallback successCallback, optional ErrorCallback? errorCallback);
void getVolume(DOMStringCallback successCallback, optional ErrorCallback? errorCallback);
void setVolumeChangeListener(VolumeChangeCallback callback, DOMStringCallback successCallback, optional ErrorCallback? errorCallback);
void unsetVolumeChangeListener(DOMStringCallback successCallback, optional ErrorCallback? errorCallback);
};
};
[Callback = FunctionOnly, NoInterfaceObject] interface VolumeChangeCallback {
void onchanged(unsigned short volume);
};
void setMute(boolean mute, DOMStringCallback successCallback, optional ErrorCallback? errorCallback);
This method sets to turn on or off mute mode. If changing the volume using setVolumeUp or setVolumeDown then mute is disabled automatically. Speaker UI might not be shown according to platform.
- Parameters
- mute : State of mute mode. (true/false)
- successCallback : The method to call when the mute state is set successfully.
- errorCallback : The method to invoke when an error occurs.
- Return value
- N/A
- Exceptions
- throws TypeError
- if type of any parameters is not matched to specification.
- throws Error
- if unknown error occured.
- throws TypeError
- Examples
-
Setting mute state to true.
var mute = true; toast.tvaudiocontrol.setMute(mute, function() { console.log('Success'); }, function(err) { console.log('Error: ' + err.message); });
-
This method gets mute state.
- Parameters
- successCallback : The method to call when the state of mute got successfully.
- errorCallback : The method to invoke when an error occurs.
- Return value
- N/A
- Exceptions
- throws TypeError
- if type of any parameters is not matched to specification.
- throws Error
- if unknown error occured.
- throws TypeError
- Examples
-
Getting mute state.
toast.tvaudiocontrol.isMute(function(value) { console.log('Success: ' + value); }, function(err) { console.log('Error: ' + err.message); });
-
void setVolume(unsigned short volume, DOMStringCallback successCallback, optional ErrorCallback? errorCallback);
This method changes the volume level. The value of volume is allowed from 0 to 100.
- Parameters
- volume : Volume level to set. (The available range is 0~100)
- successCallback : The method to call when the volume is changed successfully.
- errorCallback : The method to invoke when an error occurs.
- Return value
- N/A
- Exceptions
- throws TypeError
- if type of any parameters is not matched to specification.
- throws Error
- if unknown error occured.
- throws TypeError
- Examples
-
Changing the volume level to 5.
var volume = 5; toast.tvaudiocontrol.setVolume(volume, function() { console.log('Success'); }, function(err) { console.log('Error: ' + err.message); });
-
This method increases the volume 1 level. The maximum volume level is 100. If the current volume is above 100 level, it would be ignored.
- Parameters
- successCallback : The method to call when the volume increases 1 level successfully.
- errorCallback : The method to invoke when an error occurs.
- Return value
- N/A
- Exceptions
- throws TypeError
- if type of any parameters is not matched to specification.
- throws Error
- if unknown error occured.
- throws TypeError
- Examples
-
Increasing the volume 1 level.
toast.tvaudiocontrol.setVolumeUp(function() { console.log('Success'); }, function(err) { console.log('Error: ' + err.message); });
-
This method decreases the volume 1 level. The minimum volume level is 0. If the current volume is under 0 level, it would be ignored.
- Parameters
- successCallback : The method to call when the volume decreases 1 level successfully.
- errorCallback : The method to invoke when an error occurs.
- Return value
- N/A
- Exceptions
- throws TypeError
- if type of any parameters is not matched to specification.
- throws Error
- if unknown error occured.
- throws TypeError
- Examples
-
Decreasing the volume 1 level.
toast.tvaudiocontrol.setVolumeDown(function() { console.log('Success'); }, function(err) { console.log('Error: ' + err.message); });
-
This method gets the value of current volume.
- Parameters
- successCallback : The method to call when the value of current volume got successfully.
- errorCallback : The method to invoke when an error occurs.
- Return value
- N/A
- Exceptions
- throws TypeError
- if type of any parameters is not matched to specification.
- throws Error
- if unknown error occured.
- throws TypeError
- Examples
-
Getting the value of current volume.
toast.tvaudiocontrol.getVolume(function(value) { console.log('Success: ' + value); }, function(err) { console.log('Error: ' + err.message); });
-
void setVolumeChangeListener(VolumeChangeCallback callback, DOMStringCallback successCallback, optional ErrorCallback? errorCallback);
The method registers a volume change callback for getting notified when TV volume has been changed.
- Parameters
- callback : The method to invoke when the volume has been changed.
- successCallback : The method to call when the volume change callback is registered successfully.
- errorCallback : The method to invoke when an error occurs.
- Return value
- N/A
- Exceptions
- throws TypeError
- if type of any parameters is not matched to specification.
- throws Error
- if unknown error occured.
- throws TypeError
- Examples
-
When the volume has been changed, onVolumeChanged would be invoked.
function onVolumeChanged(volume){ console.log('volume changes to ' + volume); } toast.tvaudiocontrol.setVolumeChangeListener(onVolumeChanged, function() { console.log('Success'); }, function(err) { console.log('Error: ' + err.message); });
-
void unsetVolumeChangeListener(DOMStringCallback successCallback, optional ErrorCallback? errorCallback);
The method unregisters a volume change callback.
- Parameters
- successCallback : The method to call when the volume change callback is unregistered successfully.
- errorCallback : The method to invoke when an error occurs.
- Return value
- N/A
- Exceptions
- throws TypeError
- if type of any parameters is not matched to specification.
- throws Error
- if unknown error occured.
- throws TypeError
- Examples
-
unregister volume change callback.
toast.tvaudiocontrol.unsetVolumeChangeListener(function() { console.log('Success'); }, function(err) { console.log('Error: ' + err.message); });
-
None