startScreenShare method
Method to start screen share.
Parameters:
hmsActionResultListener - hmsActionResultListener
is a callback instance on which HMSActionResultListener.onSuccess and HMSActionResultListener.onException will be called
Note: Pass [preferredExtension] and [appGroup] in HMSSDK instance for use screen share (broadcast screen) in iOS.
Refer screen share in android
Refer screen share in iOS
Implementation
Future<void> startScreenShare(
{HMSActionResultListener? hmsActionResultListener}) async {
HMSLocalPeer? localPeer = await getLocalPeer();
if (localPeer?.role.publishSettings?.allowed.contains("screen") ?? false) {
var result =
await PlatformService.invokeMethod(PlatformMethod.startScreenShare);
if (hmsActionResultListener != null) {
if (result == null) {
hmsActionResultListener.onSuccess(
methodType: HMSActionResultListenerMethod.startScreenShare);
} else {
hmsActionResultListener.onException(
methodType: HMSActionResultListenerMethod.startScreenShare,
hmsException: HMSException.fromMap(result["error"]));
}
}
} else {
if (hmsActionResultListener != null) {
hmsActionResultListener.onException(
methodType: HMSActionResultListenerMethod.startScreenShare,
hmsException: HMSException(
message: "Permission denied",
description: "Screen share is not included in publish settings",
action:
"Enable screen share from the dashboard for the current role",
isTerminal: false));
}
}
}