此文档仅用于说明 Electron 平台的回调设置方式及参数使用方式。详细的 功能介绍 和 参数说明 请参考具体API说明。
Express Electron SDK的回调在多个模块进行管理。模块及其实例获取方式如下:
创建 SDK 实例 zegoEngine
// 创建 SDK 实例
const zgEngine = window.require('zego-express-engine-electron/ZegoExpressEngine');
createMediaPlayer --- 创建媒体播放器实例 zgMediaPlayer
// 创建媒体播放器实例
const zgMediaPlayer = zgEngine.createMediaPlayer();
createAudioEffectPlayer --- 创建音频效果播放器实例 zgAudioEffectPlayer
// 创建音频效果播放器实例
const zgAudioEffectPlayer = zgEngine.createAudioEffectPlayer();
ZegoExpressScreenCaptureSource
createScreenCaptureSource --- 创建屏幕捕获源实例 zgScreenCaptureSource
// 创建屏幕捕获源实例
// sourceId {number}指定的屏幕 ID 或窗口 ID
// sourceType {ZegoScreenCaptureSourceType} 指定的 screen 源类型。
const zgScreenCaptureSource = zgEngine.createScreenCaptureSource(sourceId, sourceType);
使用示例:
zgEngine.on("onDebugError",({errorCode,funcName,info})=>{
console.log(`onDebugError: ${errorCode},${funcName},${info}`)
})
使用示例:
zgEngine.on("onEngineStateUpdate",({state})=>{
console.log(`onEngineStateUpdate: ${state}`)
})
使用示例:
zgEngine.on("onRecvExperimentalAPI",({content})=>{
console.log(`onRecvExperimentalAPI: ${content}`)
})
使用示例:
zgEngine.on("onRoomStateUpdate",({roomID,state,errorCode,extendedData})=>{
console.log(`onRoomStateUpdate: ${roomID},${state},${errorCode},${extendedData}`)
})
使用示例:
zgEngine.on("onRoomStateChanged",({roomID,reason,errorCode,extendedData})=>{
console.log(`onRoomStateChanged: ${roomID},${reason},${errorCode},${extendedData}`)
})
使用示例:
zgEngine.on("onRoomUserUpdate",({roomID,updateType,userList})=>{
console.log(`onRoomUserUpdate: ${roomID},${updateType},${userList}`)
})
使用示例:
zgEngine.on("onRoomOnlineUserCountUpdate",({roomID,count})=>{
console.log(`onRoomOnlineUserCountUpdate: ${roomID},${count}`)
})
使用示例:
zgEngine.on("onRoomStreamUpdate",({roomID,updateType,streamList,extendedData})=>{
console.log(`onRoomStreamUpdate: ${roomID},${updateType},${streamList},${extendedData}`)
})
使用示例:
zgEngine.on("onRoomStreamExtraInfoUpdate",({roomID,streamList})=>{
console.log(`onRoomStreamExtraInfoUpdate: ${roomID},${streamList}`)
})
使用示例:
zgEngine.on("onRoomExtraInfoUpdate",({roomID,roomExtraInfoList})=>{
console.log(`onRoomExtraInfoUpdate: ${roomID},${roomExtraInfoList}`)
})
使用示例:
zgEngine.on("onRoomTokenWillExpire",({roomID,remainTimeInSecond})=>{
console.log(`onRoomTokenWillExpire: ${roomID},${remainTimeInSecond}`)
})
使用示例:
zgEngine.on("onPublisherStateUpdate",({streamID,state,errorCode,extendedData})=>{
console.log(`onPublisherStateUpdate: ${streamID},${state},${errorCode},${extendedData}`)
})
使用示例:
zgEngine.on("onPublisherQualityUpdate",({streamID,quality})=>{
console.log(`onPublisherQualityUpdate: ${streamID},${quality}`)
})
使用示例:
zgEngine.on("onPublisherCapturedAudioFirstFrame",()=>{
console.log(`onPublisherCapturedAudioFirstFrame: `)
})
使用示例:
zgEngine.on("onPublisherCapturedVideoFirstFrame",({channel})=>{
console.log(`onPublisherCapturedVideoFirstFrame: ${channel}`)
})
使用示例:
zgEngine.on("onPublisherSendAudioFirstFrame",({channel})=>{
console.log(`onPublisherSendAudioFirstFrame: ${channel}`)
})
使用示例:
zgEngine.on("onPublisherSendVideoFirstFrame",({channel})=>{
console.log(`onPublisherSendVideoFirstFrame: ${channel}`)
})
使用示例:
zgEngine.on("onPublisherVideoSizeChanged",({width,height,channel})=>{
console.log(`onPublisherVideoSizeChanged: ${width},${height},${channel}`)
})
使用示例:
zgEngine.on("onPublisherRelayCDNStateUpdate",({streamID,infoList})=>{
console.log(`onPublisherRelayCDNStateUpdate: ${streamID},${infoList}`)
})
使用示例:
zgEngine.on("onVideoObjectSegmentationStateChanged",({state,channel,errorCode})=>{
console.log(`onVideoObjectSegmentationStateChanged: ${state},${channel},${errorCode}`)
})
使用示例:
zgEngine.on("onPlayerStateUpdate",({streamID,state,errorCode,extendedData})=>{
console.log(`onPlayerStateUpdate: ${streamID},${state},${errorCode},${extendedData}`)
})
使用示例:
zgEngine.on("onPlayerQualityUpdate",({streamID,quality})=>{
console.log(`onPlayerQualityUpdate: ${streamID},${quality}`)
})
使用示例:
zgEngine.on("onPlayerMediaEvent",({streamID,event})=>{
console.log(`onPlayerMediaEvent: ${streamID},${event}`)
})
使用示例:
zgEngine.on("onPlayerRecvAudioFirstFrame",({streamID})=>{
console.log(`onPlayerRecvAudioFirstFrame: ${streamID}`)
})
使用示例:
zgEngine.on("onPlayerRecvVideoFirstFrame",({streamID})=>{
console.log(`onPlayerRecvVideoFirstFrame: ${streamID}`)
})
使用示例:
zgEngine.on("onPlayerRenderVideoFirstFrame",({streamID})=>{
console.log(`onPlayerRenderVideoFirstFrame: ${streamID}`)
})
使用示例:
zgEngine.on("onPlayerVideoSizeChanged",({streamID,width,height})=>{
console.log(`onPlayerVideoSizeChanged: ${streamID},${width},${height}`)
})
使用示例:
zgEngine.on("onPlayerRecvSEI",({streamID,data})=>{
console.log(`onPlayerRecvSEI: ${streamID},${data}`)
})
使用示例:
zgEngine.on("onPlayerSyncRecvSEI",({streamID,data})=>{
console.log(`onPlayerSyncRecvSEI: ${streamID},${data}`)
})
使用示例:
zgEngine.on("onAudioDeviceStateChanged",({updateType,deviceType,deviceInfo})=>{
console.log(`onAudioDeviceStateChanged: ${updateType},${deviceType},${deviceInfo}`)
})
使用示例:
zgEngine.on("onAudioDeviceVolumeChanged",({deviceType,deviceID,volume})=>{
console.log(`onAudioDeviceVolumeChanged: ${deviceType},${deviceID},${volume}`)
})
使用示例:
zgEngine.on("onVideoDeviceStateChanged",({updateType,deviceInfo})=>{
console.log(`onVideoDeviceStateChanged: ${updateType},${deviceInfo}`)
})
使用示例:
zgEngine.on("onCapturedSoundLevelUpdate",({soundLevel})=>{
console.log(`onCapturedSoundLevelUpdate: ${soundLevel}`)
})
使用示例:
zgEngine.on("onCapturedSoundLevelInfoUpdate",({soundLevelInfo})=>{
console.log(`onCapturedSoundLevelInfoUpdate: ${soundLevelInfo}`)
})
使用示例:
zgEngine.on("onRemoteSoundLevelUpdate",({soundLevels})=>{
console.log(`onRemoteSoundLevelUpdate: ${soundLevels}`)
})
使用示例:
zgEngine.on("onLocalCaptureVideoData",({videoParam})=>{
console.log(`onLocalCaptureVideoData: ${videoParam}`)
})
使用示例:
zgEngine.on("onRemotePlayVideoData",({videoParam})=>{
console.log(`onRemotePlayVideoData: ${videoParam}`)
})
使用示例:
zgEngine.on("onRemoteSoundLevelInfoUpdate",({soundLevelInfos})=>{
console.log(`onRemoteSoundLevelInfoUpdate: ${soundLevelInfos}`)
})
使用示例:
zgEngine.on("onCapturedAudioSpectrumUpdate",({audioSpectrum})=>{
console.log(`onCapturedAudioSpectrumUpdate: ${audioSpectrum}`)
})
使用示例:
zgEngine.on("onRemoteAudioSpectrumUpdate",({audioSpectrums})=>{
console.log(`onRemoteAudioSpectrumUpdate: ${audioSpectrums}`)
})
使用示例:
zgEngine.on("onLocalDeviceExceptionOccurred",({exceptionType,deviceType,deviceID})=>{
console.log(`onLocalDeviceExceptionOccurred: ${exceptionType},${deviceType},${deviceID}`)
})
使用示例:
zgEngine.on("onRemoteCameraStateUpdate",({streamID,state})=>{
console.log(`onRemoteCameraStateUpdate: ${streamID},${state}`)
})
使用示例:
zgEngine.on("onRemoteMicStateUpdate",({streamID,state})=>{
console.log(`onRemoteMicStateUpdate: ${streamID},${state}`)
})
使用示例:
zgEngine.on("onRemoteSpeakerStateUpdate",({streamID,state})=>{
console.log(`onRemoteSpeakerStateUpdate: ${streamID},${state}`)
})
使用示例:
zgEngine.on("onAudioVADStateUpdate",({type,state})=>{
console.log(`onAudioVADStateUpdate: ${type},${state}`)
})
使用示例:
zgEngine.on("onIMRecvBroadcastMessage",({roomID,messageList})=>{
console.log(`onIMRecvBroadcastMessage: ${roomID},${messageList}`)
})
使用示例:
zgEngine.on("onIMRecvBarrageMessage",({roomID,messageList})=>{
console.log(`onIMRecvBarrageMessage: ${roomID},${messageList}`)
})
使用示例:
zgEngine.on("onIMRecvCustomCommand",({roomID,fromUser,command})=>{
console.log(`onIMRecvCustomCommand: ${roomID},${fromUser},${command}`)
})
使用示例:
zgEngine.on("onCapturedDataRecordStateUpdate",({state,errorCode,config,channel})=>{
console.log(`onCapturedDataRecordStateUpdate: ${state},${errorCode},${config},${channel}`)
})
使用示例:
zgEngine.on("onCapturedDataRecordProgressUpdate",({progress,config,channel})=>{
console.log(`onCapturedDataRecordProgressUpdate: ${progress},${config},${channel}`)
})
使用示例:
zgEngine.on("onNetworkModeChanged",({mode})=>{
console.log(`onNetworkModeChanged: ${mode}`)
})
使用示例:
zgEngine.on("onNetworkSpeedTestError",({errorCode,type})=>{
console.log(`onNetworkSpeedTestError: ${errorCode},${type}`)
})
使用示例:
zgEngine.on("onNetworkSpeedTestQualityUpdate",({quality,type})=>{
console.log(`onNetworkSpeedTestQualityUpdate: ${quality},${type}`)
})
使用示例:
zgEngine.on("onDownloadProgressUpdate",({resourceID,progressRate})=>{
console.log(`onDownloadProgressUpdate: ${resourceID},${progressRate}`)
})
使用示例:
zgEngine.on("onCurrentPitchValueUpdate",({resourceID,currentDuration,pitchValue})=>{
console.log(`onCurrentPitchValueUpdate: ${resourceID},${currentDuration},${pitchValue}`)
})
使用示例:
zgMediaPlayer.on("onMediaPlayerStateUpdate",({state,errorCode})=>{
console.log(`onMediaPlayerStateUpdate: ${state},${errorCode}`)
})
使用示例:
zgMediaPlayer.on("onMediaPlayerNetworkEvent",({networkEvent})=>{
console.log(`onMediaPlayerNetworkEvent: ${networkEvent}`)
})
使用示例:
zgMediaPlayer.on("onMediaPlayerPlayingProgress",({millisecond})=>{
console.log(`onMediaPlayerPlayingProgress: ${millisecond}`)
})
使用示例:
zgMediaPlayer.on("onMediaPlayerRenderingProgress",({millisecond})=>{
console.log(`onMediaPlayerRenderingProgress: ${millisecond}`)
})
使用示例:
zgMediaPlayer.on("onMediaPlayerVideoSizeChanged",({width,height})=>{
console.log(`onMediaPlayerVideoSizeChanged: ${width},${height}`)
})
使用示例:
zgMediaPlayer.on("onMediaPlayerLoadResource",({errorCode,seq})=>{
console.log(`onMediaPlayerLoadResource: ${errorCode},${seq}`)
})
使用示例:
zgMediaPlayer.on("onMediaPlayerVideoData",({videoParam})=>{
console.log(`onMediaPlayerVideoData: ${videoParam}`)
})
使用示例:
zgMediaPlayer.on("onMediaPlayerRecvSEI",({data})=>{
console.log(`onMediaPlayerRecvSEI: ${data}`)
})
使用示例:
zgMediaPlayer.on("onMediaPlayerSoundLevelUpdate",({soundLevel})=>{
console.log(`onMediaPlayerSoundLevelUpdate: ${soundLevel}`)
})
使用示例:
zgMediaPlayer.on("onMediaPlayerFrequencySpectrumUpdate",({spectrumList})=>{
console.log(`onMediaPlayerFrequencySpectrumUpdate: ${spectrumList}`)
})
使用示例:
zgMediaPlayer.on("onMediaPlayerFirstFrameEvent",({event})=>{
console.log(`onMediaPlayerFirstFrameEvent: ${event}`)
})
使用示例:
zgMediaPlayer.on("onMediaPlayerLocalCache",({errorCode,resource,cachedFile})=>{
console.log(`onMediaPlayerLocalCache: ${errorCode},${resource},${cachedFile}`)
})
使用示例:
zgAudioEffectPlayer.on("onAudioEffectPlayStateUpdate",({audioEffectID,state,errorCode})=>{
console.log(`onAudioEffectPlayStateUpdate: ${audioEffectID},${state},${errorCode}`)
})
使用示例:
zgScreenCaptureSource.on("onExceptionOccurred",({exceptionType})=>{
console.log(`onExceptionOccurred: ${exceptionType}`)
})
使用示例:
zgScreenCaptureSource.on("onWindowStateChanged",({source,windowState,windowRect})=>{
console.log(`onWindowStateChanged: ${source},${windowState},${windowRect}`)
})
回调触发时机: 采集目标窗口状态发生改变。
参数信息:
参数 | 类型 | 描述 |
---|---|---|
source | ZegoAudioSourceType | 回调的屏幕采集源实例。 |
windowState | ZegoScreenCaptureWindowState | 采集的窗口状态 |
windowRect | ZegoRect | 采集的窗口矩形 |
ZegoScreenCaptureWindowState 屏幕采集源窗口状态
属性:
ZegoScreenCaptureWindowStateOnScreen:
ZegoScreenCaptureWindowStateOnScreen = (0)
窗口处于当前屏幕,坐标区域更改。
ZegoScreenCaptureWindowStateOffScreen:
ZegoScreenCaptureWindowStateOffScreen = (1)
窗口离开当前屏幕,暂停采集。
ZegoScreenCaptureWindowStateDestroy:
ZegoScreenCaptureWindowStateDestroy = (2)
窗口被销毁。
使用示例:
zgScreenCaptureSource.on("onRectChanged",({source,captureRect})=>{
console.log(`onRectChanged: ${source},${captureRect}`)
})
回调触发时机: 采集区域发生改变。
参数信息:
参数 | 类型 | 描述 |
---|---|---|
source | ZegoAudioSourceType | 回调的屏幕采集源实例。 |
captureRect | ZegoRect | 采集的区域矩形 |
取消注册的回调,可以通过 off
和 removeAllListeners
方法取消注册的回调。
方法 | 参数 | 描述 |
---|---|---|
off | eventName,listener | 取消指定事件的注册的回调 |
removeAllListeners | eventName | 取消指定事件所有注册的回调 |
on方法同一事件可以注册多个回调,当使用 on 注册 匿名函数回调时,只能使用removeAllListeners方法取消所有回调。
取消回调示例
以下使用zgEngine的onDebugError事件为例,
使用off
方法取消"onDebugError"
注册的Listener
回调。
const Listener = ({errorCode,funcName,info})=>{
console.log(`onDebugError: ${errorCode},${funcName},${info}`)
}
zgEngine.on("onDebugError",Listener)
zgEngine.off("onDebugError",Listener)
使用removeAllListeners
方法取消"onDebugError"
所有注册的回调。
zgEngine.removeAllListeners("onDebugError")
联系我们
文档反馈