Kotlin
Initializing Session
1. Perform session initialisation
Request camera/mic permissions, then connect to the Vonage session:
2. On Session connected request screen capture
When connected, launch the system screen capture dialog:
3. When user grants permission, start capture
When the user shares screen via the dialog:
- Start the foreground service – Required before using
MediaProjection. - Get
MediaProjection– From the result intent. - Create the capturer –
ScreenSharingCapturer(context, mediaProjection). - Build the publisher – Use the capturer and set video type to
PublisherKitVideoTypeScreen. - Publish –
session.publish(publisher).
PublisherKitVideoTypeScreen optimizes encoding for screen content (e.g., text and UI).
Step 5: Foreground Service
The ScreenSharingService shows a notification and calls startForeground() with ServiceInfo.FOREGROUND_SERVICE_TYPE_MEDIA_PROJECTION. This must happen before you call getMediaProjection().
ScreenSharingManager binds to this service and exposes startForeground(). Initialize it in onCreate and unbind in onDestroy.
Screen sharing
Learn how to implement tha screensharing capability using the Vonage Video API platform.
手順
1
Introduction2
Getting Started3
Creating a new project4
Adding the Android SDK5
Setting up authentication6
Requesting permissions7
Implement the Custom Capturer8
Starting the capture9
Initializing Session10
Running the app11
Conclusion