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

Method

Description

Supported in Emulator

setMuted

Mutes or unmutes the volume.

Yes

volumeDown

Decreases the volume by 1.

Yes

volumeUp

Increases the volume by 1.

Yes

 

Open All


setMuted

Description

Mutes or unmutes the volume.

Syntax

setMuted(Boolean muted)

Parameters

Name

Required

Type

Description

muted

Required

Boolean

Flag that indicates whether to mute the volume or unmute the volume.

  • true: mute the volume

  • false: unmute the volume

Call Returns

Name

Required

Type

Description

returnValue

Required

Boolean

 Flag that indicates success/failure of the request.

  • true: Success

  • false: Failure

errorCode

Optional

Number

errorCode contains the error code if the method fails. The method will return errorCode only if it fails.

See the Error Codes Reference of this method for more details.

errorText

Optional

String

errorText contains the error text if the method fails. The method will return errorText only if it fails.

See the Error Codes Reference of this method for more details.

Error Reference

Error Code

Error Message

1

Not 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.

Syntax

volumeDown()

Parameters

None

Call Returns

Name

Required

Type

Description

returnValue

Required

Boolean

 Flag that indicates success/failure of the request.

  • true: Success

  • false: Failure

errorCode

Optional

Number

errorCode contains the error code if the method fails. The method will return errorCode only if it fails.

See the Error Codes Reference of this method for more details.

errorText

Optional

String

errorText contains the error text if the method fails. The method will return errorText only if it fails.

See the Error Codes Reference of this method for more details.

Error Reference

Error Code

Error Message

ERROR_3

Parameters 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.

Syntax

volumeUp()

Parameters

None

Call Returns

Name

Required

Type

Description

returnValue

Required

Boolean

 Flag that indicates success/failure of the request.

  • true: Success

  • false: Failure

errorCode

Optional

Number

errorCode contains the error code if the method fails. The method will return errorCode only if it fails.

See the Error Codes Reference of this method for more details.

errorText

Optional

String

errorText contains the error text if the method fails. The method will return errorText only if it fails.

See the Error Codes Reference of this method for more details.

Error Reference

Error Code

Error Message

ERROR_3

Parameters 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



Navigation