UI Kit quickstart
Agora UI Kit makes it easy to add Interactive Live Streaming to your app in minutes. UI Kit is an Open Source project that includes best practices for business logic, as well as a pre-built video UI. Every piece is customizable, so the developer has full control over how the video call looks and feels.
This page outlines the minimum code you need to integrate high-quality, low-latency Interactive Live Streaming functionality into your app with a customizable UI.
Understand the tech
UI Kit simplifies the implementation of Interactive Live Streaming by handling common calling logic such as remote user status, and displaying it in a pre-built customizable UI. UI Kit contains the following components:
To use UI Kit, you implement the following steps in your app:
-
Create an instance of the viewer
Declare and initialize an instance of the UI Kit viewer.
-
Join a channel
When you execute the
join
command, your app joins the channel, publishes the local audio and video streams to Agora SD-RTN™, and handles audio and video for anyone else who joins the call in a default UI.Yes, you read that right. After initializing a viewer instance, you can create or join a channel with just one line of code.
Prerequisites
To follow this procedure you must have:
-
Flutter 2.0.0 or higher
-
Dart 2.15.1 or higher
-
Android Studio, IntelliJ, VS Code, or any other IDE that supports Flutter, see Set up an editor.
-
If your target platform is iOS:
- Xcode on macOS (latest version recommended)
- A physical iOS device
- iOS version 12.0 or later
-
If your target platform is Android:
- Android Studio on macOS or Windows (latest version recommended)
- An Android emulator or a physical Android device.
-
If you are developing a desktop application for Windows, macOS or Linux, make sure your development device meets the Flutter desktop development requirements.
-
A computer with Internet access.
Ensure that no firewall is blocking your network communication.
Project setup
To integrate Interactive Live Streaming into your app using UI Kit, do the following:
-
Set up a Flutter environment for a Interactive Live Streaming project
In the terminal, run the following command:
Flutter checks your development device and helps you set up your local development environment. Make sure that your system passes all the checks.
-
Create a new Flutter app
In the IDE of your choice, create a new project.
You can also create a new project from the terminal using the command:
-
Add the Flutter UI Kit package to your project
Add the following line to
pubspec.yaml
under dependencies.You can get the latest Flutter UI Kit version number from pub.dev.
-
Use the Flutter framework to download dependencies to your app
Open a terminal window and execute the following command in the project folder:
-
Add permissions for microphone and camera usage
If your target platform is iOS, in Xcode, open Info in the project navigation panel, then add the following properties to the Information Property List:
Key Type Value NSMicrophoneUsageDescription String Access the microphone. NSCameraUsageDescription String Access the camera.
Implement a client for Interactive Live Streaming
When a user opens the app, you initialize UI Kit and join a channel. When the user taps the Leave button, the app leaves a channel. When another user joins the same channel, their video and audio is rendered in the app. This simple workflow enables you to concentrate on implementing Agora features and not UX bells and whistles.
To integrate real-time video with a ready-made user interface into your app using UI Kit:
Import the UI Kit classes
In /lib/main.dart
, replace the entire contents of the file with the UI Kit import
statements:
Create the variables you use to initiate and join a channel
In /lib/main.dart
, add these variable declarations after the import statements
:
Create the app framework that initializes an AgoraClient
instance and joins a channel
When you start the app, you initialize an instance of AgoraClient
using AgoraConnectionData
.
In /lib/main.dart
, add this code framework after the variable declarations:
Build the user interface
To implement the UI, add AgoraVideoViewer
and AgoraVideoButtons
widgets to a build
method.
In /lib/main.dart
, replace //Build
with this custom widget:
Test your implementation
To ensure that you have implemented Interactive Live Streaming in your app:
-
Generate a temporary token in Agora Console
-
In your browser, navigate to the Agora web demo and update App ID, Channel, and Token with the values for your temporary token, then click Join.
-
In
/lib/main.dart
, updateappId
,channelName
andtoken
with the values for your temporary token. -
Connect a test device to your development device.
-
In your IDE, click Run app or launch your app from the terminal using
flutter run
. A moment later you see the project installed on your device.If this is the first time you run the project, you need to grant microphone and camera access to your app.
-
Now, you can see yourself on the test device as you have successfully joined the channel as a Host.
-
To join the channel as Audience, edit the
AgoraClient
object and add aclientRole
in theAgoraChannelData
class: -
Relaunch the app. Now you have joined the channel as Audience and you see only the host stream.
Reference
This section contains information that completes the information in this page, or points you to documentation that explains other aspects to this product.
-
See the Open Source UI Kit projects on GitHub here.
-
Downloads shows you how to install Video SDK manually.
-
To ensure communication security in a test or production environment, use a token server to generate token is recommended to ensure communication security, see Implement the authentication workflow.