VideoSDK Class Methods - Android
initialize()
To initialize the meeting, first you have to initialize the VideoSDK
.
You can initialize the VideoSDK
using initialize()
method provided by the SDK.
Parameters
- context: Context
Returns
void
VideoSDK.initialize(Context context)
config()
By using config()
method, you can set the token
property of VideoSDK
class.
Please refer this documentation to generate a token.
Parameters
- token: String
Returns
void
VideoSDK.config(String token)
initMeeting()
- Initialize the meeting using a factory method provided by the SDK called
initMeeting()
. initMeeting()
will generate a newMeeting
class and the initiated meeting will be returned.
VideoSDK.initMeeting(
Context context,
String meetingId,
String name,
boolean micEnabled,
boolean webcamEnabled,
String participantId,
String mode,
boolean multiStream,
Map<String, CustomStreamTrack> customTracks
JSONObject metaData,
String signalingBaseUrl
PreferredProtocol preferredProtocol
)
- Please refer this documentation to know more about
initMeeting()
.
getDevices()
-
The
getDevices()
method returns a list of the currently available media devices, such as microphones, cameras, headsets, and so forth. The method returns a list ofDeviceInfo
objects describing the devices. -
DeviceInfo
class has four properties :-
DeviceInfo.deviceId
- Returns a string that is an identifier for the represented device, persisted across sessions.
-
DeviceInfo.label
- Returns a string describing this device (for example
BLUETOOTH
).
- Returns a string describing this device (for example
-
DeviceInfo.kind
- Returns an enumerated value that is either
video
oraudio
.
- Returns an enumerated value that is either
-
DeviceInfo.FacingMode
- Returns a value of type
FacingMode
indicating which camera device is in use (front or back).
- Returns a value of type
-
Returns
Set<DeviceInfo>
Example
- Kotlin
- Java
val devices: Set<DeviceInfo> = VideoSDK.getDevices()
for (deviceInfo in devices) {
Log.d("VideoSDK", "Device's DeviceId " + deviceInfo.deviceId)
Log.d("VideoSDK", "Device's Label " + deviceInfo.label)
Log.d("VideoSDK", "Device's Kind " + deviceInfo.kind)
Log.d("VideoSDK", "Device's Facing Mode " + deviceInfo.facingMode) //Value will be null for Audio Devices
}
Set<DeviceInfo> devices = VideoSDK.getDevices();
for (DeviceInfo deviceInfo :
devices) {
Log.d("VideoSDK", "Device's DeviceId " + deviceInfo.getDeviceId());
Log.d("VideoSDK", "Device's Label " + deviceInfo.getLabel());
Log.d("VideoSDK", "Device's Kind " + deviceInfo.getKind());
Log.d("VideoSDK", "Device's Facing Mode " + deviceInfo.getFacingMode()) //Value will be null for Audio Devices
}
getVideoDevices()
-
The
getVideoDevices
method returns a list of currently available video devices. The method returns a list ofVideoDeviceInfo
objects describing the video devices. -
VideoDeviceInfo
class has four properties :-
VideoDeviceInfo.deviceId
- Returns a string that is an identifier for the represented device, persisted across sessions.
-
VideoDeviceInfo.label
- Returns a string describing this device (for example
BLUETOOTH
).
- Returns a string describing this device (for example
-
VideoDeviceInfo.kind
- Returns an enumerated value that is
video
.
- Returns an enumerated value that is
-
VideoDeviceInfo.FacingMode
- Returns a value of type
FacingMode
indicating which camera device is in use (front or back).
- Returns a value of type
-
Returns
Set<VideoDeviceInfo>
Example
- Kotlin
- Java
val videoDevices: Set<VideoDeviceInfo> = VideoSDK.getVideoDevices()
for (videoDevice in videoDevices) {
Log.d("VideoSDK", "Video Device's DeviceId " + videoDevice.deviceId)
Log.d("VideoSDK", "Video Device's Label " + videoDevice.label)
Log.d("VideoSDK", "Video Device's Kind " + videoDevice.kind)
}
Set<VideoDeviceInfo> videoDevices = VideoSDK.getVideoDevices();
for (VideoDeviceInfo videoDevice:
videoDevices) {
Log.d("VideoSDK", "Video Device's DeviceId " + videoDevice.getDeviceId());
Log.d("VideoSDK", "Video Device's Label " + videoDevice.getLabel());
Log.d("VideoSDK", "Video Device's Kind " + videoDevice.getKind());
}
getAudioDevices()
-
The
getAudioDevices
method returns a list of currently available audio devices. The method returns a list ofAudioDeviceInfo
objects describing the audio devices. -
AudioDeviceInfo
class has three properties :-
AudioDeviceInfo.deviceId
- Returns a string that is an identifier for the represented device, persisted across sessions.
-
AudioDeviceInfo.label
- Returns a string describing this device (for example
BLUETOOTH
).
- Returns a string describing this device (for example
-
AudioDeviceInfo.kind
- Returns an enumerated value that is
audio
.
- Returns an enumerated value that is
-
Returns
Set<AudioDeviceInfo>
Example
- Kotlin
- Java
val audioDevices: Set<AudioDeviceInfo> = VideoSDK.getAudioDevices()
for (audioDevice in audioDevices) {
Log.d("VideoSDK", "Audio Device's DeviceId " + audioDevice.deviceId)
Log.d("VideoSDK", "Audio Device's Label " + audioDevice.label)
Log.d("VideoSDK", "Audio Device's Kind " + audioDevice.kind)
}
Set<AudioDeviceInfo> audioDevices = VideoSDK.getAudioDevices();
for (AudioDeviceInfo audioDevice:
audioDevices) {
Log.d("VideoSDK", "Audio Device's DeviceId " + audioDevice.getDeviceId());
Log.d("VideoSDK", "Audio Device's Label " + audioDevice.getLabel());
Log.d("VideoSDK", "Audio Device's Kind " + audioDevice.getKind());
}
setAudioDeviceChangeListener()
- The
AudioDeviceChangeEvent
is emitted when an audio device, is connected to or removed from the device. This event can be set by usingsetAudioDeviceChangeListener()
method.
Parameters
- audioDeviceChangeEvent: AudioDeviceChangeEvent
Returns
void
Example
- Kotlin
- Java
VideoSDK.setAudioDeviceChangeListener { selectedAudioDevice: AudioDeviceInfo, audioDevices: Set<AudioDeviceInfo> ->
Log.d(
"VideoSDK",
"Selected Audio Device: " + selectedAudioDevice.label
)
for (audioDevice in audioDevices) {
Log.d("VideoSDK", "Audio Devices" + audioDevice.label)
}
}
VideoSDK.setAudioDeviceChangeListener((selectedAudioDevice, audioDevices) -> {
Log.d("VideoSDK", "Selected Audio Device: " + selectedAudioDevice.getLabel());
for (AudioDeviceInfo audioDevice :
audioDevices) {
Log.d("VideoSDK", "Audio Devices" + audioDevice.getLabel());
}
});
checkPermissions()
- The
checkPermissions()
method verifies whether permissions to access camera and microphone devices have been granted. If the required permissions are not granted, the method will proceed to request these permissions from the user.
Parameters
-
context
- type:
Context
REQUIRED
- The android context.
- type:
-
permission
- type:
List<Permission>
REQUIRED
- The permission to be requested.
- type:
-
permissionHandler
- type:
PermissionHandler
REQUIRED
- The permission handler object for handling callbacks of various user actions such as permission granted, permission denied, etc.
- type:
-
rationale
- type:
String
OPTIONAL
- Explanation to be shown to user if they have denied permission earlier. If this parameter is not provided, permissions will be requested without showing the rationale dialog.
- type:
-
options
- type:
Permissions.Options
OPTIONAL
- The options object for setting title and description of dialog box that prompts users to manually grant permissions by navigating to device settings. If this parameter is not provided,the default title and decription will be used for the dialog box.
- type:
Returns
void
Example
- Kotlin
- Java
private val permissionHandler: PermissionHandler = object : PermissionHandler() {
override fun onGranted() {}
override fun onBlocked(
context: Context,
blockedList: java.util.ArrayList<Permission>
): Boolean {
for (blockedPermission in blockedList) {
Log.d("VideoSDK Permission", "onBlocked: $blockedPermission")
}
return super.onBlocked(context, blockedList)
}
override fun onDenied(
context: Context,
deniedPermissions: java.util.ArrayList<Permission>
) {
for (deniedPermission in deniedPermissions) {
Log.d("VideoSDK Permission", "onDenied: $deniedPermission")
}
super.onDenied(context, deniedPermissions)
}
override fun onJustBlocked(
context: Context,
justBlockedList: java.util.ArrayList<Permission>,
deniedPermissions: java.util.ArrayList<Permission>
) {
for (justBlockedPermission in justBlockedList) {
Log.d("VideoSDK Permission", "onJustBlocked: $justBlockedPermission")
}
super.onJustBlocked(context, justBlockedList, deniedPermissions)
}
}
val permissionList: MutableList<Permission> = ArrayList()
permissionList.add(Permission.audio)
permissionList.add(Permission.video)
permissionList.add(Permission.bluetooth)
val rationale = "Please provide permissions"
val options =
Permissions.Options().setRationaleDialogTitle("Info").setSettingsDialogTitle("Warning")
//If you wish to disable the dialog box that prompts
//users to manually grant permissions by navigating to device settings,
//you can set options.sendDontAskAgainToSettings(false)
VideoSDK.checkPermissions(this, permissionList, rationale, options, permissionHandler)
private final PermissionHandler permissionHandler = new PermissionHandler() {
@Override
public void onGranted() {
}
@Override
public boolean onBlocked(Context context, ArrayList<Permission> blockedList) {
for (Permission blockedPermission :
blockedList) {
Log.d("VideoSDK Permission", "onBlocked: " + blockedPermission);
}
return super.onBlocked(context, blockedList);
}
@Override
public void onDenied(Context context, ArrayList<Permission> deniedPermissions) {
for (Permission deniedPermission :
deniedPermissions) {
Log.d("VideoSDK Permission", "onDenied: " + deniedPermission);
}
super.onDenied(context, deniedPermissions);
}
@Override
public void onJustBlocked(Context context, ArrayList<Permission> justBlockedList, ArrayList<Permission> deniedPermissions) {
for (Permission justBlockedPermission :
justBlockedList) {
Log.d("VideoSDK Permission", "onJustBlocked: " + justBlockedPermission);
}
super.onJustBlocked(context, justBlockedList, deniedPermissions);
}
};
List<Permission> permissionList = new ArrayList<>();
permissionList.add(Permission.audio);
permissionList.add(Permission.video);
permissionList.add(Permission.bluetooth);
String rationale = "Please provide permissions";
Permissions.Options options =
new Permissions.Options().setRationaleDialogTitle("Info").setSettingsDialogTitle("Warning");
//If you wish to disable the dialog box that prompts
//users to manually grant permissions by navigating to device settings,
//you can set options.sendDontAskAgainToSettings(false)
VideoSDK.checkPermissions(this, permissionList, rationale, options, permissionHandler);
setSelectedAudioDevice()
- It sets the selected audio device, allowing the user to specify which audio device to use in the meeting.
Parameters
- selectedAudioDevice: AudioDeviceInfo
Returns
void
Example
- Kotlin
- Java
val audioDevices: Set<AudioDeviceInfo> = VideoSDK.getAudioDevices()
val audioDeviceInfo: AudioDeviceInfo = audioDevices.toTypedArray().get(0) as AudioDeviceInfo
VideoSDK.setSelectedAudioDevice(audioDeviceInfo)
Set<AudioDeviceInfo> audioDevices = VideoSDK.getAudioDevices();
AudioDeviceInfo audioDeviceInfo = (AudioDeviceInfo) audioDevices.toArray()[0];
VideoSDK.setSelectedAudioDevice(audioDeviceInfo);
setSelectedVideoDevice()
- It sets the selected video device, allowing the user to specify which video device to use in the meeting.
Parameters
- selectedVideoDevice: VideoDeviceInfo
Returns
void
Example
- Kotlin
- Java
val videoDevices: Set<VideoDeviceInfo> = VideoSDK.getVideoDevices()
val videoDeviceInfo: VideoDeviceInfo = videoDevices.toTypedArray().get(1) as VideoDeviceInfo
VideoSDK.setSelectedVideoDevice(videoDeviceInfo)
Set<VideoDeviceInfo> videoDevices = VideoSDK.getVideoDevices();
VideoDeviceInfo videoDeviceInfo = (VideoDeviceInfo) videoDevices.toArray()[1];
VideoSDK.setSelectedVideoDevice(videoDeviceInfo);
applyVideoProcessor()
- This method allows users to dynamically apply virtual background to their video stream during a live session.
Parameters
-
videoFrameProcessor
- type:
VideoFrameProcessor
- This is an object of the
VideoFrameProcessor
class, which overrides theonFrameCaptured(VideoFrame videoFrame)
method.
- type:
Returns
void
Example
- Kotlin
- Java
val uri = Uri.parse("https://st.depositphotos.com/2605379/52364/i/450/depositphotos_523648932-stock-photo-concrete-rooftop-night-city-view.jpg")
val backgroundImageProcessor = BackgroundImageProcessor(uri)
VideoSDK.applyVideoProcessor(backgroundImageProcessor)
Uri uri = Uri.parse("https://st.depositphotos.com/2605379/52364/i/450/depositphotos_523648932-stock-photo-concrete-rooftop-night-city-view.jpg");
BackgroundImageProcessor backgroundImageProcessor = new BackgroundImageProcessor(uri)
VideoSDK.applyVideoProcessor(backgroundColorProcessor);
removeVideoProcessor()
-
This method provides users with a convenient way to revert their video background to its original state, removing any previously applied virtual background.
- Returns:
void
- Returns:
Example
VideoSDK.removeVideoProcessor();
Got a Question? Ask us on discord