Client Object (HWLLSClient)
This section describes the HWLLSClient APIs of the LLL web SDK.
API |
Description |
---|---|
Starts playback. The client obtains the corresponding live stream from the server based on the entered URL. |
|
Quickly switches to the next stream. |
|
Stops the playback. |
|
Replays the video. |
|
Customizes the playback. |
|
Resumes the playback. |
|
Pauses the playback. |
|
Pauses the video playback. |
|
Resumes the video playback. |
|
Pauses the audio playback. |
|
Resumes the audio playback. |
|
Sets the playback volume. |
|
Obtains the audio volume. |
|
Mutes a site or all sites. |
|
Specifies whether to enable stream statistics. |
|
Enables or disables media stream status detection. |
|
Registers the callback for a client object event. |
|
Deregisters the callback for a client object event. |
|
Destroys a client object. |
|
Enables/Disables full-screen display. |
startPlay
startPlay(url: string, options: StartPlayOptions): Promise<void>
[Function Description]
Starts playback. The client obtains the corresponding live stream from the server based on the entered URL.
[Request Parameters]
- url: (mandatory) String type. A streaming URL is in the format of webrtc://{domain}/{AppName}/{StreamName}.
- webrtc://: The value is fixed, indicating that streams are pulled using WebRTC.
- domain: indicates the streaming domain name. Use the streaming domain name registered with Huawei Cloud.
- AppName: indicates the application name. Use the application name registered with Huawei Cloud.
- StreamName: indicates the stream name, which must be the same as the pushed stream name.
- options: (mandatory) Playback configuration parameter. The value is of StartPlayOptions type. The definition of StartPlayOptions is as follows: {
- elementId: (mandatory) indicates the playback DOM ID.
- objectFit: (optional) String type. Default value: cover. The following enumerated values are supported:
- contain: preferentially ensures that all video content is displayed. The video is scaled proportionally until one side of the video window is aligned with the window border. If the video size is inconsistent with the display window size, when the aspect ratio is locked and the video is zoomed in or out to fill the window, a black bar is displayed around the zoomed-in or zoomed-out video.
- cover: preferentially ensures that the window is filled. The video is scaled proportionally until the entire window is filled with video. If the video size is inconsistent with the display window size, the video stream will be cropped or the image will be stretched to fill the display window.
- fill: The window is filled with video. If the aspect ratio of the video does not match the window, the video will be stretched to fit the window.
- muted: (optional) Boolean type. true indicates muted; false indicates unmuted. The default value is false.
- sessionId: (optional) String type. Indicates the unified ID of a complete session.
- showLoading: (optional) Boolean type. Indicates whether to enable the loading display effect. true indicates that the loading display effect is enabled. The default value is false. When this parameter is set to true, the loading effect upon playback start will also be enabled. The loading effect upon buffering during playback needs to be set based on the LOADING_CONFIG in the setParameter API.
- The QQ browser on Android devices does not support this function.
- You are advised to leave showLoading blank or set it to false.
- autoPlay: (optional) Boolean type. true indicates that the autoplay function is enabled. false indicates that the autoplay function needs to be manually triggered. The default value is true.
- poster: (optional) The object definition is as follows: {
- url: (optional) String type. Sets the complete address of the thumbnail image to be played. The image must be in JPG, PNG, or static GIF format, the size cannot exceed 1 MB, and the resolution cannot exceed 1920 x 1080. The file name cannot contain Chinese characters.
- mode: (optional) String type. The default value is crop. The following enumerated values are supported: {
- fill: The window is filled with video. If the aspect ratio of the video does not match the window, the video will be stretched to fit the window.
- crop: original size of the video thumbnail. If the thumbnail exceeds the playback area, the excess part is cropped. Otherwise, the thumbnail is displayed in the middle of the playback window.
}
- startEnable: (optional) Boolean type. Indicates whether to display the thumbnail when the playback starts. The options are true and false. The default value is false. This parameter takes effect only in non-autoplay scenarios.
- pauseEnable: (optional) Boolean type. Indicates whether to display the thumbnail on the playback page when the video is paused. The options are true and false. The default value is false.
}
- webrtcConfig: (optional) WebRTCConfig type. Specifies parameters for pulling streams of a specified media type. WebRTCConfig is defined as follows: {
- receiveVideo: (optional) Boolean type. Pulls a video for playback. true indicates that a video is pulled for playback, and false indicates that a video is not pulled for playback. The default value is true. This parameter and receiveAudio cannot be set to false at the same time.
- receiveAudio: (optional) Boolean type. Indicates whether to pull an audio for playback. true indicates that an audio is pulled for playback, and false indicates that an audio is not pulled for playback. The default value is true. This parameter and receiveVideo cannot be set to false at the same time.
}
- domainPolicy: (optional) DomainPolicy type. Specifies the policy of an access domain name. This setting takes effect only when schedulePolicy is set to DNS. DomainPolicy is defined as follows: {
- 0: (optional) Number type. Indicates that the user-defined domain name is used. The default value is 0.
- 1: (optional) Number type. Indicates that the public access domain name is used.
}
- autoDowngrade: (optional) Boolean type. true indicates that automatic downgrade is enabled, and false (default) indicates not.
- downgradeUrl: (optional) The object definition is as follows: {
- hlsUrl?: (optional) String type. Identifies the downgraded HLS streaming URL.
- flvUrl?: (optional) String type. Identifies the downgraded FLV streaming URL.
}
[Response Parameters]
Promise<void>: returns a Promise object.
When the LLL service is faulty, the error code HWLLS_BUSINESS_DOWNGRADE can be used to downgrade the playback. For details, see SDK Usage.
switchPlay
switchPlay(url: string, options: StartPlayOptions): Promise<void>
[Function Description]
After the playback has been started, the system quickly switches to the next stream.
[Request Parameters]
- url: (mandatory) Ingest URL. A streaming URL is in the format of webrtc://{domain}/{AppName}/{StreamName}.
- webrtc://: The value is fixed, indicating that streams are pulled using WebRTC.
- domain: indicates the streaming domain name. Use the streaming domain name registered with Huawei Cloud.
- AppName: indicates the application name. Use the application name registered with Huawei Cloud.
- StreamName: indicates the stream name, which must be the same as the pushed stream name.
- options: (optional) Playback configuration parameter. The value is of StartPlayOptions type. If this parameter is not carried, the options data carried in the first playback start request is reused. The definition of StartPlayOptions is as follows: {
- elementId: (mandatory) indicates the playback DOM ID.
- objectFit: (optional) String type. Default value: cover. The following enumerated values are supported:
- contain: preferentially ensures that all video content is displayed. The video is scaled proportionally until one side of the video window is aligned with the window border. If the video size is inconsistent with the display window size, when the aspect ratio is locked and the video is zoomed in or out to fill the window, a black bar is displayed around the zoomed-in or zoomed-out video.
- cover: preferentially ensures that the window is filled. The video is scaled proportionally until the entire window is filled with video. If the video size is inconsistent with the display window size, the video stream will be cropped or the image will be stretched to fill the display window.
- fill: The window is filled with video. If the aspect ratio of the video does not match the window, the video will be stretched to fit the window.
- muted: (optional) Boolean type. true indicates muted; false indicates unmuted. The default value is false.
- sessionId: (optional) String type. Indicates the unified ID of a complete session.
- showLoading: (optional) Boolean type. Indicates whether to enable the loading display effect. true indicates that the loading display effect is enabled. The default value is false. When this parameter is set to true, the loading effect upon playback start will also be enabled. The loading effect upon buffering during playback needs to be set based on the LOADING_CONFIG in the setParameter API.
- autoPlay: (optional) Boolean type. true indicates that the autoplay function is enabled. false indicates that the autoplay function needs to be manually triggered. The default value is true.
- poster: (optional) The object definition is as follows: {
- url: (optional) String type. Sets the complete address of the thumbnail image to be played. The image must be in JPG, PNG, or static GIF format, the size cannot exceed 1 MB, and the resolution cannot exceed 1920 x 1080. The file name cannot contain Chinese characters.
- mode: (optional) String type. The default value is cover. The following enumerated values are supported: {
- fill: The window is filled with video. If the aspect ratio of the video does not match the window, the video will be stretched to fit the window.
- crop: original size of the video thumbnail. If the thumbnail exceeds the playback area, the excess part is cropped. Otherwise, the thumbnail is displayed in the middle of the playback window.
}
- startEnable: (optional) Boolean type. Indicates whether to display the thumbnail when the playback starts. The options are true and false. The default value is false. This parameter takes effect only in non-autoplay scenarios.
- pauseEnable: (optional) Boolean type. Indicates whether to display the thumbnail on the playback page when the video is paused. The options are true and false. The default value is false.
}
- webrtcConfig: (optional) WebRTCConfig type. Specifies parameters for pulling streams of a specified media type. WebRTCConfig is defined as follows: {
- receiveVideo: (optional) Boolean type. Pulls a video for playback. true indicates that a video is pulled for playback, and false indicates that a video is not pulled for playback. The default value is true. This parameter and receiveAudio cannot be set to false at the same time.
- receiveAudio: (optional) Boolean type. Indicates whether to pull an audio for playback. true indicates that an audio is pulled for playback, and false indicates that an audio is not pulled for playback. The default value is true. This parameter and receiveVideo cannot be set to false at the same time.
}
- schedulePolicy: (optional) SchedulePolicy type. Specifies the access scheduling policy. The definition of SchedulePolicy is as follows: {
- DNS: (optional) String type. Indicates that the domain name is resolved by DNS for being accessed. The default value is DNS.
- HTTPDNS: (optional) String type. Indicates that HTTPDNS is used for the access domain name.
}
- domainPolicy: (optional) DomainPolicy type. Specifies the policy of an access domain name. This setting takes effect only when schedulePolicy is set to DNS. DomainPolicy is defined as follows: {
- 0: (optional) Number type. Indicates that the user-defined domain name is used. The default value is 0.
- 1: (optional) Number type. Indicates that the public access domain name is used.
}
[Response Parameters]
Promise<void>: returns a Promise object.
When the LLL service is faulty, the error code HWLLS_BUSINESS_DOWNGRADE can be used to downgrade the playback. For details, see SDK Usage.
stopPlay
stopPlay(): boolean
[Function Description]
Stops the playback.
[Request Parameters]
None
[Response Parameters]
boolean: result of stopping playback. The options are true (success) and false (failure).
replay
replay(): Promise<boolean>
[Function Description]
Replays the video.
[Request Parameters]
None
[Response Parameters]
Promise<boolean>: replay result. The options are true (success) and false (failure).
startPlayCustomize
startPlayCustomize(url: string, options: StartPlayOptions): Promise<boolean>
[Function Description]
Customizes the playback.
[Request Parameters]
- url: (mandatory) Ingest URL. Streaming URL, which is a customized URL for playback.
- options: (optional) Playback configuration parameter. The value is of StartPlayOptions type. If this parameter is not carried, the options data carried in the first playback start request is reused. The definition of StartPlayOptions is as follows: {
- elementId: (mandatory) indicates the playback DOM ID.
- objectFit: (optional) String type. Default value: cover. The following enumerated values are supported:
- contain: preferentially ensures that all video content is displayed. The video is scaled proportionally until one side of the video window is aligned with the window border. If the video size is inconsistent with the display window size, when the aspect ratio is locked and the video is zoomed in or out to fill the window, a black bar is displayed around the zoomed-in or zoomed-out video.
- cover: preferentially ensures that the window is filled. The video is scaled proportionally until the entire window is filled with video. If the video size is inconsistent with the display window size, the video stream will be cropped or the image will be stretched to fill the display window.
- fill: The window is filled with video. If the aspect ratio of the video does not match the window, the video will be stretched to fit the window.
- muted: (optional) Boolean type. true indicates muted; false indicates unmuted. The default value is false.
- sessionId: (optional) String type. Indicates the unified ID of a complete session.
- showLoading: (optional) Boolean type. Indicates whether to enable the loading display effect. true indicates that the loading display effect is enabled. The default value is false. When this parameter is set to true, the loading effect upon playback start will also be enabled. The loading effect upon buffering during playback needs to be set based on the LOADING_CONFIG in the setParameter API.
- autoPlay: (optional) Boolean type. true indicates that the autoplay function is enabled. false indicates that the autoplay function needs to be manually triggered. The default value is true.
- poster: (optional) The object definition is as follows: {
- url: (optional) String type. Sets the complete address of the thumbnail image to be played. The image must be in JPG, PNG, or static GIF format, the size cannot exceed 1 MB, and the resolution cannot exceed 1920 x 1080. The file name cannot contain Chinese characters.
- mode: (optional) String type. The default value is cover. The following enumerated values are supported: {
- fill: The window is filled with video. If the aspect ratio of the video does not match the window, the video will be stretched to fit the window.
- crop: original size of the video thumbnail. If the thumbnail exceeds the playback area, the excess part is cropped. Otherwise, the thumbnail is displayed in the middle of the playback window.
}
- startEnable: (optional) Boolean type. Indicates whether to display the thumbnail when the playback starts. The options are true and false. The default value is false. This parameter takes effect only in non-autoplay scenarios.
- pauseEnable: (optional) Boolean type. Indicates whether to display the thumbnail on the playback page when the video is paused. The options are true and false. The default value is false.
}
- webrtcConfig: (optional) WebRTCConfig type. Specifies parameters for pulling streams of a specified media type. WebRTCConfig is defined as follows: {
- receiveVideo: (optional) Boolean type. Pulls a video for playback. true indicates that a video is pulled for playback, and false indicates that a video is not pulled for playback. The default value is true. This parameter and receiveAudio cannot be set to false at the same time.
- receiveAudio: (optional) Boolean type. Indicates whether to pull an audio for playback. true indicates that an audio is pulled for playback, and false indicates that an audio is not pulled for playback. The default value is true. This parameter and receiveVideo cannot be set to false at the same time.
}
- schedulePolicy: (optional) SchedulePolicy type. Specifies the access scheduling policy. The definition of SchedulePolicy is as follows: {
- DNS: (optional) String type. Indicates that the domain name is resolved by DNS for being accessed. The default value is DNS.
- HTTPDNS: (optional) String type. Indicates that HTTPDNS is used for the access domain name.
}
- domainPolicy: (optional) DomainPolicy type. Specifies the policy of an access domain name. This setting takes effect only when schedulePolicy is set to DNS. DomainPolicy is defined as follows: {
- 0: (optional) Number type. Indicates that the user-defined domain name is used. The default value is 0.
- 1: (optional) Number type. Indicates that the public access domain name is used.
}
[Response Parameters]
Promise<void>: returns a Promise object.
resume
resume(): Promise<boolean>
[Function Description]
Resumes the playback.
[Request Parameters]
None
[Response Parameters]
Promise<boolean>: result of resuming the audio/video playback. The options are true (success) and false (failure).
pause
pause(): boolean
[Function Description]
Pauses the audio/video playback.
[Request Parameters]
None
[Response Parameters]
boolean: playback pause result. The options are true (success) and false (failure).
pauseVideo
pauseVideo(): boolean
[Function Description]
This parameter is used to pause a video. After the video is paused, it freezes.
[Request Parameters]
None
[Response Parameters]
boolean: result of pausing video playback. The options are true (success) and false (failure).
resumeVideo
resumeVideo(): Promise<boolean>
[Function Description]
Resumes the video playback.
[Request Parameters]
None
[Response Parameters]
Promise<boolean>: result of resuming the video playback. The options are true (success) and false (failure).
pauseAudio
pauseAudio(): boolean
[Function Description]
Pauses the audio playback.
[Request Parameters]
None
[Response Parameters]
boolean: result of pausing the audio playback. The options are true (success) and false (failure).
resumeAudio
resumeAudio(): Promise<boolean>
[Function Description]
Resumes the audio playback.
[Request Parameters]
None
[Response Parameters]
Promise<boolean>: result of resuming the audio playback. The options are true (success) and false (failure).
setPlayoutVolume
setPlayoutVolume(volume: number): boolean
[Function Description]
Sets the audio volume. This API is not supported on iOS.
[Request Parameters]
volume: (mandatory) audio volume. The value is a number ranging from 0 to 100.
[Response Parameters]
boolean: whether the operation is successful. The options are true (success) and false (failure).
getPlayoutVolume
getPlayoutVolume(): number
[Function Description]
Obtains the audio volume.
[Request Parameters]
None
[Response Parameters]
number: volume value. The value ranges from 0 to 100.
muteAudio
muteAudio(isMute: boolean): void
[Function Description]
Mutes.
[Request Parameters]
- isMute: (mandatory) indicates whether the device is muted. The value is of the Boolean type. true indicates that the device is muted, and false indicates that the device is unmuted.
[Response Parameters]
None
streamStatistic
streamStatistic(enable: boolean, interval: number): void
[Function Description]
Specifies whether to enable stream statistics.
[Request Parameters]
- enable: (mandatory) Specifies whether to enable stream statistics. The value is of the Boolean type. The value true indicates that stream statistics are enabled.
- interval: (mandatory) Specifies the statistics interval, in seconds. The value is a number ranging from 1 to 60. The default value is 1.
[Response Parameters]
None
enableStreamStateDetection
enableStreamStateDetection(enable: boolean, interval: number, interruptRetry:StreamInterruptRetry): boolean
[Function Description]
Enables or disables media stream status detection. After the function is enabled, the system can detect whether the stream has been interrupted at the stream push device.
[Request Parameters]
- enable: (mandatory) whether to enable media stream status detection. The value is of the Boolean type. true indicates enabled; false (default value) indicates disabled.
- interval: (mandatory) Specifies the interval in seconds. The value is a number ranging from 1 to 60. This parameter is used to determine when there is no media stream. The default value is 3 (recommended).
- interruptRetry: (optional) Parameter for configuring playback retry upon stream interruption. The value is of StreamInterruptRetry type. The definition of StreamInterruptRetry is as follows: {
enable: The value is of the Boolean type. Attempt for automatically resuming playback is enabled after stream interruption. The default value is false, indicating that attempt for automatically resuming playback is disabled.
retryInterval: retry interval for stream pulling, in seconds. The value type is number. The value ranges from 10 to 60 and defaults to 30.
retryTimes: maximum number of retry times for resuming playback. The value type is number. The minimum value is 1 and the default value is 30.
}
[Response Parameters]
boolean: whether the operation is successful. The options are true (success) and false (failure).
The QQ browser on Android devices does not support this function.
on
on(event: string, handler: function, withTimeout?: boolean): void
[Function Description]
Registers the callback for a client object event.
- event: (mandatory) event name. The type is string. For details, see HWLLSClientEvent.
- 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.
- event: (mandatory) event name. The type is string. For details, see HWLLSClientEvent.
- handler: (mandatory) event processing method. The type is function.
[Response Parameters]
None
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot