
Build a UGC Live Streaming App with Amazon IVS: Adding ScreenSharing to a Web Broadcast (Lesson 3.4)
Welcome to Lesson 3.4 in this series where we're looking at building a web based user-generated content live streaming application with Amazon IVS. This entire series is available in video format on the AWS Developers YouTube channel and all of the code related to the sample application used in this series can be viewed on GitHub. Refer to the links at the end of the post for more information.
navigator.mediaDevices.getUserMedia()
is used to obtain permissions and access a user's cameras and microphones. To create a media stream from the user's desktop, window, or browser tab, there is a similar function called navigator.mediaDevices.getDisplayMedia()
(docs). To toggle a screenshare, we check the model variable isSharingScreen
, and if this value is false, we can use getDisplayMedia()
, to get a MediaStream
and addVideoInputDevice()
to add that stream to the broadcast. We also update the currentVideoComposition
in our model to reduce the size of the user's camera stream, and position it in the bottom right corner of the broadcast. If the user is turning off screensharing, we remove the screenshare video and reset the composition to the default (full frame) composition setting. Any opinions in this post are those of the individual author and may not reflect the opinions of AWS.