How to publish LocalScreenShare tracks from IOS to Web browser in React-Native using Twilio

Viewed 55

I want to integrate Screen Share feature in my react-native application in which I am using Twilio for video communication. In Web we are able to achieve this by following these steps.

1 : We get the media device stream using

navigator.mediaDevices.getDisplayMedia({ video: true, });

2 : Then we get the first stream tracks using

const newScreenTrack = first(stream.getVideoTracks());

3 : After that we set this newScreenTrack in some useState

const localScreenTrack = new TwilioVideo.LocalVideoTrack( newScreenTrack );

4 : After that we first unpublish the previous tracks and publish the new tracks using

videoRoom.localParticipant.publishTrack(newScreenTrack, { name: "screen_share", });

5 : And finally we pass these tracks in our ScreenShare component and render these tracks to View the screenShare from remote Participant.

I need to do the same thing in my react-native application as well. Where if localParticipant ask for screenShare permission to another participant. Participant will accept the permission and able to publish the localScreenShare tracks. If anyone know this please help me in this. It would be really helpful. Thank you

1 Answers

I think this is an issue with the react-native-twilio-video-webrtc package. It seems that, as you discovered in this issue, that screen sharing was previously a feature of the library and it was removed as part of a refactor.

Sadly, the library does more work than the underlying Twilio libraries to look after the video and audio tracks. The Twilio library is built to be able to publish more than one track at a time, however this React Native library allows you to publish a single audio track and a single video track using the camera at a time.

In order to add screen sharing, you can either support pull requests like this one or refactor the library to separate getting access to the camera from publishing a video track, so that you can publish multiple video tracks at a time, including screen tracks.

Related