This topic describes the callback and listener interfaces of the Electron SDK.

Contents

API Description Supported earliest version
onJoinChannelResult Callback for the result of adding a channel. 2.5.2
onLeaveChannelResult The callback of the result of leaving the channel. 2.5.2
onRemoteUserOnLineNotify The callback that is launched by the remote user. 2.5.2
onRemoteUserOffLineNotify The callback for the remote user to go offline. 2.5.2
onAudioPublishStateChanged The callback for audio stream ingest changes. 2.5.2
onVideoPublishStateChanged The callback for the video ingest change. 2.5.2
onDualStreamPublishStateChanged Callback for minor stream ingest changes. 2.5.2
onScreenSharePublishStateChangedWithInfo The screen shares the callback for the stream change. 2.5.2
onRemoteTrackAvailableNotify Callback when the audio and video streams of remote users change. 2.5.2
onAudioSubscribeStateChanged The callback for the audio subscription change. 2.5.2
onVideoSubscribeStateChanged Callback for changes to the camera stream subscription. 2.5.2
onScreenShareSubscribeStateChanged Callback for changes in screen sharing stream subscription status. 2.5.2
onSubscribeStreamTypeChanged The callback for the change of the size stream subscription. 2.5.2
onOccurWarning Warning callback. 2.5.2
onOccurError Error callback. 2.5.2
onBye The callback when the server is kicked out or the channel is closed. 2.5.2
onAudioDeviceStateChanged The callback for the status change of the audio device. 2.5.2
onVideoDeviceStateChanged The callback for the status change of the video device. 2.5.2
onNetworkQualityChanged Callback when the network quality changes. 2.5.2
onUserAudioMuted A notification that the peer user stops sending audio data. 2.5.2
onUserVideoMuted A notification sent by the peer user to send the video black frame data. 2.5.2
onUpdateRoleNotify The callback when the user role changes. 2.5.2
onAudioPlayingStateChanged The callback played by the accompaniment. 2.5.2
onLastmileDetectResultWithQuality The callback for the network quality probe. 2.5.2
onAudioDeviceRecordLevel The callback for the audio capture device test. 2.5.2
onAudioDevicePlayoutLevel Audio playback device test callback. 2.5.2
onAudioDevicePlayoutEnd The callback when the audio playback device test ends (the audio file is played). 2.5.2
onStats The callback of current session statistics (triggered once in 2 seconds). 2.5.2
onLocalVideoStats Local video statistics callback (triggered once in 2s). 2.5.2
onRemoteVideoStats Remote video statistics callback (triggered once in 2s). 2.5.2
onLocalAudioStats Local audio statistics callback (triggered once in 2s). 2.5.2
onRemoteAudioStats Remote audio statistics callback (triggered once in 2s). 2.5.2
onMediaRecordEvent Recording event callback. 2.5.2
onAudioVolumeCallback Callback for user volume size. 2.5.2
onActiveSpeaker The current speaker of the subscription. 2.5.2

