webOSDev API
The webOSDev API provides methods for device information, digital rights management (DRM), and app launch.
Most methods of the webOSDev API are newly added, especially for webOS TV.
Methods
| Type | Name | Description |
|---|---|---|
Member | Holds properties representing the list of built-in apps opened on the webOS TV. | |
Holds properties that represent the DRM error number and the DRM type. | ||
Method | Returns the `DRMAgent` instance of a specific DRM type. | |
Launches an application with parameters. | ||
Passes parameters when an app is being launched after `webOS.launch` is called. | ||
Returns a device ID provided by the webOS TV (`LGUDID`) since webOS TV 3.0. | ||
Returns the network connection state. |
APP
Description
A member representing the list of built-in apps on the webOS TV opened to external developers.
Properties
Name | Type | Description |
|---|---|---|
BROWSER | String | The built-in browser on the webOS TV |
Example
// You can launch webOS browser application.
webOSDev.launch({
id: webOSDev.APP.BROWSER,
params: {
target: 'http://www.your-web-page.com', // target should be
},
onSuccess(res) {
// do something
},
onFailure(res) {
// handle error
},
});See also
None
DRM
Description
An object containing properties that represent the DRM error number and the DRM type.
Properties
Name | Type | Description |
|---|---|---|
error | DRMError | The error number from the DRM service |
type | DRMType | The type of DRM |
See also
None
drmAgent
Description
Returns `DRMAgent` instance of a specific DRM type.
For more details about `DRMAgent`, see DRMAgent.
Parameters
| Name | Type | Description | Required | ||||||
|---|---|---|---|---|---|---|---|---|---|
type | String | The DRM type to be set to the `DRMAgent` instance. Properties
| Yes |
Call returns
Returns the instance of `DRMAgent`.
Example
var drmagent;
drmagent = webOSDev.drmAgent(webOSDev.DRM.Type.PLAYREADY);See also
None
launch
Description
Launches an application with parameters.
Parameters
| Name | Type | Description | Required | |||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
parameters | Object | The JSON object containing an app ID, parameters, and callback handlers. Properties
| Yes |
Success callback returns
None
Failure callback returns
| Name | Type | Description | |||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
error | Object | The JSON object containing DRM service's error details. Properties
|
Call returns
Returns undefined.
Example
// In app A: launch app B with parameters
webOSDev.launch({
id: 'your.app.B',
params: {
userId: 'user',
page: 'shown page',
},
onSuccess: function (res) {
// do something
},
onFailure: function (res) {
// error
},
});
// In app B: receive the parameters passed by app A
document.addEventListener('webOSLaunch', function (data) {
console.log(data.detail.userId + ', ' + data.detail.page);
});
document.addEventListener('webOSRelaunch', function (data) {
console.log(data.detail.userId + ', ' + data.detail.page);
});
var params = webOSDev.launchParams();
if (params.userId === 'user') {
console.log(params.userId + ' wants to access to ' + params.page);
}See also
launchParams
Description
Passes parameters of an app launched by the `webOSDev.launch` method.
The parameters are usually delivered when the `webOSLaunch` event or `webOSRelaunch` event occurs. This method can be used to get the parameters from elsewhere where those events don't occur.
Parameters
None
Call returns
Name | Type | Description |
|---|---|---|
params | Object | Parameters passed to the app |
Example
var params = webOSDev.launchParams();
if (params) {
console.log(params.userId + ' wants to access to page ' + params.page);
}See also
LGUDID
Description
Returns the device ID provided by the webOS TV since webOS TV 3.0.
Parameters
| Name | Type | Description | Required | |||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
parameters | Object | The JSON object containing handlers. Properties
| Yes |
Success callback returns
| Name | Type | Description | ||||||
|---|---|---|---|---|---|---|---|---|
info | Object | The JSON object containing the device ID. Properties
|
Failure callback returns
| Name | Type | Description | |||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
info | Object | The JSON object containing UDID error details. Properties
|
Call returns
Returns undefined.
Example
webOSDev.LGUDID({
onSuccess: function (res) {
// user device from server
if (res.id === user.device) {
// do something
}
},
onFailure: function (res) {
// API calling error
},
});See also
None
connection.getStatus
Description
Returns the network connection state.
Parameters
| Name | Type | Description | Required | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
parameters | Object | The JSON object containing handlers. Properties
| Yes |
Success callback returns
| Name | Type | Description | |||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
response | Object | The JSON object containing the service's response data related to the network connection. Properties
|
Failure callback returns
| Name | Type | Description | |||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
info | Object | The JSON object containing the error details. Properties
|
Call returns
Returns undefined.
Example
webOSDev.connection.getStatus({
onSuccess: function (res) {
if (res.isInternetConnectionAvailable === false) {
// pop up network error message
} else {
if (res.wired) {
// do something
} else if (res.wifi) {
// do something
}
}
},
onFailure: function (res) {
// API calling error
},
subscribe: true,
});See also
None