api.video is the video infrastructure for product builders. Lightning fast video APIs for integrating, scaling, and managing on-demand & low latency live streaming features in your app.
- Table of contents
- Project description
- Getting started
- Tips
- Documentation
- Dependencies
- Sample application
- FAQ
This library is an easy way to broadcast livestream to api.video platform on Android.
On build.gradle add the following code in dependencies:
dependencies {
implementation 'video.api:android-live-stream:1.4.2'
}
<manifest>
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.RECORD_AUDIO" />
</manifest>
Your application must dynamically require android.permission.CAMERA
and android.permission.RECORD_AUDIO
.
- Add permissions to your
AndroidManifest.xml
and request them in your Activity/Fragment. - Add a
ApiVideoView
to your Activity/Fragment layout for the camera preview.
<video.api.livestream.views.ApiVideoView
android:id="@+id/apiVideoView"
android:layout_width="match_parent"
android:layout_height="match_parent" />
- Implement a
IConnectionListener
.
val connectionListener = object : IConnectionListener {
override fun onConnectionSuccess() {
//Add your code here
}
override fun onConnectionFailed(reason: String?) {
//Add your code here
}
override fun onDisconnect() {
//Add your code here
}
}
- Create an
ApiVideoLiveStream
instance.
class MyFragment : Fragment(), IConnectionListener {
private var apiVideoView: ApiVideoView? = null
private lateinit var apiVideo: ApiVideoLiveStream
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
val apiVideoView = view.findViewById(R.id.apiVideoView)
val audioConfig = AudioConfig(
bitrate = 128 * 1000, // 128 kbps
sampleRate = 44100, // 44.1 kHz
stereo = true,
echoCanceler = true,
noiseSuppressor = true
)
val videoConfig = VideoConfig(
bitrate = 2 * 1000 * 1000, // 2 Mbps
resolution = Resolution.RESOLUTION_720,
fps = 30
)
apiVideo =
ApiVideoLiveStream(
context = getContext(),
connectionListener = this,
initialAudioConfig = audioConfig,
initialVideoConfig = videoConfig,
apiVideoView = apiVideoView
)
}
}
- Start your stream with
startStreaming
method
For detailed information on this livestream library API, refers to API documentation.
You can check device supported configurations by using the helper: Helper
We are using external library
Plugin | README |
---|---|
StreamPack | README.md |
A demo application demonstrates how to use this livestream library. See /example
folder.
If you have any questions, ask us here: https://community.api.video . Or use Issues.