DRMAgent Class
DRMAgent is a class provided for the webOSDev API.
Methods
Type | Name | Description |
---|---|---|
Constructor | DRMAgent | Creates a DRM agent. |
Method | getClientId | Returns a client ID of DRM. |
getDrmType | Returns a DRM type to be set. | |
getErrorCode | Returns an error code from the DRM service. | |
getErrorText | Returns a text represented by an error from the DRM service. | |
getRightsError | Returns error information when an error of the DRM license occurs during content playback. | |
load | Creates a client instance for a given type of DRM. | |
isLoaded | Checks whether a DRM client that corresponds to given application ID exists. | |
sendDrmMessage | Sends a DRM message to a DRM service. | |
unload | Removes a DRM client instance and deallocates relevant resources. |
DRMAgent
Description
Create a DRM agent.
Properties
Name | Type | Description |
---|---|---|
type | String | The type of DRM.
|
getClientId
Description
Returns a client ID of DRM.
Parameters
None
Example
function loadPlayer() {
var player = document.querySelector('video');
var options = {
mediaTransportType: 'PLAYREADY',
option: {
drm: {
type: drmAgent.getDrmType(),
clientId: drmAgent.getClientId(),
},
},
};
var mediaOption = encodeURI(JSON.stringify(options));
var source = document.createElement('source');
source.setAttribute('src', CONTENT_URL);
source.setAttribute('type', 'video/mp4;mediaOption=' + mediaOption);
player.appendChild(source);
player.load();
}
See also
- None
getDrmType
Description
Returns a DRM type to be set.
Parameters
None
Call returns
Name | Type | Description |
---|---|---|
type | String | The DRM type.
|
Example
function loadPlayer() {
var player = document.querySelector('video');
var options = {
mediaTransportType: 'PLAYREADY',
option: {
drm: {
type: drmAgent.getDrmType(),
clientId: drmAgent.getClientId(),
},
},
};
var mediaOption = encodeURI(JSON.stringify(options));
var source = document.createElement('source');
source.setAttribute('src', CONTENT_URL);
source.setAttribute('type', 'video/mp4;mediaOption=' + mediaOption);
player.appendChild(source);
player.load();
}
See also
- None
getErrorCode
Description
Returns an error code from the DRM service.
Parameters
None
Call returns
Returns the error code.
Example
drmAgent.load({
onSuccess: function (res) {
sendDrmMessage();
},
onFailure: function (res) {
// API calling error
console.log('error -', res.errorCode, '/', res.errorText);
// or but it does not guarantee sync
console.log(
'error -',
drmAgent.getErrorCode(),
'/',
drmAgent.getErrorText()
);
},
});
See also
getErrorText
Description
Returns a text represented by an error from the DRM service.
Parameters
None
Call returns
Returns the error text from the DRM service.
Example
drmAgent.load({
onSuccess: function (res) {
sendDrmMessage();
},
onFailure: function (res) {
// API calling error
console.log('error -', res.errorCode, '/', res.errorText);
// or but it does not guarantee sync
console.log(
'error -',
drmAgent.getErrorCode(),
'/',
drmAgent.getErrorText()
);
},
});
See also
getRightsError
Description
Returns error information when an error of the DRM license occurs during content playback.
This method is supported in the following DRM type only:
- PlayReady
Parameters
Name | Type | Description | Required | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
params | Object | The JSON object containing handlers Properties
| Yes |
Success Callback Returns
Name | Type | Description | Required |
---|---|---|---|
returnValue | Boolean | Flag that indicates success/failure of the request.
| Yes |
subscribed | Boolean | Flag that indicates whether the subscription is enabled or not.
| Yes |
errorCode | 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. | No |
errorText | 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. | No |
Failure Callback Returns
Name | Type | Description | |||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
error | Object | The JSON Object containing DRM service's error details. Properties
|
Call returns
Returns undefined.
Example
function getRightsError() {
drmAgent.getRightsError({
onSuccess: function (res) {
// playready only
// handle error
},
onFailure: function (res) {
// API calling error
},
});
}
See also
- None
isLoaded
Description
Checks whether a DRM client that corresponds to given application ID exists.
Parameters
Name | Type | Description | Required | |||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
params | Object | JSON object containing handlers. Properties
| Yes |
Success Callback Returns
Name | Type | Description | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
response | Object | JSON Object containing DRM service's error details. Properties
|
Failure Callback Returns
Name | Type | Description | |||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
error | Object | JSON Object containing DRM service's error details. Properties
|
Example
function isDrmLoaded() {
drmAgent.isLoaded({
onSuccess: function (res) {
if (res.loadStatus === true) {
loadDrm();
} else {
sendDrmMessage();
}
},
onFailure: function (res) {
// API calling error
},
});
}
See also
load
Description
Creates a client instance for a certain type of DRM.
The DRM type is specified when a DRM agent is created.
Parameters
Name | Type | Description | Required | |||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
params | Object | The JSON object containing handlers. Properties
| Yes |
Success Callback Returns (loadCallback)
Name | Type | Description | ||||||
---|---|---|---|---|---|---|---|---|
response | Object | The JSON object of return value. Properties
|
Failure Callback Returns (failureCallback)
Name | Type | Description | |||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
error | Object | JSON Object containing DRM service's error details. Properties
|
Call returns
Returns undefined.
Example
function loadDrm() {
drmAgent.load({
onSuccess: function (res) {
sendDrmMessage();
},
onFailure: function (res) {
// API calling error
},
});
}
See also
sendDrmMessage
Description
Sends a DRM message to a DRM service.
After receiving the message, the DRM service starts to parse the message and perform the DRM operation.
Parameters
Name | Type | Description | Required | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
params | Object | JSON object containing handlers. Properties
| No |
Success Callback Returns (sendDrmMessageCallback)
Name | Type | Description | ||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
response | Object | The JSON Object of result after sending messages. Properties
|
Failure Callback Returns (failureCallback)
Name | Type | Description | |||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
error | Object | The JSON Object containing DRM service's error details. Properties
|
Example
function sendDrmMessage() {
drmAgent.sendDrmMessage({
msg: 'some messages',
onSuccess: function (res) {
loadPlayer();
},
onFailure: function (res) {
// API calling error
},
});
}
See also
- None
unload
Description
Removes a DRM client instance and deallocates relevant resources.
Parameters
Name | Type | Description | Required | |||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
params | Object | The JSON object containing handlers. Properties
| Yes |
Success Callback Returns (unloadCallback)
Name | Type | Description |
---|---|---|
response | Object | Empty JSON Object |
Failure Callback Returns (failureCallback)
Name | Type | Description | |||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
error | Object | The JSON Object containing DRM service's error details. Properties
|
Call returns
Returns undefined.
Example
function unloadDrm() {
drmAgent.unload({
onSuccess: function (res) {
// do something
},
onFailure: function (res) {
// API calling error
},
});
}
See also
Error code reference
Name | Type | Description |
---|---|---|
NOT_ERROR | Number | No error. |
CLIENT_NOT_LOADED | Number | The DRM client is not loaded. |
VENDOR_ERROR | Number | The vendor managed error. |
API_NOT_SUPPORTED | Number | This API is not supported in the activated DRM. |
WRONG_CLIENT_ID | Number | There is no process matching to the client ID. |
KEY_NOT_FOUND | Number | It cannot find a key file in DRM store. |
INVALID_PARAMS | Number | A part of parameters is not valid data or format. |
UNSUPPORTED_DRM_TYPE | Number | It's not a supported DRM type. |
INVALID_KEY_FORMAT | Number | The key file is not a valid format. |
INVALID_TIME_INFO | Number | It cannot get the valid time information. |
DRM_TYPE_UNMATCHED | Number | The DRM type of the currently loaded client is not matched with the DRM type that was set when the DRM agent is created. |
UNKNOWN_ERROR | Number | It's an unknown error. |