Meeting instance
In order to join/interact with the Meeting you need to create an instance
val eyesonMeeting = EyesonMeeting(
application = getApplication(),
experimentalFeatureStereo = false // Experimental! Usage is NOT recommended
)
Join a meeting
Can either be done via accessKey
or guestToken
.
audioOnly
no video will be sent/received
local
/remove
are the respective VideoRenderer. Can be left null at start and set at a later time. Video will be sent/received regardless.
screenShareInfo
If provided join the meeting with active screen share (your local video won't be visible until the screen share is stopped) See Screen share for further information.
The Android OS could suspend your app execution as soon as it is no longer visible to the user. In order to prevent this, you must start a foreground service.
See Background handling for further information.
Join meeting with accessKey
eyesonMeeting.join(
accessKey = accessKey,
frontCamera = true,
audioOnly = false,
local = localVideoRenderer,
remote = remoteVideoRenderer,
eventListener: EyesonEventListener,
microphoneEnabledOnStart = true,
videoEnabledOnStart = true,
screenShareInfo = null
)
Join meeting with guestToken
eyesonMeeting.joinAsGuest(
guestToken = guestToken,
name = "My name in the meeting",
id = null, // optional
avatar = null, // optional URL
frontCamera = true,
audioOnly = false,
local = localVideoRenderer,
remote = remoteVideoRenderer,
eventListener: EyesonEventListener,
microphoneEnabledOnStart = true,
videoEnabledOnStart = true,
screenShareInfo = null
)
Background handling
To prevent the OS from suspending the execution of your app you need to start a foreground service.
Manifest
Add the following permissions and service to your manifest
<!-- For API >= 33 -->
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
<!-- For API >= 34 -->
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_CAMERA" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_MICROPHONE" />
<application
...
<service
android:name=".service.MeetingActiveService"
android:exported="false"
android:foregroundServiceType="camera|microphone" />
</application>
Service
Add Service itself. You can use this example or your own customized service.
camera and microphone are while-in-use permissions. Be aware of that when starting your foreground service!
See Foreground services and Restrictions on starting foreground services for detailed information
class MeetingActiveService : Service() {
override fun onBind(intent: Intent?): IBinder? {
// Not a bound service
return null
}
override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int {
createNotificationChannel()
val foregroundServiceType = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
ServiceInfo.FOREGROUND_SERVICE_TYPE_CAMERA or ServiceInfo.FOREGROUND_SERVICE_TYPE_MICROPHONE
} else {
0
}
ServiceCompat.startForeground(this, 1, generateInCallNotification(this), foregroundServiceType)
return START_STICKY
}
override fun onTaskRemoved(rootIntent: Intent?) {
stopSelf()
}
private fun createNotificationChannel() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
val channel = NotificationChannel(
IN_CALL_CHANNEL_ID,
IN_CALL_CHANNEL_NAME,
NotificationManager.IMPORTANCE_DEFAULT
)
val manager = getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager
manager.createNotificationChannel(channel)
}
}
private fun generateInCallNotification(context: Context): Notification {
val pendingIntent =
PendingIntent.getActivity(
context, 0,
Intent(context, MainActivity::class.java),
PendingIntent.FLAG_IMMUTABLE or PendingIntent.FLAG_ONE_SHOT
)
return NotificationCompat.Builder(context, IN_CALL_CHANNEL_ID)
.setOngoing(true)
.setSilent(true)
.setContentText(context.getText(R.string.click_to_resume))
.setContentTitle(context.getText(R.string.active_call))
.setPriority(NotificationCompat.PRIORITY_DEFAULT)
.setSmallIcon(R.drawable.video_call_24)
.setContentIntent(pendingIntent)
.setAutoCancel(true)
.build()
}
companion object {
const val IN_CALL_CHANNEL_ID = "17"
const val IN_CALL_CHANNEL_NAME = "In call"
}
}
Start foreground service
You can start the service as soon as you have joined the meeting or at the latest when your transitions to background.
val intent = Intent(context, MeetingActiveService::class.java)
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
ContextCompat.startForegroundService(context, intent)
} else {
context.startService(intent)
}
Stop service
Stop the service once you leave the meeting or your app becomes active again (optional).
val intent = Intent(context, MeetingActiveService::class.java)
context.stopService(intent)