Getting started
Table of contents
This section gives an introduction to the core features of the Flowplayer Android SDK and lists all the requirements for adding the SDK in an Android Project. This guide assumes that you have basic understanding of Android development and that you are familiar with Android Studio and Gradle.
Introduction
The Flowplayer Android SDK is a native media player, written entirely in Kotlin and provides an easy-to-use API which enables developers to create beautiful Android applications that play audio and video both locally and over the Internet. The Flowplayer Android SDK uses ExoPlayer in its core and therefore takes advantage of all its powerful and well-tested features. The SDK supports adaptive streaming technologies such as DASH, HLS, and SmoothStreaming, as well as the most popular single container formats, such as MP4, MP3, WebM, and several more.
Our demo application is available open source on Github and it will help you to better understand how to include the Flowplayer Android SDK in your Android project.
Supported features
Some of the most important features of the Flowplayer Android SDK include but are not limited to:
- DASH, HLS, SmoothStreaming, MP4, WebM, MP3 formats.
- Chromecast.
- Fullscreen playback and configurable device orientation management.
- Callbacks for monitoring a wide range of player events.
- Interactive Media Ads (IMA).
- VAST and VMAP advertisement.
- DRM-protected media playback.
- Customizable user interface.
Prerequisites
In order to be able to compile and run your application using the Flowplayer Android SDK, the following few requirements need to be met.
Minimum Android SDK
The minimum required Android SDK version is 19. Set the minSdkVersion
in your app level module as follows:
android {
defaultConfig {
minSdkVersion 19
}
}
AndroidX
If your project does not use any older version of the Support Library,
then simply enable AndroidX by setting the following attributes inside your gradle.properties
file.
android.useAndroidX=true
android.enableJetifier=true
If, however, your project already uses an older version of the Support Library, then you will have to migrate to AndroidX. This can be easily achieved using Android Studio and by simply following these AndroidX migration instructions.
Java 8
The Flowplayer Android SDK is written using Java 8 features.
In order to make your project compatible with Java 8, you need to configure the targetCompatibility
in your app level build.gradle
file as follows:
android {
compileOptions {
targetCompatibility JavaVersion.VERSION_1_8
}
}
Add the SDK to your project
Once you have met all the prerequisites, you are ready to add the Flowplayer Android SDK to your project and start developing.
Download dependencies
First, add the mavenCentral
in your project level build.gradle
as
follows:
allprojects {
repositories {
mavenCentral()
}
}
Finally, add the SDK as a dependency in your app level build.gradle
and replace "x.x.x" with the latest version as noted below:
dependencies {
implementation 'com.flowplayer.android.player:flowplayer-core:x.x.x'
}
Update AndroidManifest
In your application's AndroidManifest.xml
there are two things that need to be configured:
- Add a
<meta-data>
tag with your Flowplayer access token in order to enable the player to play content. - In every
<activity>
that will contain the player, addandroid:configChanges="keyboard|keyboardHidden|orientation|screenSize"
in order to prevent the Activity from being destroyed on orientation changes.
A correctly configured manifest will look similar to this:
<application>
<activity
android:name="com.my.package.MyAwesomePlayerActivity"
android:configChanges="keyboard|keyboardHidden|orientation|screenSize" />
<meta-data
android:name="com.flowplayer.accessToken"
android:value="MY_FLOWPLAYER_ACCESS_TOKEN" />
</application>