Features topic
- Event Listener
Event Listeners
express event listeners
In the Zego Express Engine, event callbacks are exclusive.
This means that if any newly listener register to a event callback, the previously registered listener will become invalid.
If you want to use both the Zego Express Engine and the UIKit prebuilt series product together while also listening to events from Zego Express, you need to prevent the aforementioned event conflict issue. To do this, please listen to the events thrown by ZegoUIKit.
Example
Here's how you can implement it:
First, inherit the ZegoUIKitExpressEventInterface and override the event listener you need, as shown below:
class ExpressEvent extends ZegoUIKitExpressEventInterface { @override void onDebugError( int errorCode, String funcName, String info, ) { /// your code } }
Next, create an instance of your event listener class and register the event using
ZegoUIKit().registerExpressEvent
:final expressEvent = ExpressEvent(); ZegoUIKit().registerExpressEvent(expressEvent);
Finally, if you no longer want to listen to the events, you can unregister the event using
ZegoUIKit().unregisterExpressEvent
.ZegoUIKit().unregisterExpressEvent(expressEvent);
media event listeners
The media APIs is derived from the Zego Express Engine.
In the Zego Express Engine, event callbacks are exclusive.
This means that if any newly listener register to a event callback, the previously registered listener will become invalid.
If you want to use both the Zego Express Engine and the UIKit prebuilt series product together while also listening to events from Zego Express, you need to prevent the aforementioned event conflict issue. To do this, please listen to the events thrown by ZegoUIKit.
Example
Here's how you can implement it:
First, inherit the ZegoUIKitMediaEventInterface and override the event listener you need, as shown below:
class MediaEvent extends ZegoUIKitMediaEventInterface { @override void onMediaPlayerStateUpdate( ZegoMediaPlayer mediaPlayer, ZegoMediaPlayerState state, int errorCode,) { /// your code } }
Next, create an instance of your event listener class and register the event using
ZegoUIKit().registerMediaEvent
:final mediaEvent = MediaEvent(); ZegoUIKit().registerMediaEvent(mediaEvent);
Finally, if you no longer want to listen to the events, you can unregister the event using
ZegoUIKit().unregisterMediaEvent
.ZegoUIKit().unregisterMediaEvent(mediaEvent);