Version: Smart Feature Phone 3.0

AudioVolumeManager service

Instanciating the service#

Load the following scripts:

<script src="http://127.0.0.1/api/v1/shared/core.js"></script>
<script src="http://127.0.0.1/api/v1/shared/session.js"></script>
<script src="http://127.0.0.1/api/v1/audiovolumemanager/service.js"></script>

You can then get an instance of the service with code similar to:

const session = new lib_session.Session();
const sessionstate = {};
let _audiovolumeManager = null;
sessionstate.onsessionconnected = function () {
console.log(`AudioVolumeManager onsessionconnected`);
lib_audiovolume.AudioVolumeManager.get(session).then((AudioVolumeManagerService) => {
console.log(`Got AudioVolumeManager : #AudioVolumeManagerService.service_id}`);
_audiovolumeManager = AudioVolumeManagerService;
}).catch((e) => {
console.log(`Error calling AudioVolumeManager service${JSON.stringify(e)}`);
_audiovolumeManager = null;
});
};
sessionstate.onsessiondisconnected = function () {
console.log(`AudioVolumeManager onsessiondisconnected Daemon Crashed`);
};
// On desktop version, set ENV WS_RUNTIME_TOKEN=secrettoken
session.open('websocket', 'localhost', 'secrettoken', sessionstate, true);

Then the developer can use _audiovolumeManager as AudioVolumeManager service instance.

This service implements the AudioVolume interface.


AudioVolumeState enumeration#

{
NONE,
VOLUME_UP,
VOLUME_DOWN,
VOLUME_SHOW
}


AudioVolume Interface#

Methods#

  requestVolumeDown requestVolumeShow requestVolumeUp

requestVolumeDown()

Resolves with void

Rejects with void


requestVolumeShow()

Resolves with void

Rejects with void


requestVolumeUp()

Resolves with void

Rejects with void


Events#

  AUDIO_VOLUME_CHANGED

The AUDIO_VOLUME_CHANGED event emits a AudioVolumeState

To manage this event, use code similar to:

function handleEvent(value) {
...
}
_audiovolumeManager.addEventListener(_audiovolumeManager.AUDIO_VOLUME_CHANGED_EVENT, handleEvent);
_audiovolumeManager.removeEventListener(_audiovolumeManager.AUDIO_VOLUME_CHANGED_EVENT, handleEvent);

Sample code#

New APIs sample code