Updated on 2024-10-30 GMT+08:00

Main Entry (HWLLSPlayer)

This section describes the HWLLSPlayer APIs of the LLL Web SDK.

Table 1 HRTC APIs

API

Description

checkSystemRequirements

Checks whether the browser supports the LLL Web SDK.

getVersion

Obtains the SDK version number.

createClient

Creates a client object for pulling live streams. If multiple live streams need to be pulled, you need to create multiple client objects.

uploadLog

Uploads logs.

saveLog

Saves logs.

setParameter

Configures global parameters.

setLogLevel

Sets the level of logs to be printed on the console.

setReportConfig

Sets the dotting capability and the authentication policy for dotting and log uploading.

on

Registers the callback for a client object event.

off

Deregisters the callback for a client object event.

checkSystemRequirements

checkSystemRequirements(): Promise<boolean>

[Function Description]

Checks whether the browser supports the LLL Web SDK.

[Request Parameters]

None

[Response Parameters]

Promise<boolean>: A Promise object is returned. The value true indicates that the browser is compatible with the LLL Web SDK. If they are incompatible, an error is returned.

LLL requires the WebRTC capability but some browsers may not support WebRTC playback. In this case, you can downgrade the playback based on the specific error code (HWLLS_ERROR_WEBRTC_UNSUPPORTED). For details, see SDK Usage.

getVersion

getVersion(): string

[Function Description]

Obtains the current SDK version number.

[Request Parameters]

None

[Response Parameters]

string: current SDK version number.

createClient

createClient(type: string): HWLLSClient | HWFlvClient | HWHlsClient

[Function Description]

Creates a client object for pulling live streams. If multiple live streams need to be pulled, you need to create multiple client objects.

[Request Parameters]

type: (optional) String type. Indicates the type of the client created for pulling streams.

  • Type of the client for pulling LLL streams: webrtc
  • Type of the client for pulling FLV streams: flv.
  • Type of the client for pulling HLS streams: hls (reserved)

Default value: webrtc

[Response Parameters]

client: client object for pulling streams.

uploadLog

async uploadLog(): Promise<void>

[Function Description]

Uploads logs.

[Request Parameters]

None

[Response Parameters]

Promise<void>: If tryCatch is used to obtain errors as an array, error information corresponding to multiple app IDs will be returned.

saveLog

async saveLog(): Promise<Blob>

[Function Description]

Users can flexibly save logs.

[Request Parameters]

None

[Response Parameters]

Promise<Blob>: Promise<Blob> compressed in .zip format, which can be directly saved as a .zip file.

setParameter

setParameter(parameterKey: string, parameterValue: any): boolean

[Function Description]

Configures global parameters.

[Request Parameters]

Parameter

Value

LOADING_CONFIG

LoadingConfig is defined as:

{

netQualityLoading: (optional) The type is Boolean. true indicates that the loading effect is displayed based on the network quality. The default value is false, indicating that the loading effect is not displayed.

netQualityLoadingThreshold: (optional) The type is number. Indicates the threshold of the network-quality for displaying the loading effect. The default network quality level is 5.

frameStuckLoading: (optional) The type is Boolean. true indicates that the loading effect is displayed based on the frame freezing duration. The default value is false, indicating that the loading effect is not displayed.

frameStuckThreshold: (optional) The type is number. Indicates the frame freezing duration threshold for displaying the loading effect. The unit is 100 ms. The default value is 10, indicating that the frame freezing duration is 1000 ms.

}

CAUTION:

You need to configure this parameter before starting playback.

DNS_QUERY_ENABLE

(Optional) Boolean type. true indicates that DNS resolution is enabled. false (default) indicates that DNS resolution is disabled.

ACCESS_DOMAIN

(Optional) String type. By default, this parameter is not specified, is used to configure the stream pull environment, and needs to be set by Huawei engineers.

GLSB_DOMAIN

(Optional) String type. By default, this parameter is not specified, is used to configure the GSLB environment, and needs to be set by Huawei engineers.

BACKGROUND_PLAY

(Optional) Boolean type. true indicates that background playback is enabled, and false (default) indicates that background playback is disabled.

[Response Parameters]

boolean: configuration parameter setting result. true indicates that the setting is successful. false indicates that the setting fails.

setLogLevel

setLogLevel(level: string): boolean

[Function Description]

Set the level of logs to be printed on the console. Otherwise, the default level is error.

[Request Parameters]

level: (mandatory) String type. A log level identifier.

  • none: Disables the function of printing logs of all levels.
  • error: Logs of the error level are printed.
  • warn: Logs of the warn level and higher levels are printed.
  • info: Logs of the info level and higher levels are printed.
  • debug: Logs of the debug level and higher levels are printed.

[Response Parameters]

boolean: log level setting result. true indicates that the log level is set successfully. false indicates that the log level fails to be set.

setReportConfig

setReportConfig(reportConfig:ReportConfig):boolear

[Function Description]

Sets the dotting capability and the authentication policy for dotting and log uploading.

[Request Parameters]

reportConfig: (mandatory) ReportConfig type. reportConfig is defined as follows:

  • enable: (mandatory) The value is of the Boolean type. true (default) indicates that dotting is enabled, and false indicates that dotting is disabled.
  • tokenConfig: (optional) The object definition is as follows:
    • enable: The value is of the Boolean type. true indicates that authentication is enabled, and false (default) indicates that authentication is disabled.
    • tokenInfo: The value is of the array type. The array contains the ReportTokenInfo class. ReportTokenInfo is defined as follows:
      • appid: The value is of the string type.
      • expTimestamp: The value is of the string type, indicating the expiration timestamp. The value is the current UNIX timestamp plus the authentication expiration time. The recommended value is 7200 seconds. The maximum value is 43200 seconds, that is, 12 hours.

        For example, if the current UNIX timestamp is 1708531200 and the authentication expiration time is 7200 seconds, the expiration timestamp is 1708538400, indicating that the verification string expires at 02:00:00 on February 22, 2024.

      • token: The value is of the string type. It is a string generated by hmac_sha256. hmac_sha256 (shared key, expiration timestamp + appID) The shared key is controlled and obtained by the user.

[Response Parameters]

A Boolean value is returned. Returns true if the value is set successfully; returns false otherwise.

If the authentication policy is enabled, the actual request status is obtained by registering the Error callback through the on function.

on

on(event: string, handler: function, withTimeout?: boolean): void

[Function Description]

Registers the callback for a client object event.

[Request Parameters]
  • event: (mandatory) event name, which is of the string type. It is used to register the Error event, listen for dotting, or upload error information in logs.
  • handler: (mandatory) event processing method. The type is function.
  • withTimeout: (optional) indicates whether a timeout error is reported. The value is of the Boolean type.

[Response Parameters]

None

off

off(event: string, handler: function): void

[Function Description]

Deregisters the callback for a client object event.

[Request Parameters]
  • event: (mandatory) event name, which is of the string type. It is used to deregister the Error event.
  • handler: (mandatory) event processing method. The type is function.

[Response Parameters]

None