This document is only for explaining the callback setting method and parameter usage on the Electron platform. For detailed function introduction and parameter description, please refer to the specific API documentation.
The callbacks of the Express Electron SDK are managed across multiple modules. The modules and how to obtain their instances are as follows:
Create SDK instance zegoEngine
// Create SDK instance
const zgEngine = window.require('zego-express-engine-electron/ZegoExpressEngine');
createMediaPlayer --- Create media player instance zgMediaPlayer
// Create media player instance
const zgMediaPlayer = zgEngine.createMediaPlayer();
createAudioEffectPlayer --- Create audio effect player instance zgAudioEffectPlayer
// Create audio effect player instance
const zgAudioEffectPlayer = zgEngine.createAudioEffectPlayer();
ZegoExpressScreenCaptureSource
createScreenCaptureSource --- Create screen capture source instance zgScreenCaptureSource
// Create screen capture source instance
// sourceId {number} The specified screen ID or window ID
// sourceType {ZegoScreenCaptureSourceType} The specified screen source type.
const zgScreenCaptureSource = zgEngine.createScreenCaptureSource(sourceId, sourceType);
Example:
zgEngine.on("onDebugError",(errorCode,funcName,info)=>{
console.log(`onDebugError: ${errorCode},${funcName},${info}`)
})
Example:
zgEngine.on("onEngineStateUpdate",(state)=>{
console.log(`onEngineStateUpdate: ${state}`)
})
Example:
zgEngine.on("onRecvExperimentalAPI",(content)=>{
console.log(`onRecvExperimentalAPI: ${content}`)
})
Example:
zgEngine.on("onRoomStateUpdate",(roomID,state,errorCode,extendedData)=>{
console.log(`onRoomStateUpdate: ${roomID},${state},${errorCode},${extendedData}`)
})
Example:
zgEngine.on("onRoomStateChanged",(roomID,reason,errorCode,extendedData)=>{
console.log(`onRoomStateChanged: ${roomID},${reason},${errorCode},${extendedData}`)
})
Example:
zgEngine.on("onRoomUserUpdate",(roomID,updateType,userList)=>{
console.log(`onRoomUserUpdate: ${roomID},${updateType},${userList}`)
})
Example:
zgEngine.on("onRoomOnlineUserCountUpdate",(roomID,count)=>{
console.log(`onRoomOnlineUserCountUpdate: ${roomID},${count}`)
})
Example:
zgEngine.on("onRoomStreamUpdate",(roomID,updateType,streamList,extendedData)=>{
console.log(`onRoomStreamUpdate: ${roomID},${updateType},${streamList},${extendedData}`)
})
Example:
zgEngine.on("onRoomStreamExtraInfoUpdate",(roomID,streamList)=>{
console.log(`onRoomStreamExtraInfoUpdate: ${roomID},${streamList}`)
})
Example:
zgEngine.on("onRoomExtraInfoUpdate",(roomID,roomExtraInfoList)=>{
console.log(`onRoomExtraInfoUpdate: ${roomID},${roomExtraInfoList}`)
})
Example:
zgEngine.on("onRoomTokenWillExpire",(roomID,remainTimeInSecond)=>{
console.log(`onRoomTokenWillExpire: ${roomID},${remainTimeInSecond}`)
})
Example:
zgEngine.on("onPublisherStateUpdate",(streamID,state,errorCode,extendedData)=>{
console.log(`onPublisherStateUpdate: ${streamID},${state},${errorCode},${extendedData}`)
})
Example:
zgEngine.on("onPublisherQualityUpdate",(streamID,quality)=>{
console.log(`onPublisherQualityUpdate: ${streamID},${quality}`)
})
Example:
zgEngine.on("onPublisherCapturedAudioFirstFrame",()=>{
console.log(`onPublisherCapturedAudioFirstFrame: `)
})
Example:
zgEngine.on("onPublisherCapturedVideoFirstFrame",(channel)=>{
console.log(`onPublisherCapturedVideoFirstFrame: ${channel}`)
})
Example:
zgEngine.on("onPublisherSendAudioFirstFrame",(channel)=>{
console.log(`onPublisherSendAudioFirstFrame: ${channel}`)
})
Example:
zgEngine.on("onPublisherSendVideoFirstFrame",(channel)=>{
console.log(`onPublisherSendVideoFirstFrame: ${channel}`)
})
Example:
zgEngine.on("onPublisherVideoSizeChanged",(width,height,channel)=>{
console.log(`onPublisherVideoSizeChanged: ${width},${height},${channel}`)
})
Example:
zgEngine.on("onPublisherRelayCDNStateUpdate",(streamID,infoList)=>{
console.log(`onPublisherRelayCDNStateUpdate: ${streamID},${infoList}`)
})
Example:
zgEngine.on("onVideoObjectSegmentationStateChanged",(state,channel,errorCode)=>{
console.log(`onVideoObjectSegmentationStateChanged: ${state},${channel},${errorCode}`)
})
Example:
zgEngine.on("onPlayerStateUpdate",(streamID,state,errorCode,extendedData)=>{
console.log(`onPlayerStateUpdate: ${streamID},${state},${errorCode},${extendedData}`)
})
Example:
zgEngine.on("onPlayerQualityUpdate",(streamID,quality)=>{
console.log(`onPlayerQualityUpdate: ${streamID},${quality}`)
})
Example:
zgEngine.on("onPlayerMediaEvent",(streamID,event)=>{
console.log(`onPlayerMediaEvent: ${streamID},${event}`)
})
Example:
zgEngine.on("onPlayerRecvAudioFirstFrame",(streamID)=>{
console.log(`onPlayerRecvAudioFirstFrame: ${streamID}`)
})
Example:
zgEngine.on("onPlayerRecvVideoFirstFrame",(streamID)=>{
console.log(`onPlayerRecvVideoFirstFrame: ${streamID}`)
})
Example:
zgEngine.on("onPlayerRenderVideoFirstFrame",(streamID)=>{
console.log(`onPlayerRenderVideoFirstFrame: ${streamID}`)
})
Example:
zgEngine.on("onPlayerVideoSizeChanged",(streamID,width,height)=>{
console.log(`onPlayerVideoSizeChanged: ${streamID},${width},${height}`)
})
Example:
zgEngine.on("onPlayerRecvSEI",(streamID,data)=>{
console.log(`onPlayerRecvSEI: ${streamID},${data}`)
})
Example:
zgEngine.on("onPlayerSyncRecvSEI",(streamID,data)=>{
console.log(`onPlayerSyncRecvSEI: ${streamID},${data}`)
})
Example:
zgEngine.on("onAudioDeviceStateChanged",(updateType,deviceType,deviceInfo)=>{
console.log(`onAudioDeviceStateChanged: ${updateType},${deviceType},${deviceInfo}`)
})
Example:
zgEngine.on("onAudioDeviceVolumeChanged",(deviceType,deviceID,volume)=>{
console.log(`onAudioDeviceVolumeChanged: ${deviceType},${deviceID},${volume}`)
})
Example:
zgEngine.on("onVideoDeviceStateChanged",(updateType,deviceInfo)=>{
console.log(`onVideoDeviceStateChanged: ${updateType},${deviceInfo}`)
})
Example:
zgEngine.on("onCapturedSoundLevelUpdate",(soundLevel)=>{
console.log(`onCapturedSoundLevelUpdate: ${soundLevel}`)
})
Example:
zgEngine.on("onCapturedSoundLevelInfoUpdate",(soundLevelInfo)=>{
console.log(`onCapturedSoundLevelInfoUpdate: ${soundLevelInfo}`)
})
Example:
zgEngine.on("onRemoteSoundLevelUpdate",(soundLevels)=>{
console.log(`onRemoteSoundLevelUpdate: ${soundLevels}`)
})
Example:
zgEngine.on("onLocalCaptureVideoData",(videoParam)=>{
console.log(`onLocalCaptureVideoData: ${videoParam}`)
})
Example:
zgEngine.on("onRemotePlayVideoData",(videoParam)=>{
console.log(`onRemotePlayVideoData: ${videoParam}`)
})
Example:
zgEngine.on("onRemoteSoundLevelInfoUpdate",(soundLevelInfos)=>{
console.log(`onRemoteSoundLevelInfoUpdate: ${soundLevelInfos}`)
})
Example:
zgEngine.on("onCapturedAudioSpectrumUpdate",(audioSpectrum)=>{
console.log(`onCapturedAudioSpectrumUpdate: ${audioSpectrum}`)
})
Example:
zgEngine.on("onRemoteAudioSpectrumUpdate",(audioSpectrums)=>{
console.log(`onRemoteAudioSpectrumUpdate: ${audioSpectrums}`)
})
Example:
zgEngine.on("onLocalDeviceExceptionOccurred",(exceptionType,deviceType,deviceID)=>{
console.log(`onLocalDeviceExceptionOccurred: ${exceptionType},${deviceType},${deviceID}`)
})
Example:
zgEngine.on("onRemoteCameraStateUpdate",(streamID,state)=>{
console.log(`onRemoteCameraStateUpdate: ${streamID},${state}`)
})
Example:
zgEngine.on("onRemoteMicStateUpdate",(streamID,state)=>{
console.log(`onRemoteMicStateUpdate: ${streamID},${state}`)
})
Example:
zgEngine.on("onRemoteSpeakerStateUpdate",(streamID,state)=>{
console.log(`onRemoteSpeakerStateUpdate: ${streamID},${state}`)
})
Example:
zgEngine.on("onAudioVADStateUpdate",(type,state)=>{
console.log(`onAudioVADStateUpdate: ${type},${state}`)
})
Example:
zgEngine.on("onIMRecvBroadcastMessage",(roomID,messageList)=>{
console.log(`onIMRecvBroadcastMessage: ${roomID},${messageList}`)
})
Example:
zgEngine.on("onIMRecvBarrageMessage",(roomID,messageList)=>{
console.log(`onIMRecvBarrageMessage: ${roomID},${messageList}`)
})
Example:
zgEngine.on("onIMRecvCustomCommand",(roomID,fromUser,command)=>{
console.log(`onIMRecvCustomCommand: ${roomID},${fromUser},${command}`)
})
Example:
zgEngine.on("onCapturedDataRecordStateUpdate",(state,errorCode,config,channel)=>{
console.log(`onCapturedDataRecordStateUpdate: ${state},${errorCode},${config},${channel}`)
})
Example:
zgEngine.on("onCapturedDataRecordProgressUpdate",(progress,config,channel)=>{
console.log(`onCapturedDataRecordProgressUpdate: ${progress},${config},${channel}`)
})
Example:
zgEngine.on("onNetworkModeChanged",(mode)=>{
console.log(`onNetworkModeChanged: ${mode}`)
})
Example:
zgEngine.on("onNetworkSpeedTestError",(errorCode,type)=>{
console.log(`onNetworkSpeedTestError: ${errorCode},${type}`)
})
Example:
zgEngine.on("onNetworkSpeedTestQualityUpdate",(quality,type)=>{
console.log(`onNetworkSpeedTestQualityUpdate: ${quality},${type}`)
})
Example:
zgEngine.on("onDownloadProgressUpdate",(resourceID,progressRate)=>{
console.log(`onDownloadProgressUpdate: ${resourceID},${progressRate}`)
})
Example:
zgEngine.on("onCurrentPitchValueUpdate",(resourceID,currentDuration,pitchValue)=>{
console.log(`onCurrentPitchValueUpdate: ${resourceID},${currentDuration},${pitchValue}`)
})
Example:
zgMediaPlayer.on("onMediaPlayerStateUpdate",(state,errorCode)=>{
console.log(`onMediaPlayerStateUpdate: ${state},${errorCode}`)
})
Example:
zgMediaPlayer.on("onMediaPlayerNetworkEvent",(networkEvent)=>{
console.log(`onMediaPlayerNetworkEvent: ${networkEvent}`)
})
Example:
zgMediaPlayer.on("onMediaPlayerPlayingProgress",(millisecond)=>{
console.log(`onMediaPlayerPlayingProgress: ${millisecond}`)
})
Example:
zgMediaPlayer.on("onMediaPlayerRenderingProgress",(millisecond)=>{
console.log(`onMediaPlayerRenderingProgress: ${millisecond}`)
})
Example:
zgMediaPlayer.on("onMediaPlayerVideoSizeChanged",(width,height)=>{
console.log(`onMediaPlayerVideoSizeChanged: ${width},${height}`)
})
Example:
zgMediaPlayer.on("onMediaPlayerLoadResource",(errorCode,seq)=>{
console.log(`onMediaPlayerLoadResource: ${errorCode},${seq}`)
})
Example:
zgMediaPlayer.on("onMediaPlayerVideoData",(videoParam)=>{
console.log(`onMediaPlayerVideoData: ${videoParam}`)
})
Example:
zgMediaPlayer.on("onMediaPlayerRecvSEI",(data)=>{
console.log(`onMediaPlayerRecvSEI: ${data}`)
})
Example:
zgMediaPlayer.on("onMediaPlayerSoundLevelUpdate",(soundLevel)=>{
console.log(`onMediaPlayerSoundLevelUpdate: ${soundLevel}`)
})
Example:
zgMediaPlayer.on("onMediaPlayerFrequencySpectrumUpdate",(spectrumList)=>{
console.log(`onMediaPlayerFrequencySpectrumUpdate: ${spectrumList}`)
})
Example:
zgMediaPlayer.on("onMediaPlayerFirstFrameEvent",(event)=>{
console.log(`onMediaPlayerFirstFrameEvent: ${event}`)
})
Example:
zgMediaPlayer.on("onMediaPlayerLocalCache",(errorCode,resource,cachedFile)=>{
console.log(`onMediaPlayerLocalCache: ${errorCode},${resource},${cachedFile}`)
})
Example:
zgAudioEffectPlayer.on("onAudioEffectPlayStateUpdate",(audioEffectID,state,errorCode)=>{
console.log(`onAudioEffectPlayStateUpdate: ${audioEffectID},${state},${errorCode}`)
})
Example:
zgScreenCaptureSource.on("onExceptionOccurred",(exceptionType)=>{
console.log(`onExceptionOccurred: ${exceptionType}`)
})
Example:
zgScreenCaptureSource.on("onWindowStateChanged",(source,windowState,windowRect)=>{
console.log(`onWindowStateChanged: ${source},${windowState},${windowRect}`)
})
Callback Trigger Timing: The state of the target window being captured changes.
Parameter Information:
Parameter | Type | Description |
---|---|---|
source | ZegoAudioSourceType | The screen capture source instance for the callback. |
windowState | ZegoScreenCaptureWindowState | The state of the captured window. |
windowRect | ZegoRect | The rectangle of the captured window. |
ZegoScreenCaptureWindowState Screen Capture Source Window State
Properties:
ZegoScreenCaptureWindowStateOnScreen:
ZegoScreenCaptureWindowStateOnScreen = (0)
The window is on the current screen, and the coordinate area changes.
ZegoScreenCaptureWindowStateOffScreen:
ZegoScreenCaptureWindowStateOffScreen = (1)
The window leaves the current screen, pausing capture.
ZegoScreenCaptureWindowStateDestroy:
ZegoScreenCaptureWindowStateDestroy = (2)
The window is destroyed.
Example:
zgScreenCaptureSource.on("onRectChanged",(source,captureRect)=>{
console.log(`onRectChanged: ${source},${captureRect}`)
})
Callback Trigger Timing: The capture area changes.
Parameter Information:
Parameter | Type | Description |
---|---|---|
source | ZegoAudioSourceType | The screen capture source instance for the callback. |
captureRect | ZegoRect | The rectangle of the capture area. |
To unregister a callback, you can use the off
and removeAllListeners
methods to cancel the registered callback.
Method | Parameter | Description |
---|---|---|
off | eventName,listener | Cancel the registered callback for the specified event |
removeAllListeners | eventName | Cancel all registered callbacks for the specified event |
The on method can register multiple callbacks for the same event. When using an anonymous function callback registered with on, you can only use the removeAllListeners method to cancel all callbacks.
Cancel Callback Example
The following uses the zgEngine's onDebugError event as an example.
Use the off
method to cancel the Listener
callback registered for "onDebugError"
.
const Listener = (errorCode,funcName,info)=>{
console.log(`onDebugError: ${errorCode},${funcName},${info}`)
}
zgEngine.on("onDebugError",Listener)
zgEngine.off("onDebugError",Listener)
Use the removeAllListeners
method to cancel all registered callbacks for "onDebugError"
.
zgEngine.removeAllListeners("onDebugError")