api.video Android Player

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

Easily integrate a video player for videos from api.video in your Android application.

Getting started



In your module build.gradle, add the following code in dependencies:

dependencies {
    implementation 'video.api:android-player:1.3.1'


In your AndroidManifest.xml, add the following code in <manifest>:

<uses-permission android:name="android.permission.INTERNET" />

Retrieve your video Id

At this point, you must have uploaded a least one video to your account. If you haven't see how to upload a video. You'll need a video Id to use this component and play a video from api.video. To get yours, follow these steps:

  1. Log into your account or create one here.
  2. Copy your API key (sandbox or production if you are subscribed to one of our plan).
  3. Go to the official api.video documentation.
  4. Log into your account in the top right corner. If it's already done, be sure it's the account you want to use.
  5. Go to API Reference -> Videos -> List all videos
  6. On the right, be sure the "Authentication" section contains the API key you want to use.
  7. Generate your upload token by clicking the "Try It!" button in the right section
  8. Copy the "videoId" value of one of elements of the response in the right section.

Alternatively, you can find your video Id in the video details of your dashboard.

Code sample

  1. Add a ApiVideoExoPlayerView to your Activity/Fragment layout:

    app:show_subtitles="true" />

You can also use an ExoPlayer StyledPlayerView or a SurfaceView according to your customisation level.

  1. Implements the ApiVideoPlayerController.Listener interface:
val playerControllerListener = object : ApiVideoPlayerController.Listener {
    override fun onError(error: Exception) {
        Log.e(TAG, "An error happened", error)
    override fun onReady() {
        Log.I(TAG, "Player is ready")
  1. Instantiate the ApiVideoPlayerController in an your Activity/Fragment:
val playerView = findViewById<ApiVideoExoPlayerView>(R.id.playerView)

val player = ApiVideoPlayerController(
    VideoOptions("YOUR_VIDEO_ID", VideoType.VOD), // For private video: VideoOptions("YOUR_VIDEO_ID", VideoType.VOD, "YOUR_PRIVATE_VIDEO_TOKEN")
  1. Fullscreen video

If you requires a fullscreen video. You will have to implement the ApiVideoPlayerController.ViewListener interface. Check out for the implementation in the Sample application.

Sample application

A demo application demonstrates how to use player. See /example folder.

On the first run, you will have to set your video Id:

  1. Click on the FloatingActionButton -> Settings
  2. Replace "YOUR_VIDEO_ID" by your video Id



We are using external library

Exoplayer README.md


If you have any questions, ask us here: https://community.api.video. Or use [Issues].

Was this page helpful?