cometchat_calls_sdk 4.0.0-beta1 cometchat_calls_sdk: ^4.0.0-beta1 copied to clipboard
CometChat Calling Flutter Plugin.
CometChatCall Flutter Plugin #
Features #
- Direct Call
- Default Call
- Calling v3 support
- Support Android platform
- Support iOS platform
Integrate CometChat Flutter Calls Plugin #
1. Setup
-
SDK Version <= 2.14
A dependency may be manually added to your project pubspec.yaml:dependencies:
cometchatcalls_plugin:
hosted:
name: cometchatcalls_plugin
url: https://dart.cloudsmith.io/cometchat/call-team/
version: 1.0.1
-
SDK Version >= 2.15 dart pub is capable of adding a dependency from this repository to your package pubspec.yaml automatically:
dart pub add cometchatcalls_plugin:1.0.1 --hosted-url https://dart.cloudsmith.io/cometchat/call-team/
2. Configure CometChat Flutter Calls Plugin inside your Flutter app
i. Import CometChatCall
import 'package:cometchatcalls_plugin/cometchatcalls.dart';
ii. Initialize CometChatCalls
CallAppSettings callAppSettings= (CallAppSettingBuilder()
..appId = AppConfig.appId
..region= AppConfig.region
//..host = ""
).build();
CometChatCalls.init(callAppSettings, onSuccess: (String successMessage) {
debugPrint("===>>>: Initialization completed successfully $successMessage");
}, onError: (CometChatCallsException e) {
debugPrint("===>>>: Initialization failed with exception: ${e.message}");
});
iii. Generate Call Token
CometChatCalls.generateToken("sessionId", "userAuthToken", onSuccess: (GenerateToken generateToken){
debugPrint("===>>>: generateToken success: ${generateToken.token}");
}, onError: (CometChatCallsException e){
debugPrint("===>>>: generateToken Error: $e");
});
iv. Start call session
MainVideoContainerSetting videoSettings = MainVideoContainerSetting();
videoSettings.setVideoStreamProp("contain");
videoSettings.setNameLabelProps("top-left", true, "#000");
videoSettings.setZoomButtonProps("top-right", true);
videoSettings.setUserListButtonProps("top-left", true);
videoSettings.setFullScreenButtonProps("top-right", true);
CallSettings callSettings= (CallSettingsBuilder()
..defaultLayout = true
..videoSettings = videoSettings
..listener = this
).build();
CometChatCalls.startSession("generatedToken", callSettings, onSuccess: (Widget? callingWidget){
debugPrint("===>>>: startCallSession success");
}, onError: (CometChatCallsException e){
debugPrint("===>>>: startCallSession Error: $e");
});
v. Call settings
- End Session
CometChatCalls.endSession(onSuccess: (success) {
debugPrint("===>>>: callingOtherSettings: endSession: success $success");
Navigator.pop(context);
}, onError: (error) {
debugPrint("===>>>: callingOtherSettings: endSession: error $error");
});
- Switch Camera
CometChatCalls.switchCamera(onSuccess: (success) {
debugPrint("===>>>: callingOtherSettings: switchCamera: success $success");
}, onError: (error) {
debugPrint("===>>>: callingOtherSettings: switchCamera: error $error");
});
- Mute Audio
CometChatCalls.muteAudio(true ,onSuccess: (success) {
debugPrint("===>>>: callingOtherSettings: muteAudio: success $success");
}, onError: (error) {
debugPrint("===>>>: callingOtherSettings: muteAudio: error $error");
});
- Pause Video
CometChatCalls.pauseVideo(true, onSuccess: (success) {
debugPrint("===>>>: callingOtherSettings: pauseVideo: success $success");
}, onError: (error) {
debugPrint("===>>>: callingOtherSettings: pauseVideo:error $error");
});
- Set Audio Mode
CometChatCalls.setAudioMode("", onSuccess: (success) {
debugPrint("===>>>: callingOtherSettings: setAudioMode: success $success");
}, onError: (error) {
debugPrint("===>>>: callingOtherSettings: setAudioMode: error $error");
});
- Enter PIP Mode
CometChatCalls.enterPIPMode(onSuccess: (success) {
debugPrint("===>>>: callingOtherSettings: enterPIPMode: success $success");
}, onError: (error) {
debugPrint("===>>>: callingOtherSettings: enterPIPMode: error $error");
});
- Exit PIP Mode
CometChatCalls.exitPIPMode(onSuccess: (success) {
debugPrint("===>>>: callingOtherSettings: exitPIPMode: success $success");
}, onError: (error) {
debugPrint("===>>>: callingOtherSettings: exitPIPMode: error $error");
});
- Switch to Video Call
CometChatCalls.switchToVideoCall(onSuccess: (success) {
debugPrint("===>>>: callingOtherSettings: switchToVideoCall: success $success");
}, onError: (error) {
debugPrint("===>>>: callingOtherSettings: switchToVideoCall: error $error");
});
- Start Recording
CometChatCalls.startRecording(onSuccess: (success) {
debugPrint("===>>>: callingOtherSettings: startRecording: success $success");
}, onError: (error) {
debugPrint("===>>>: callingOtherSettings: startRecording: error $error");
});
- Stop Recording
CometChatCalls.stopRecording(onSuccess: (success) {
debugPrint("===>>>: callingOtherSettings: stopRecording: success $success");
}, onError: (error) {
debugPrint("===>>>: callingOtherSettings: stopRecording: error $error");
});