Details

  • onJoinChannelResult: the callback for the result of adding a channel.
    on(event: "onJoinChannelResult", listener: (result: number, channel: string, elapsed: number) => {}): void;
    Parameter Type Description
    result number The result of adding a channel. 0 is returned if it is successful and an error code is returned if it fails.
    channel string The ID of the channel.
    elapsed number The time taken to join the channel. Unit: milliseconds.
  • onLeaveChannelResult: The callback of the result of leaving the channel.
    on(event: "onLeaveChannelResult", listener: (result: number) => {}): void;
    Parameter Type Description
    result number 0 is returned if successful and error code information is returned if failed.
  • onRemoteUserOnLineNotify: the callback that is launched by the remote user.
    on(event: "onRemoteUserOnLineNotify", listener: (uid: string, elapsed: number) => {}): void;
    Parameter Type Description
    uid string The ID of the remote user.
    elapsed number The duration of time when the user joins the channel. Unit: milliseconds.
  • onRemoteUserOffLineNotify: the callback for remote users to go offline.
    on(event: "OnRemoteUserOffLineNotify", listener: (uid: string, reason: AliEngineUserOfflineReason) => {}): void;
    Parameter Type Description
    uid string The ID of the remote user.
    reason AliEngineUserOfflineReason The reason why the user is offline.
  • onAudioPublishStateChanged: the callback for audio stream ingest changes.
    on(event: "onAudioPublishStateChanged", listener: (oldState: AliEnginePublishState, newState: AliEnginePublishState, elapseSinceLastState: number, channel: string) => {}): void;
    Parameter Type Description
    oldState AliEnginePublishState The status of the last stream ingest.
    newState AliEnginePublishState The current stream ingest status.
    elapseSinceLastState number The interval at which the status changes. Unit: milliseconds.
    channel string The ID of the current channel.
  • onVideoPublishStateChanged: the callback for video stream ingest changes.
    on(event: "onVideoPublishStateChanged", listener: (oldState: AliEnginePublishState, newState: AliEnginePublishState, elapseSinceLastState: number, channel: string) => {}): void;
    Parameter Type Description
    oldState AliEnginePublishState The status of the last stream ingest.
    newState AliEnginePublishState The current stream ingest status.
    elapseSinceLastState number The interval at which the status changes. Unit: milliseconds.
    channel string The ID of the current channel.
  • onDualStreamPublishStateChanged: callback for secondary stream ingest changes.
    on(event: "onDualStreamPublishStateChanged", listener: (oldState: AliEnginePublishState, newState: AliEnginePublishState, elapseSinceLastState: number, channel: string) => {}): void;
    Parameter Type Description
    oldState AliEnginePublishState The status of the last stream ingest.
    newState AliEnginePublishState The current stream ingest status.
    elapseSinceLastState number The interval at which the status changes. Unit: milliseconds.
    channel string The ID of the current channel.
  • onScreenSharePublishStateChangedWithInfo: The screen shares the callback for the stream change.
    on(event: "onRemoteUserOnLineNotify", listener: (oldState: AliEnginePublishState, newState: AliEnginePublishState, elapseSinceLastState: number, channel: string, screenShareInfo: AliEngineScreenShareInfo) => {}): void;
    Parameter Type Description
    oldState AliEnginePublishState The status of the last stream ingest.
    newState AliEnginePublishState The current stream ingest status.
    elapseSinceLastState number The interval at which the status changes. Unit: milliseconds.
    channel string The ID of the current channel.
    screenShareInfo AliEngineScreenShareInfo This screen shares streaming information.
  • onRemoteTrackAvailableNotify: the callback when the audio and video streams of remote users change.
    on(event: "onRemoteTrackAvailableNotify", listener: (uid: string, audioTrack: AliEngineAudioTrack, videoTrack: AliEngineVideoTrack) => {}): void;
    Parameter Type Description
    uid string The ID of the remote user.
    audioTrack AliEngineAudioTrack The audio stream after the remote user changes.
    videoTrack AliEngineVideoTrack The video stream after the remote user changes.
  • onAudioSubscribeStateChanged: the callback for the audio subscription change.
    on(event: "onAudioSubscribeStateChanged", listener: (uid: string, oldState: AliEngineSubscribeState, newState: AliEngineSubscribeState, elapseSinceLastState: number, channel: string) => {}): void;
    Parameter Type Description
    uid string The ID of the remote user.
    oldState AliEngineSubscribeState The status of the last subscription.
    newState AliEngineSubscribeState The current subscription status.
    elapseSinceLastState number The interval at which the status changes. Unit: milliseconds.
    channel string The ID of the current channel.
  • onVideoSubscribeStateChanged: the callback for the change of the camera stream subscription.
    on(event: "onVideoSubscribeStateChanged", listener: (uid: string, oldState: AliEngineSubscribeState, newState: AliEngineSubscribeState, elapseSinceLastState: number, channel: string) => {}): void;
    Parameter Type Description
    uid string The ID of the remote user.
    oldState AliEngineSubscribeState The status of the last subscription.
    newState AliEngineSubscribeState The current subscription status.
    elapseSinceLastState number The interval at which the status changes. Unit: milliseconds.
    channel string The ID of the current channel.
  • onScreenShareSubscribeStateChanged: Callback for changes in screen sharing stream subscription status.
    on(event: "onScreenShareSubscribeStateChanged", listener: (uid: string, oldState: AliEngineSubscribeState, newState: AliEngineSubscribeState, elapseSinceLastState: number, channel: string) => {}): void;
    Parameter Type Description
    uid string The ID of the remote user.
    oldState AliEngineSubscribeState The status of the last subscription.
    newState AliEngineSubscribeState The current subscription status.
    elapseSinceLastState number The interval at which the status changes. Unit: milliseconds.
    channel string The ID of the current channel.
  • onSubscribeStreamTypeChanged: the callback for the change of the size stream subscription.
    on(event: "onSubscribeStreamTypeChanged", listener: (uid: string, oldState: AliEngineVideoStreamType, newState: AliEngineVideoStreamType, elapseSinceLastState: number, channel: string) => {}): void;
    Parameter Type Description
    uid string The ID of the remote user.
    oldStreamType AliEngineVideoStreamType The status of the last subscription.
    newStreamType AliEngineVideoStreamType The current subscription status.
    elapseSinceLastState number The interval at which the status changes. Unit: milliseconds.
    channel string The ID of the current channel.
  • onOccurWarning: a warning callback.
    on(event: "onOccurWarning", listener: (warn: number, msg: string) => {}): void;
    Parameter Type Description
    warn number The type of the warning.
    msg string Warning instructions.
  • onOccurError: the error callback.
    on(event: "onOccurError", listener: (error: number, msg: string) => {}): void;
    Parameter Type Description
    error number The type of the error that occurred.
    Note If the error parameter is set to 16908812 or 33620229, you need to release the instance, recreate the SDK instance, and then call the joinChannel to join the channel.
    msg string The error description.
  • onBye: the callback when the server is kicked out or the channel is closed.
    on(event: "onBye", listener: (code: AliEngineOnByeType) => {}): void;
    Parameter Type Description
    code AliEngineOnByeType The OnBye type.
  • onAudioDeviceStateChanged: the callback for the status change of the audio device.
    on(event: "onAudioDeviceStateChanged", listener: (deviceInfo: AliEngineDeviceInfo, deviceType: AliEngineExternalDeviceType, deviceState: AliEngineExternalDeviceState) => {}): void;
    Parameter Type Description
    deviceInfo AliEngineDeviceInfo The information about the external device.
    deviceType AliEngineExternalDeviceType The type of the external device.
    deviceState AliEngineExternalDeviceState The status of the external device.
  • onVideoDeviceStateChanged: the callback for the status change of the video device.
    on(event: "onVideoDeviceStateChanged", listener: (deviceInfo: AliEngineDeviceInfo, deviceType: AliEngineExternalDeviceType, deviceState: AliEngineExternalDeviceState) => {}): void;
    Parameter Type Description
    deviceInfo AliEngineDeviceInfo The information about the external device.
    deviceType AliEngineExternalDeviceType The type of the external device.
    deviceState AliEngineExternalDeviceState The status of the external device.
  • onNetworkQualityChanged: the callback when the network quality changes.
    on(event: "onNetworkQualityChanged", listener: (uid: string, upQuality: AliEngineNetworkQuality, downQuality: AliEngineNetworkQuality) => {}): void;
    Parameter Type Description
    uid string The ID of the user whose network quality has changed. If the user ID is empty, it means local, and others means remote.
    upQuality AliEngineNetworkQuality Upstream network quality.
    downQuality AliEngineNetworkQuality The downstream network quality.
  • onUserAudioMuted: the notification that the peer user stops sending audio data.
    on(event: "onUserAudioMuted", listener: (uid: string, isMute: boolean) => {}): void;
    Parameter Type Description
    uid string The user who executed the muteLocalMic.
    isMute boolean Specifies whether to mute. Valid values:
    • true: mute.
    • false: The instance is not muted.
  • onUserVideoMuted: The peer user sends a notification sent by the video black frame data.
    on(event: "onUserVideoMuted", listener: (uid: string, isMute: boolean) => {}): void;
    Parameter Type Description
    uid string The user who executed the enableLocalVideo.
    isMute boolean Specifies whether to turn on camera stream collection. Valid values:
    • true: enables camera stream collection.
    • false: disables camera stream collection.
  • onUpdateRoleNotify: the callback when the user role changes.
    on(event: "onUpdateRoleNotify", listener: (oldRole: AliEngineClientRole, newRole: AliEngineClientRole) => {}): void;
    Parameter Type Description
    oldRole AliEngineClientRole The role before the switch.
    newRole AliEngineClientRole The role after the switch.
  • onAudioPlayingStateChanged: Callback for accompaniment playback.
    on(event: "onAudioPlayingStateChanged", listener: (type: AliEngineAudioPlayingType, errorCode: AliEngineAudioPlayingErrorCode) => {}): void;
    Parameter Type Description
    type AliEngineAudioPlayingType The current playback status.
    errorCode AliEngineAudioPlayingErrorCode The error code returned.
  • onLastmileDetectResultWithQuality: the callback for network quality detection.
    on(event: "onLastmileDetectResultWithQuality", listener: (networkQuality: AliEngineNetworkQuality) => {}): void;
    Parameter Type Description
    networkQuality AliEngineNetworkQuality Network quality.
  • onAudioDeviceRecordLevel: the callback for the audio capture device test.
    on(event: "onAudioDeviceRecordLevel", listener: (level: number) => {}): void;
    Parameter Type Description
    level number The audio collection device volume value.
  • onAudioDevicePlayoutLevel: the audio playback device test callback.
    on(event: "onAudioDevicePlayoutLevel", listener: (level: number) => {}): void;
    Parameter Type Description
    level number The audio collection device volume value.
  • onAudioDevicePlayoutEnd: the callback when the audio playback device test ends (the audio file is played).
    on(event: "onAudioDevicePlayoutEnd", listener: () => {}): void;
  • onStats: the callback for the statistics of the current session. The callback is triggered once in 2 seconds.
    on(event: "onStats", listener: (stats: AliEngineStats) => {}): void;
    Parameter Type Description
    stats AliEngineStats Session statistics.
  • onLocalVideoStats: local video statistics callback (triggered once in 2 seconds).
    on(event: "onLocalVideoStats", listener: (localVideoStats: AliEngineLocalVideoStats) => {}): void;
    Parameter Type Description
    localVideoStats AliEngineLocalVideoStats The statistics on local videos.
  • onRemoteVideoStats: remote video statistics callback (triggered once in 2s).
    on(event: "onRemoteVideoStats", listener: (remoteVideoStats: AliEngineRemoteVideoStats) => {}): void;
    Parameter Type Description
    remoteVideoStats AliEngineRemoteVideoStats The statistics on remote videos.
  • onLocalAudioStats: local audio statistics callback (triggered once in 2s).
    on(event: "onLocalAudioStats", listener: (localAudioStats: AliEngineLocalAudioStats) => {}): void;
    Parameter Type Description
    localAudioStats AliEngineLocalAudioStats The local audio statistics.
  • onRemoteAudioStats: remote audio statistics callback (triggered once in 2s).
    on(event: "onRemoteAudioStats", listener: (remoteAudioStats: AliEngineRemoteAudioStats) => {}): void;
    Parameter Type Description
    remoteAudioStats AliEngineRemoteAudioStats The statistics on remote audio.
  • onMediaRecordEvent: the callback for recording events.
    on(event: "onMediaRecordEvent", listener: (event: number, filePath: string) => {}): void;
    Parameter Type Description
    event number Record events. Valid values:
    • 0: The recording starts.
    • 1: The recording ends.
    • 2: Failed to open the file.
    • 3: Failed to write the file.
    filePath string The path of the recording file.
  • onAudioVolumeCallback: the callback for the volume of the user.
    on(event: "onAudioVolumeCallback", listener: (volumeInfo: AliEngineUserVolumeInfo) => {}): void;
    Parameter Type Description
    volumeInfo AliEngineUserVolumeInfo Speaker structure information.
    Note In the AliEngineUserVolumeInfo, uid 0 indicates the local ingest volume, 1 indicates the remote mixing volume, and others indicate the user's volume.
  • onActiveSpeaker: the current speaker of the subscription.
    on(event: "onActiveSpeaker", listener: (uid: string) => {}): void;
    Parameter Type Description
    uid string The ID of the user.