Skip to main content
Version: 0.x.x

Custom ScreenShare Sources - Android

To deliver high-quality livestreams, it's essential to fine-tune screen share tracks being broadcasted. Whether youโ€™re hosting a webinar, or going live with a presentation, using custom media tracks gives you better control over stream quality and performance.

Custom Screen Share Trackโ€‹

This feature enables the customization of screenshare streams with enhanced optimization modes and predefined encoder configuration (resolution + FPS) for specific use cases, which can then be sent to other hosts and audience members.

How to Create Custom Screen Share Track ?โ€‹

  • You can create a Screen Share track using createScreenShareVideoTrack() method of VideoSDK.
  • This method can be used to create video track using different encoding parameters and optimization mode.

Exampleโ€‹

// data is received from onActivityResult method.
VideoSDK.createScreenShareVideoTrack(

// This will accept the height & FPS of video you want to capture.
"h720p_15fps", // `h360p_30fps` | `h1080p_30fps` // Default : `h720p_15fps`

// It is Intent received from onActivityResult when user provide permission for ScreenShare.
data,

// Pass Conext
this)

//Callback to this listener will be made when track is ready with CustomTrack as parameter
{
track ->
meeting!!.enableScreenShare(track)
}

How to Setup Custom Screen Share Track ?โ€‹

In order to switch tracks during the meeting, you have to pass the CustomStreamTrack in the enableScreenShare() method of Meeting.

note

Make sure to call disableScreenShare() before you create a new track as it may lead to unexpected behavior.

Exampleโ€‹
@TargetApi(21)
private fun askPermissionForScreenShare() {
val mediaProjectionManager = application.getSystemService<Any>(
Context.MEDIA_PROJECTION_SERVICE
) as MediaProjectionManager
startActivityForResult(
mediaProjectionManager.createScreenCaptureIntent(), CAPTURE_PERMISSION_REQUEST_CODE
)
}

@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
super.onActivityResult(requestCode, resultCode, data)
if (requestCode != CAPTURE_PERMISSION_REQUEST_CODE) return
if (resultCode == RESULT_OK) {
VideoSDK.createScreenShareVideoTrack("h720p_15fps", data, this) { track ->
liveStream!!.enableScreenShare(track)
}
}
}

API Referenceโ€‹

The API references for all the methods and events utilised in this guide are provided below.

Got a Question? Ask us on discord