DRMAgent

DRMAgent is a class provided for the webOSDev API. 

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.

 

Open


DRMAgent

Description

Create a DRM agent.

Properties

Name

Type

Description

type

String

The type of DRM.

  • PLAYREADY: PlayReady
  • WIDEVINE: Widevine

getClientId

Description

Returns a client ID of DRM.

Syntax

DRMAgent.getClientId()

Parameters

None​

Example

function loadPlayer() {
    var player = document.querySelector('video');
    var options = {
        mediaTransportType: 'WIDEVINE',
        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.

Syntax

DRMAgent.getDrmType()

Parameters

None

Call Returns

Name

Type

Description

type

String

The DRM type.

  • PLAYREADY: PlayReady
  • WIDEVINE: Widevine

Example

function loadPlayer() {
    var player = document.querySelector('video');
    var options = {
        mediaTransportType: 'WIDEVINE',
        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. 

Syntax

DRMAgent.getErrorCode()

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.

Syntax

DRMAgent.getErrorText()

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

Syntax

DRMAgent.getRightsError(params)

Parameters

Name

Type

Description

Required

params

Object

The JSON object containing handlers

Properties

Name

Type

Description

Required

onSuccess

Function

The callback function called when the method succeeds.

Yes

onFailure

Function

The callback function called when the method fails. 

Yes

Yes

Success Callback Returns

Name

Type

Description

Required

returnValue

Boolean

 Flag that indicates success/failure of the request.

  • true: Success

  • false: Failure

Yes

subscribed

Boolean

Flag that indicates whether the subscription is enabled or not.

  • true: Enabled

  • false: Not enabled

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

Name

Type

Description

errorCode

Number

The error code returned when the method fails.

errorText

String

The error text returned when the method fails.

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.

Syntax

DRMAgent.isLoaded(params)

Parameters

Name

Type

Description

Required

params

Object

JSON object containing handlers.

Properties

Name

Type

Description

onSuccess

Function

The callback function called when the method succeeds.

onFailure

Function

The callback function called when the method fails. 

Yes

Success Callback Returns

Name

Type

Description

response

Object

JSON Object containing DRM service's error details.

Properties

Name

Type

Description

loadStatus

Boolean

Indicates the DRM client is loaded.

  • true: the DRM client is loaded.

  • false: the DRM client is not loaded.

clientId

String

Returns the loaded client ID when the DRM client is loaded successfully.

drmType

String

Returns the client type of DRM when the DRM client is loaded successfully.

Failure Callback Returns

Name

Type

Description

error

Object

JSON Object containing DRM service's error details.

Properties

Name

Type

Description

errorCode

Number

The error code returned when the method fails.

errorText

String

The error text returned when the method fails.

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.

Syntax

DRMAgent.load(params)

Parameters

Name

Type

Description

Required

params

Object

The JSON object containing handlers.

Properties

Name

Type

Description

onSuccess

Function

The callback function called when the method succeeds.

onFailure

Function

The callback function called when the method fails. 

Yes

Success Callback Returns (loadCallback)

Name

Type

Description

response

Object

The JSON object of return value.

Properties

Name

Type

Description

clientId

String

If the DRM agent loaded the DRM client successfully, return its client ID.

Failure Callback Returns (failureCallback)

Name

Type

Description

error

Object

JSON Object containing DRM service's error details.

Properties

Name

Type

Description

errorCode

Number

The error code returned when the method fails.

errorText

String

The error text returned when the method fails.

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.

Syntax

DRMAgent.sendDrmMessage(params)

Parameters

Name

Type

Description

Required

params

Object

JSON object containing handlers.

Properties

Name

Type

Description

msg

String

The message to be provided to the underlying DRM server, which is formatted according to the DRM type.

onSuccess

Function

The callback function called when the method succeeds.

onFailure

Function

The callback function called when the method fails. 

No

Success Callback Returns (sendDrmMessageCallback)

Name

Type

Description

response

Object

The JSON Object of result after sending messages.

Properties

Name

Type

Attributes

Description

msgId

String

<optional>

The unique ID of message which has led to this resulting message.

resultCode

Number

<optional>

The result code only for PlayReady.

resultMsg

String

<optional>

The DRM system specific result message only for PlayReady.

Failure Callback Returns (failureCallback)

Name

Type

Description

error

Object

The JSON Object containing DRM service's error details.

Properties

Name

Type

Description

errorCode

Number

The error code returned when the method fails.

errorText

String

The error text returned when the method fails.

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.

Syntax

DRMAgent.unload(params)

Parameters

Name

Type

Description

Required

params

Object

The JSON object containing handlers.

Properties

Name

Type

Description

onSuccess

Function

The callback function called when the method succeeds.

onFailure

Function

The callback function called when the method fails.

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

Name

Type

Description

errorCode

Number

The error code returned when the method fails.

errorText

String

The error text returned when the method fails.

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.

 


Navigation