Getting started (Android SDK)
Overview
Repository
The Android SDK is available on Nexus.
Key Features
- Developed in
Kotlin 1.9.0(compatible with version1.8.20and above) - Remote player management
- Verified Google IMA integration
- OMSDK support
- TCF2 support
- Access to Player events and state facilitated
- Fullscreen playback management
- Chromecast support
Supported versions & requirements
minSdk set to 21 (Lollipop) |
Dependencies
The following dependencies are required:
Player dependencies |
|
Advertising dependencies |
|
NoteDM advertising SDK includes IMA Native. This will require additional dependencies to work. Those additional dependencies can be found in Android IMA SDK integration guide.
Installation
1. Create an Android Player configuration
As a first step you need to create a custom player configuration for your Android application in your Dailymotion account. A unique Player Id will be generated which will be required for player initialization in-app, accurate monetization, targeting and attribution.
The custom player configuration can be created and managed either through the “Players” tab in the Dailymotion Studio or programmatically via the Platform API.
Note“Picture-in-Picture”, “First time viewable”, “Aspect ratio” and “Use embedder link when sharing” features are not available on the iOS SDK and are reserved for JavaScript embeds.
CMP implementation required to ensure monetizationPublishers in GDPR countries are required to implement a TCF2 registered CMP (Consent Management Platform) in their native app to ensure monetization. A compliant CMP must be used to use IAB TCF2 for the creation and storage of the transparency & consent string. As Dailymotion fully supports the IAB TCF2 standard, our native SDKs and our Player can access this string received from the CMP in-app.
It’s important that the consent string is available before the Player is loading. For information on how to use a CMP in-app see here.
2 - Add the SDK to your project
Step 1 - Add the Dailymotion Maven repository
The Android SDK is available on Nexus
.Gradle (your app’s build system) needs to know where to download the Dailymotion Android SDK from, so we need to add this address to your app configuration:
- Open your settings.gradle file.
- Inside the
dependencyResolutionManagementblock, add our Maven repository like this:
dependencyResolutionManagement {
...
repositories {
...
maven {
name = "DailymotionMavenRelease"
url = "https://mvn.dailymotion.com/repository/releases/"
}
...
}
...
}Step 2 - Add the SDK dependencies
Once your app knows where to find the SDK, it needs to actually install it, along with a few companion tools.
These are the actual building blocks your app needs to display videos, handle ads (if you want), and make everything run smoothly.
In your app’s build.gradle file, add:
dependencies {
implementation 'com.dailymotion.player.android:sdk:1.2.7' // Main video player
implementation 'androidx.fragment:fragment:1.5.7' // Needed to show video in part of the screen
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.4' // Smooth background loading
// Optional: for video ads
implementation 'com.dailymotion.player.android:ads:1.2.7'
implementation 'com.google.ads.interactivemedia.v3:interactivemedia:3.33.0'
}
Note:If you’re already using
androidx.appcompat:appcompat, you can skip addingandroidx.fragment:fragment. It’s included by default.
3 - Create and add PlayerView to view hierarchy
Now that your app has everything installed, it’s time to actually create the video player and show it on screen.
Create a PlayerView using Dailymotion.createPlayer(...) method:
Dailymotion.createPlayer(
context = context,
playerId = "MY_PLAYER_ID", // replace by desired player id
videoId = "A_VIDEO_ID", // replace by desired video id
playerSetupListener = object : Dailymotion.PlayerSetupListener {
override fun onPlayerSetupSuccess(player: PlayerView) {
// Add the PlayerView to your screen here (e.g., inside a layout)
}
override fun onPlayerSetupFailed(error: PlayerError) {
// Handle error (e.g., network issue or bad video ID)
}
}
)Updated 18 days ago
