This topic describes how to use the screen sharing feature.
Publisher
Start screen sharing.
// Start screen sharing. AliRtcEngine mRtcEngine = AliRtcEngine.getInstance(getApplicationContext()); int ret = mRtcEngine.startScreenShare(); .....After you start the stream, use a callback to verify that the screen share is published successfully.
public void onScreenSharePublishStateChanged(AliRtcEngine.AliRtcPublishState oldState , AliRtcEngine.AliRtcPublishState newState, int elapseSinceLastState, String channel);Parameter
Type
Description
oldState
AliRtcPublishState
The previous publishing state.
newState
AliRtcPublishState
The current publishing state.
elapseSinceLastState
int
The state change interval, in milliseconds.
channel
String
The current channel ID.
Stop screen sharing.
// Stop screen sharing. int ret = mRtcEngine.stopScreenShare();;After you stop screen sharing, use a callback to verify that the screen share is successfully unpublished.
public void onScreenSharePublishStateChanged(AliRtcEngine.AliRtcPublishState oldState , AliRtcEngine.AliRtcPublishState newState, int elapseSinceLastState, String channel);Parameter
Type
Description
oldState
AliRtcPublishState
The previous publishing state.
newState
AliRtcPublishState
The current publishing state.
elapseSinceLastState
int
The time elapsed since the last state change. Unit: ms.
channel
String
The current channel ID.
Subscriber
Subscribers can subscribe to the screen sharing video stream automatically or manually, and set a view to display the stream. For more information, see the AliRtcEngine API reference.