Samsung Electronics logo

Audio Control

Table of Contents


The Audio Control API provides a way to control audio features on the TV-associated device. The AudioControl module supports controlling audio-related functions of the Smart TV platform. Sing It allows developers a way to control and handle mute and volume features on TV-associated devices, for example, it sets the mute state of audio device to “MUTE” or “UNMUTE” and also provides a feature that allows you to get the mute state. You can also set the volume of the DTV system using this module. Using Audio Control API capabilities, your application can:

Prerequisites

The ImageView API lets you play the image media content on a TV. When the application is launched, an ImageView object is automatically instantiated in the webapis object. The webapis.imageview object is an instance of the ImageViewManager interface, which gives the method to handle image content play on the TV. The following figure shows how the API objects are structured inside the application window. Adding the JavaScript file to your application is required. This is the script to add to the webapis file:

 
<html><head>
<!-- including the JavaScript file which supports Samsung Web API -->
<script type="text/javascript" language="javascript" src="$MANAGER_WIDGET/Common/webapi/1.0/webapis.js"></script>
</head></html>

Control Volume

You can use the Samsung Web APIs to control the audio features of TV-associated devices. A webapis.audiocontrol object provides access to the functionality of the audiocontrol API.

Request setting mute state

The Audio Control API provides methods that allow you to request setting the mute state of the audio device. The following values are supported for each mute state:

  • true: Passing this value as an argument sets the mute state to MUTE in the audio device
  • false: Passing this value as an argument sets the mute state to UNMUTE in the audio device

To request setting the mute state, call the setMute() method, passing the respective value of mute state as mentioned above. On successful execution, the return value will be true; else the return value is false.

 
var audioControlObject= webapis.audiocontrol;  
audioControlObject.setMute(true);

Request to get mute state

The Audio Control API provides methods that allow you to request getting the mute state of the audio device. To request getting the mute state, call the getMute() method. On successful execution, the return value is true if audio is mute, false if audio is not mute.

 
var audioControlObject= webapis.audiocontrol;  
alert(“The mute state is”+ audioControlObject.getMute());

Request setting volume

The Audio Control API provides methods that allow you to request setting the volume of the audio device. The following values are supported as arguments to set the volume.

  • To be numeric: range (0 to 100)

Using this value, the volume of the respective audio device is set to given numeric value. The value to set the volume ranges between 0 and 100. To request setting the volume of the audio device, call the setVolume() method. On successful execution, the return value is “true”; else the return value is “false”.

 
var audioControlObject= webapis.audiocontrol;                                  
audioControlObject.audiocontrol.setVolume(25);

Request setting volume up

The Audio Control API provides methods that allow you to request increased volume of the DTV system. The volume range is 0 to 100. To request setting the volume of the audio device, call the setVolumeUp () method.

 
var audioControlObject= webapis.audiocontrol;                                     
audioControlObject.audiocontrol.setVolumeUp();

Request setting volume down

The Audio Control API provides methods that allow you to request decreased volume of the DTV system. The volume range is 0 to 100. To request setting the volume of the audio device, call the setVolumeDown () method.

 
var audioControlObject= webapis.audiocontrol;                                 
audioControlObject.audiocontrol.setVolumeDown();

Request getting volume

The Audio Control API provides methods that allow you to request getting the volume of the DTV system. The range of volume is 0 to 100. To request setting the volume of the audio device, call the getVolume() method. On successful execution, the return value is the volume of the audio device, which ranges between 0 and 100.

 
var audioControlObject= webapis.audiocontrol;  
alert(“the volume of Audio device is”+audioControlObject.audiocontrol.getVolume());

Check Audio Output Mode

The Audio Control API provides methods that allow you to request getting the output mode of the current audio device. To request getting the output mode of the current audio device, call the getOutputMode() method. On successful execution, the return value can be ”MODE_AUDIO_OUTPUT_PCM”, ”MODE_AUDIO_OUTPUT_DOLBY”, “MODE_AUDIO_OUTPUT_DTS” based on the current audio device.

 
var audioControlObject= webapis.audiocontrol;  
alert(“the output mode of current audio devices”+audioControlObject.audiocontrol.getOutputMode());
Interface Attributes Description
AudioControlManager const unsigned short MODE_AUDIO_OUTPUT_PCM = 0 External Output mode of PCMM
const unsigned short MODE_AUDIO_OUTPUT_DOLBY = 1 External Output mode of DOLBY
const unsigned short MODE_AUDIO_OUTPUT_DTS = 2 External Output mode of DTS

Make a Beep Sound

The Audio Control API provides methods that allow you to request playing a specific beep sound of the audio device. To request playing the beep sound, call the playSound () method. The application must provide the input parameter as sound type. On successful execution, the return value can be true or false.

 
try {
     webapis.audiocontrol.playSound(webapis.audiocontrol.AUDIO_SOUND_TYPE_UP);
} catch (error) {
     console.log(error.name);
}

The following table shows the sound type available for beep sound play:

Interface Attributes Value
AudioControlManager AUDIO_SOUND_TYPE_UP 1
AUDIO_SOUND_TYPE_DOWN 2
AUDIO_SOUND_TYPE_LEFT 3
AUDIO_SOUND_TYPE_RIGHT 4
AUDIO_SOUND_TYPE_PAGE_LEFT 5
AUDIO_SOUND_TYPE_PAGE_RIGHT 6
AUDIO_SOUND_TYPE_BACK 7
AUDIO_SOUND_TYPE_SELECT 8
AUDIO_SOUND_TYPE_CANCEL 9
AUDIO_SOUND_TYPE_WARNING 10
AUDIO_SOUND_TYPE_KEYPAD 11
AUDIO_SOUND_TYPE_KEYPAD_ENTER 12
AUDIO_SOUND_TYPE_KEYPAD_DEL 13
AUDIO_SOUND_TYPE_SMARTCONTROL_MOVE 14
AUDIO_SOUND_TYPE_SMARTCONTROL_SELECT 15
AUDIO_SOUND_TYPE_MOVE 16
AUDIO_SOUND_TYPE_PREPARING 17