Updated on 2024-03-22 GMT+08:00

Client Object (HWFlvClient)

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

Table 1 HRTC APIs

API

Description

startPlay

Starts playback. The client obtains the corresponding live stream from the server based on the entered URL.

switchPlay

Quickly switches to the next stream.

stopPlay

Stops the playback.

replay

Replays the video.

resume

Resumes the playback.

pause

Pauses the playback.

pauseVideo

Pauses the video playback.

resumeVideo

Resumes the video playback.

pauseAudio

Pauses the audio playback.

resumeAudio

Resumes the audio playback.

setPlayoutVolume

Sets the playback volume.

getPlayoutVolume

Obtains the audio volume.

muteAudio

Mutes.

streamStatistic

Specifies whether to enable stream statistics.

enableStreamStateDetection

Enables or disables media stream status detection.

destoryClient

Destroys a client object.

fullScreenToggle

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. Ingest URL that ends with flv.
  • options: (optional) 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: prioritizes the display of all video content. 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: prioritizes the filling of the window. 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: This parameter does not need to be transferred.
    • 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 thumbnail. If the poster exceeds the playback area, the excess part is cropped. Otherwise, the poster 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: This parameter does not need to be transferred.
    • schedulePolicy: This parameter does not need to be transferred.
    • domainPolicy: This parameter does not need to be transferred.
    • downgradeUrl: This parameter does not need to be transferred.

[Response Parameters]

Promise<void>: returns a Promise object.

switchPlay

switchPlay(url: string, options: StartPlayOptions): Promise<void>

[Function Description]

After the playback is started, the system quickly switches to the next stream.

[Request Parameters]

  • url: (mandatory) String type. Ingest URL that ends with flv.
  • options: (optional) 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: prioritizes the display of all video content. 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: prioritizes the filling of the window. 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: This parameter does not need to be transferred.
    • 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 thumbnail. If the poster exceeds the playback area, the excess part is cropped. Otherwise, the poster 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: This parameter does not need to be transferred.
    • schedulePolicy: This parameter does not need to be transferred.
    • domainPolicy: This parameter does not need to be transferred.
    • downgradeUrl: This parameter does not need to be transferred.

[Response Parameters]

Promise<void>: returns a Promise object.

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>: result of replay. The options are true (success) and false (failure).

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: result of pausing playback. The options are true (success) and false (failure).

pauseVideo

pauseVideo(): boolean

[Function Description]

This API is not supported.

[Request Parameters]

None

[Response Parameters]

boolean: Only false is returned.

resumeVideo

resumeVideo(): Promise<boolean>

[Function Description]

This API is not supported.

[Request Parameters]

None

[Response Parameters]

boolean: Only false is returned.

pauseAudio

pauseAudio(): boolean

[Function Description]

Pauses the audio playback.

[Request Parameters]

None

[Response Parameters]

boolean: result of pausing 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]

If you set the audio volume, sound will be heard.

[Request Parameters]

volume: (mandatory) audio volume. The value is a number ranging from 0 to 100.

[Response Parameters]

boolean: whether the audio volume has been set. 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) whether to mute. The value is of the Boolean type. true indicates muting, and false indicates unmuting.

[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 the StreamInterruptRetry type. The definition of StreamInterruptRetry is as follows: {

    enable: The value is of the Boolean type, indicating that 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 pull, 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).

destoryClient

destoryClient(): void

[Function Description]

Destroys a client object.

[Request Parameters]

None

[Response Parameters]

None

fullScreenToggle

fullScreenToggle(isExit: boolean): void

[Function Description]

Enables/Disables full-screen display.

[Request Parameters]

isExit: (mandatory) Boolean type. The default value is false.

[Response Parameters]

None