Note
This API has been available since API level 13.
This API has been available since API level 13.
Provides an interface that allows the user to access and gain audio controls through a specific application to use audio resources.
Audio Focus Manager is a middleware service in webOS. It does the following operations:
Audio Focus Manager expects the following instructions to be followed by applications to use audio resources.
API level 13
Queries the current status of the audiofocusmanager.
Name | Required | Type | Description |
---|---|---|---|
subscribe | Optional | Boolean | Indicates if subscribed to get the notifications. Possible values are:
|
displayId | Required | Number | Indicates the audio focus information of mentioned display ID. |
Name | Required | Type | Description |
---|---|---|---|
returnValue | Optional | Boolean | Indicates the status of the operation.
|
subscribed | Optional | Boolean | Indicates if subscribed to get the notifications. Possible values are:
|
errorCode | Optional | Number | Indicates the error code for the failed operation. |
errorText | Optional | String | Describes the error. Returned only in case of execution failure. |
audioFocusStatus | Optional | Object array: audioFocusStatus | Contains the information of all granted request types per session in their request types (paused and active). |
Name | Required | Type | Description |
---|---|---|---|
returnValue | Required | Boolean | Indicates the status of the operation.
|
subscribed | Optional | Boolean | Indicates if subscribed to get the notifications. Possible values are:
|
audioFocusStatus | Optional | Object array: audioFocusStatus | Contains information of all granted request types per session in their request types (paused and active). |
Example : Gets status when there are NO active requests
# luna-send -i luna://com.webos.service.audiofocusmanager/getStatus '{"displayId":0, "subscribe":true}'
Response:
{
"subscribed":true,
"returnValue":true,
"audioFocusStatus":[
{
"pausedRequests":[
],
"displayId":0,
"activeRequests":[
]
}
]
}
Example : Gets status when there are active requests
# luna-send -n 1 luna://com.webos.service.audiofocusmanager/getStatus '{"subscribe":true, "displayId":0}'
Response:
{
"subscribed":true,
"returnValue":true,
"audioFocusStatus":[
{
"pausedRequests":[
],
"displayId":0,
"activeRequests":[
{
"appId":"com.webos.app.ml4",
"requestType":"AFREQUEST_GAIN",
"streamType":"pmedia"
}
]
}
]
}
API level 13
Releases the audio resource.
Name | Required | Type | Description |
---|---|---|---|
displayId | Required | Number | Indicates the display ID from which the application is releasing the focus. |
streamType | Required | String | Indicates what is the stream played by application once it gets the focus. Possible values are:
|
Name | Required | Type | Description |
---|---|---|---|
returnValue | Required | Boolean | Indicates the status of the operation.
|
result | Optional | String | Indicates the result. Possible values are:
|
errorCode | Optional | Number | Indicates the error code for the failed operation. |
errorText | Optional | String | Indicates the reason for the failure of the operation. See the API Error Codes Reference section for details. |
Example : Releasing audio focus
# luna-send -a "com.webos.app.notification" -n 1 -f luna://com.webos.service.audiofocusmanager/releaseFocus '{
"displayId":0,
"streamType":"pmedia"
}'
Response:
{
"returnValue":true,
"result":"AF_SUCCESSFULLY_RELEASED"
}
API level 13
Requests audio focus to access the audio resource
On subscription, applications get the following suggestions:
Name | Required | Type | Description |
---|---|---|---|
requestType | Required | String | Indicates the priority of application and acts accordingly. Audio Focus Manager expects the applications to come with any one of the following request types based on applications behavior:
|
subscribe | Required | Boolean | Indicates if subscribed to get the notifications. Possible values are:
Note: It will get the suggestion from the audiofocusmanager service to pause/stop/resume the audio playback. |
displayId | Required | Number | Indicates the display ID from which the application is requesting for focus. |
streamType | Required | String | Indicates what is the stream played by application once it gets the focus |
Name | Required | Type | Description |
---|---|---|---|
returnValue | Required | Boolean | Indicates the status of the operation.
|
subscribed | Optional | Boolean | Indicates if subscribed to get the notifications. Possible values are:
|
errorCode | Optional | Number | Indicates the error code for the failed operation. |
result | Optional | String | Indicates the result. Possible values are:
|
errorText | Optional | String | Indicates the reason for the failure of the operation. See the API Error Codes Reference section for details. |
Name | Required | Type | Description |
---|---|---|---|
returnValue | Required | Boolean | Indicates the status of the operation.
|
subscribed | Optional | Boolean | Indicates if subscribed to get the notifications. Possible values are:
|
result | Optional | String | Indicates the result. Possible values are:
|
Example : Requesting audio focus
# luna-send -a "com.webos.app.ml4" -i luna://com.webos.service.audiofocusmanager/requestFocus '{
"requestType":"AFREQUEST_GAIN",
"subscribe":true,
"streamType":"pmedia",
"displayId":0
}'
Response:
{
"subscribed":true,
"returnValue":true,
"result":"AF_GRANTED"
}
Provides information of all active requests.
Name | Required | Type | Description |
---|---|---|---|
appId | Optional | String | Indicates the application ID which acquired the audio resource. |
requestType | Optional | String | Indicates the request type. Possible values are;
|
Provides information of all granted request types per session in their request types (paused and active).
Name | Required | Type | Description |
---|---|---|---|
displayId | Required | String | Indicates the audio focus information of mentioned display ID |
pausedRequests | Required | Object: pausedRequests | Provides information of all paused requests. |
activeRequests | Required | Object: activeRequests | Provides information of all active requests. |
Provides information of all paused requests.
Name | Required | Type | Description |
---|---|---|---|
appId | Optional | String | Indicates the application ID which acquire the audio resource. |
requestType | Optional | String | Indicates the request type. Possible values are:
|
Error Code | Error Text | Error Description |
---|---|---|
1 | Audio focus manager invalid schema | Error occurs due to invalid json request. |
2 | Audio focus manager Unknown request type | Error occurs due to wrong request type. |
3 | Audio focus manager internal error | Error occurs due to insufficient resource availability in audiofocusmanager. |
Contents