Overview
This document intends for vidyo.io beginner. You can have the knowledge for building simple video chat application. If you have developed your application by other company solution and VidyoWorks API, you will experience how you can more easily develop video chat application than others.
Required software
- Android Studio
- Android Package of Vidyo.io
It can be downloaded from https://developer.vidyo.io/packages
Getting Started
Create a new Android Studio Project
- Start Android Studio and click "Start a new Android Studio project"
- Set Application name and location
- Select Minimum Android SDK
- The Vidyo.io SDK supports the Android 4.4+.
- Add an Empty Activity
Import the Android library
- Download the Android Package from https://developer.vidyo.io/packages
- This Package includes the Android library and a sample that can help developers to realize many features and start quickly.
- Copy all libraries into project libs directory: VidyoIODemo app "libs"
Develop the application
Configure Project
Add CAMERA and INTERNET permission in AndroidManifest.xml
Code Snippet:
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.INTERNET" />
Add source sets in the build.gradle file.
Code Snippet:
sourceSets {main { jniLibs.srcDirs = ['libs']}}
Design the UI
- Use "RelativeLayout" in the activity_main.xml.
- Change to Design View and remove "Hello World!" TextView.
- Add 3 Operation Buttons:
START button with properties – Text: Start, onClick: Start
CONNECT button with properties – Text: Connect, onClick: Connect
DISCONNECT button with properties – Text: Disconnect, onClick: Disconnect - Add Video Frame.
- Add the FrameLayout with properties – ID: videoFrame
Implement Source Code
- Import package of Vidyo.io library and add private member variable of VidyoConnector and FrameLayout.
- Initialize Vidyo Client.
Code Snippet:
Connector.SetApplicationUIContext(this); Connector.Initialize();
videoFrame = (FrameLayout) findViewById(R.id.videoFrame);
Implement Start method
Code Snippet:
public void Start(View v) { vc = new VidyoConnector(videoFrame,VidyoConnector.VidyoConnectorViewStyle.VIDYO_CONNECTORVIEWSTYLE_Default, 16, "", "", 0);
vc.ShowViewAt(videoFrame, 0, 0, videoFrame.getWidth(),
videoFrame.getHeight());
}
Implement Connect method
Code Snippet:
public void Connect(View v) {
String token = "cHJvdmlzaW9uAGRlbW91c2VyX2IwOTZhNkA2OGY2MTMudmlkeW8uaW8ANjM2NjcxNjc5ODYAADI3NGEzZTUwZThkOTI2NmNlNzgyOTNmYmE2NDczYzM4NThjNGQ4OGYxMzc2MzY2MjU0ODRiMDIyZmZkMWEzY2ZmMzFkZDM0NzQ3ZjBhOGU5MTk2NjAyYzBiNGVmZDczMQ==";
vc.Connect("prod.vidyo.io", token, "DemoUser", "DemoRoom", this);
}
Get a token quickly
- Access to https://vidyo.io and login.
- Go to menu DEVELOPERS Demo.
- Click "GENERATE LINK" to get a meeting link.
The meeting link is as below:
Note:
The "%3D" has to be replaced by "=" when use it in the code, because it is transformed from equal sign "=" as URL rule.
How to Generate a Token
Access to https://vidyo.io and login.
Go to menu DEVELOPERS Documentation "How to Generate a Token"
Implement Disconnect method
Code Snippet:
public void Disconnect(View v) { vc.Disconnect();}
Implement IConnect Interface
Code Snippet:
public void OnSuccess() {}
public void OnFailure(VidyoConnector.VidyoConnectorFailReason vidyoConnectorFailReason) {}
public void OnDisconnected(VidyoConnector.VidyoConnectorDisconnectReason vidyoConnectorDisconnectReason) {}
The connect listener can be register when vc.Connect(…) method is invoked, which need to implement the iConnect interface.
Build and Run the Application
At first, go to Android mobile's "Developer Options" and enable the "USB Debugging".
And then connect mobile to the computer, which would be recognized by "Android Monitors" of Android Studio.
- Click run button to execute application.
- Click Start button and preview self.
- Click Connect button to join the meeting.
Other participants can join meeting via above URL generated from Vidyo.io. - Click Disconnect button to leave the meeting.
Note: Everyone has to join the meeting via the same resourceId.
Reference
Video Clip – Vidyo.io | Build an Android Video Chat App in Minutes
https://www.youtube.com/watch?v=tbT8EEw9wNw&t=1s
7 Comments
Follow