demonstration of THEOPlayer Android SDK features
This Android project is an example how to integrate THEOplayer into an Android app. There is a step-by-step guide for this project, we suggest you to follow it for better insights.
These instructions will get you a copy of the project up and running on your local machine for development and testing purposes.
- Download and install Android Studio.
- Obtain a THEOplayer Android SDK license. If you don't have a license yet, contact your sales contact or email us at support@theoplayer.com.
Once you obtained the license, you need copy it into the app/libs
folder of the project.
First of all you have to add the following code snippet above the dependencies{} inside app/build.gradle
:
repositories {
flatDir {
dirs 'libs'
}
}
Then in the module-level build.gradle
file (app/build.gradle
) use the proper name of your SDK file
dependencies {
implementation(name: 'FILENAME_OF_YOUR_SDK_FILE', ext: 'aar')
def applicationDependencies = deps.mainApplication
def unitTestDependencies = deps.unitTesting
def acceptanceTestDependencies = deps.acceptanceTesting
implementation applicationDependencies.kotlin
implementation applicationDependencies.kotlinCoroutines
implementation applicationDependencies.kotlinCoroutinesAndroid
implementation applicationDependencies.appCompat
implementation applicationDependencies.constraintLayout
implementation applicationDependencies.timber
implementation applicationDependencies.material
implementation applicationDependencies.gson
testImplementation unitTestDependencies.junit
androidTestImplementation acceptanceTestDependencies.testRunner
androidTestImplementation acceptanceTestDependencies.espressoCore
}
For example if the SDK file is called theoplayer.aar
, then your build.gradle
file should look like this :
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation(name:'theoplayer', ext:'aar')
def applicationDependencies = deps.mainApplication
def unitTestDependencies = deps.unitTesting
def acceptanceTestDependencies = deps.acceptanceTesting
implementation applicationDependencies.kotlin
implementation applicationDependencies.kotlinCoroutines
implementation applicationDependencies.kotlinCoroutinesAndroid
implementation applicationDependencies.appCompat
implementation applicationDependencies.constraintLayout
implementation applicationDependencies.timber
implementation applicationDependencies.material
implementation applicationDependencies.gson
testImplementation unitTestDependencies.junit
androidTestImplementation acceptanceTestDependencies.testRunner
androidTestImplementation acceptanceTestDependencies.espressoCore
}
Besides of adding the player @aar dependency to your build.gradle file, You also need to add Gson dependency as well, otherwise app will crash. You can add the Gson dependency using the line below:
implementation 'com.google.code.gson:gson:2.8.5'
Samples to play are residing at media_list.json inside Assets folder. In order to add a new url to be played you have to add a new row under the proper category name inside sample[] array. each record must have a name and a uri field otherwise app might crash.
Note: 🚨🚨🚨 If your sample url in uri field does not end with .m3u8 or .mpd app might not be able to guess SourceType needed by THEOPlayer, If this is the case you should help the app by adding stream_type field which should be filled with m3u8 or mpd or mp4.
Just open the project, let Android Studio to install the dependencies and build the project.
In a terminal navigate to the project folder and run:
./gradle assembleDebug
The generated APK file (what you need to install on your device) will be available in the app/build/outputs/apk/
folder.
This project is licensed under the BSD 3 Clause License - see the LICENSE file for details