startScreenCaptureByDisplayId

Captures the screen by specifying the display ID.


            
            

            
         
            
            
            
            
            

Captures the video stream of a screen or a part of the screen area.

Applicable scenarios

In the screen sharing scenario, you need to call this method to start capturing the screen video stream. For implementation guidance of screen sharing, please refer to .

Call timing

You can call this method either before or after joining the channel, with the following differences:
  • Call this method before joining a channel, and then call joinChannel [2/2] to join a channel and set publishScreenTrack or publishSecondaryScreenTrack to true to start screen sharing.
  • Call this method after joining a channel, and then call updateChannelMediaOptions to join a channel and set publishScreenTrack or publishSecondaryScreenTrack to true to start screen sharing.

Restrictions

None.

Parameters

displayId
The display ID of the screen to be shared.
captureParams
Screen sharing configurations. The default video dimension is 1920 x 1080, that is, 2,073,600 pixels. Agora uses the value of this parameter to calculate the charges. See .

Returns

  • 0: Success.
  • < 0: Failure.
    • -2: The parameter is invalid.
    • -8: The screen sharing state is invalid. Probably because you have shared other screens or windows. Try calling stopScreenCapture to stop the current sharing and start sharing the screen again.