Android

更新时间:
复制 MD 格式

This topic describes how to use the screen sharing feature.

Publisher

  1. Start screen sharing.

    // Start screen sharing.
    AliRtcEngine mRtcEngine = AliRtcEngine.getInstance(getApplicationContext());
    int ret = mRtcEngine.startScreenShare();
    .....
  2. 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.

  3. Stop screen sharing.

    // Stop screen sharing.
    int ret = mRtcEngine.stopScreenShare();;
  4. 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.