Kotlin
Connect, Publish and Show Yourself
After permissions are granted:
- Build a
Sessionwith App ID and session ID. connect(token).- In
onConnected, build aPublisher, attachpublisher.viewto a container, thensession.publish(publisher).
val session = Session.Builder(context, VideoConfig.APP_ID, VideoConfig.SESSION_ID)
.build()
session.setSessionListener(object : Session.SessionListener {
override fun onConnected(session: Session) {
val publisher = Publisher.Builder(context).build().apply {
setPublisherListener(/* … */)
setStyle(
com.opentok.android.BaseVideoRenderer.STYLE_VIDEO_SCALE,
com.opentok.android.BaseVideoRenderer.STYLE_VIDEO_FILL
)
}
publisherContainer.removeAllViews()
publisherContainer.addView(publisher.view)
session.publish(publisher)
}
override fun onDisconnected(session: Session) {}
override fun onError(session: Session, error: com.opentok.android.OpentokError) {}
override fun onStreamReceived(session: Session, stream: Stream) { /* Step 5 */ }
override fun onStreamDropped(session: Session, stream: Stream) { /* Step 5 */ }
})
session.connect(VideoConfig.TOKEN)
Call session.onResume() / session.onPause() from the hosting Activity or Fragment to match app lifecycle.
Simple Multiparty
Learn how to use the Vonage Android SDK for a multi-party call. The application publishes audio/video from a device and can connect to multiple subscribers.
Available on:
Steps
1
Introduction2
Getting Started3
Creating a new project4
Adding the Android SDK5
Setting up authentication6
Requesting permissions7
Connect publish and show yourself8
Multiparty subscribe to every remote stream9
Host SDK views in AndroidView10
Running the app11
Conclusion