Audio

Service URI - luna://com.webos.audio

Provides methods for volume control.
The Audio Setting service enables apps to control volume, with the following methods.

Methods

MethodDescriptionSupported in Emulator
setMutedMutes or unmutes the volume.Yes
volumeDownDecreases the volume by 1.Yes
volumeUpIncreases the volume by 1.Yes

setMuted

Description

Mutes or unmutes the volume.

Parameters

NameRequiredTypeDescription
mutedRequiredBooleanThe flag that indicates whether to mute the volume or unmute the volume.
  • true: mute the volume
  • false: unmute the volume

Call returns

NameRequiredTypeDescription
returnValueRequiredBoolean The flag that indicates the success/failure of the request.
  • true: Success
  • false: Failure
errorCodeOptionalNumbererrorCode contains the error code if the method fails. The method returns errorCode only if it fails.
See the Error Codes Reference of this method for more details.
errorTextOptionalStringerrorText contains the error text if the method fails. The method returns errorText only if it fails.
See the Error Codes Reference of this method for more details.

Error reference

Error CodeError Message
1Not a valid JSON message

Example

// One-time call
var request = webOS.service.request('luna://com.webos.audio', {
  method: 'setMuted',
  parameters: { muted: true },
  onSuccess: function (inResponse) {
    console.log('TV is muted');
    // To-Do something
  },
  onFailure: function (inError) {
    console.log('Failed to set muted');
    console.log('[' + inError.errorCode + ']: ' + inError.errorText);
    // To-Do something
    return;
  },
});

Return example

{
  'returnValue': true
}

See also

volumeDown

Description

Decreases the volume by 1.

Parameters

None

Call returns

NameRequiredTypeDescription
returnValueRequiredBoolean The flag that indicates the success/failure of the request.
  • true: Success
  • false: Failure
errorCodeOptionalNumbererrorCode contains the error code if the method fails. The method returns errorCode only if it fails.
See the Error Codes Reference of this method for more details.
errorTextOptionalStringerrorText contains the error text if the method fails. The method returns errorText only if it fails.
See the Error Codes Reference of this method for more details.

Error reference

Error CodeError Message
ERROR_3Parameters should be empty

Example

// One-time call
var request = webOS.service.request('luna://com.webos.audio', {
    method: 'volumeDown',
    onSuccess: function (inResponse) {
        console.log('The volume is decreased by 1.');
        // To-Do something
    },
	onFailure: function (inError) {
		console.log('Failed to decrease volume by 1.');
		console.log('[' + inError.errorCode + ']: ' + inError.errorText);
		// To-Do something
		return;
	}
});

Return example

{
  'returnValue': true
}

See also

volumeUp

Description

Increases the volume by 1.

Parameters

None

Call returns

NameRequiredTypeDescription
returnValueRequiredBoolean The flag that indicates the success/failure of the request.
  • true: Success
  • false: Failure
errorCodeOptionalNumbererrorCode contains the error code if the method fails. The method returns errorCode only if it fails.
See the Error Codes Reference of this method for more details.
errorTextOptionalStringerrorText contains the error text if the method fails. The method returns errorText only if it fails.
See the Error Codes Reference of this method for more details.

Error reference

Error CodeError Message
ERROR_3Parameters should be empty

Example

// One-time call
var request = webOS.service.request('luna://com.webos.audio', {
  method: 'volumeUp',
  onComplete: function (inResponse) {
    console.log('The volume is increased by 1.');
    // To-Do something
  },
  onFailure: function (inError) {
    console.log('Failed to increase volume by 1.');
    console.log('[' + inError.errorCode + ']: ' + inError.errorText);
    // To-Do something
    return;
  },
});

Return example

{
  'returnValue': true
}

See also

No Headings