Screen sharing
What's screen sharing?
Screen sharing refers to the process of broadcasting the contents of one screen to another device or multiple devices in a video call or interactive video scene.
Starts screen sharing | Screen shared by mobile apps | Screen shared by web apps | Landscape mode |
---|---|---|---|
Implementation
Use the screen sharing
Screen sharing is only supported in the gallery layout. To share your screen, you will need to set the layout
inside the ZegoUIKitPrebuiltCallConfig
to Gallery
first.
To decide whether to use the full-screen mode by default during screen sharing, you will need to configure the showNewScreenSharingViewInFullscreenMode
inside the ZegoLayoutGalleryConfig
. Set it to true
(default setting), meaning that the shared screen will automatically be in full screen when the screen sharing starts.
Meanwhile, the full-screen mode button is customizable, you can decide the way how it shows. To set it, configure the showScreenSharingFullscreenModeToggleButtonRules
inside the ZegoLayoutGalleryConfig
:
-
showWhenScreenPressed
: (default setting) shows the full-screen mode button when clicking the shared screen. -
alwaysShow
: always shows the full-screen mode button. -
alwaysHide
: always hides the full-screen mode button.
Add/customize the buttons
To start the screen sharing, add the ZegoMenuBarButtonName.toggleScreenSharingButton
config to the bottomMenuBarConfig
to let the screen sharing button show.
To customize the UI of the full-screen mode button, configure the foregroundBuilder
. To decide whether to show the shared screen in full-screen mode, use the controller.showScreenSharingViewInFullscreenMode
inside the custom foregroundBuilder
.
Create a Broadcast Upload Extension (for iOS only)
TIPS
The memory limit of the Broadcast Upload Extension is 50 MB, make sure the memory usage of the Extension for screen sharing does not exceed 50 MB.
-
Open your project in Xcode, and select File > New > Target.
-
In the following window, select the Broadcast Upload Extension, and click Next.
-
Fill in items or choose options for your new target, such as fill in the Product Name as ScreenShare, and choose options for the Team, Language, and other required information, and then click Finish.
WARNING
Don't need to check the Include UI Extension option.
-
Set screen sharing target minimum support version. The minimum support version needs to be greater than or equal to 12. If your phone's system version is lower than this minimum support version, screen sharing function will not be available.
-
After you created the Broadcast Upload Extension, you will see a folder for this Extension in your project with a structure similar to the following. This folder is used to store the implementation codes for the screen sharing feature:
-
Add the
ZegoExpressEngine.xcframework
dependency.
-
Run the
cd
command in the Terminal to navigate to your iOS project directory, and run thepod install
to install theZegoExpressEngine
library. -
Click the + button as shown in the following figure.
-
Select and add the
ZegoExpressEngine.xcframework
. -
Set Embed to
Do Not Embed
.
-
Replace the code in the
SampleHandler
file with the following code: