Migration from Android Player SDK to Android Native Player SDK
Overview
This guide will help you migrate from the Dailymotion Android Player SDK (WebView-based) to the Dailymotion Android Native Player SDK (Media3 ExoPlayer-based).
Why migrate ?
The Native Player SDK offers significant improvements:
- Better Performance: Native Media3 ExoPlayer instead of WebView
- Native UI: Direct Android UI components instead of HTML5 player
- Direct Control: Full control over player lifecycle and events
- Enhanced Features: Better fullscreen, PiP, and Cast support
Breaking Changes Summary
| Aspect | Android Player SDK | Native Player SDK |
|---|---|---|
| Underlying Technology | WebView-based (HTML5) | Media3 ExoPlayer (Native) |
| minSdk | 23 | 24 |
| compileSdk | Not specified | 36 |
| SDK Initialization | Not required | Required in Application class |
| Core Library Desugaring | Not required | Required |
| Maven Artifact | com.dailymotion.player.android:sdk | com.dailymotion.nativeplayer.android:sdk |
| Ads Integration | Google IMA SDK | Dailymotion Ad SDK |
| Cast Integration | Dailymotion Cast SDK + Google Cast SDK setup | Google Cast SDK setup + Dailymotion Native Player Cast SDK |
Step-by-Step Migration
1. Update Dependencies
Remove Old Dependencies
Remove from build.gradle.kts:
// Old SDK - REMOVE THESE
implementation("com.dailymotion.player.android:sdk:2.1.1")
implementation("com.dailymotion.player.android:ads:2.1.1") // if using ads
implementation("com.dailymotion.player.android:cast:2.1.1") // if using cast
implementation("com.google.ads.interactivemedia.v3:interactivemedia:3.33.0") // if using adsAdd New Dependencies
Add to build.gradle.kts:
dependencies {
// Main Native Player SDK
implementation("com.dailymotion.nativeplayer.android:sdk:1.0.0-beta-01")
// Required dependencies (NEW)
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-android:1.10.1")
implementation("androidx.media3:media3-exoplayer:1.8.0")
implementation("androidx.media3:media3-exoplayer-hls:1.8.0")
implementation("androidx.media3:media3-ui:1.8.0")
implementation("androidx.recyclerview:recyclerview:1.4.0")
implementation("androidx.constraintlayout:constraintlayout:2.1.4")
implementation("io.coil-kt:coil:2.6.0")
// Required for desugaring
coreLibraryDesugaring("com.android.tools:desugar_jdk_libs:2.1.5")
}Enable Core Library Desugaring (NEW REQUIREMENT)
Add to build.gradle.kts:
android {
compileOptions {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
isCoreLibraryDesugaringEnabled = true // NEW - REQUIRED
}
}2. Update minSdk Version
Update in build.gradle.kts :
android {
defaultConfig {
minSdk = 24 // Changed from 23 to 24
}
}3. Add SDK Intialization (NEW REQUIREMENT)
The Native Player SDK requires initialization in your Application class.
Create or update you Application class:
import android.app.Application
import com.dailymotion.nativeplayer.android.sdk.Dailymotion
class MyApplication : Application() {
override fun onCreate() {
super.onCreate()
Dailymotion.initializeSdkManager(this) // NEW - REQUIRED
}
}Declare in AndroidManifest.xml:
<application
android:name=".MyApplication"
...>
</application>Important:
The player will not work without this initialization step
4. Update PlayerView Creation
The Dailymotion.createPlayer() method signature has changed with new required parameters.
New SDK Signature
Dailymotion.createPlayer(
context = requireContext(),
playerId = "MY_PLAYER_ID",
videoId = "A_VIDEO_ID",
playlistId = null, // NEW - Optional playlist support
playerSetupListener = object : Dailymotion.PlayerSetupListener<PlayerView> {
override fun onPlayerSetupSuccess(player: PlayerView) {
// Add PlayerView to your layout
val layoutParams = FrameLayout.LayoutParams(
FrameLayout.LayoutParams.MATCH_PARENT,
FrameLayout.LayoutParams.MATCH_PARENT
)
playerContainer.addView(player, layoutParams)
}
override fun onPlayerSetupFailed(error: PlayerError) {
Log.e(TAG, "Player setup failed: ${error.message}")
}
},
// NEW - Required PlayerListener for fullscreen events
playerListener = object : PlayerListener {
override fun onFullscreenRequested(isFullScreen: Boolean): Boolean {
return false // Return false to let SDK handle fullscreen
}
},
// NEW - Optional AdListener (if using ads)
adListener = object : AdListener {
override fun onAdReadyToFetch(playerView: PlayerView) {
// Ad is ready to be fetched
}
override fun onAdSkipped(playerView: PlayerView) {
// Ad was skipped
}
}
)
Key Changes:
Same class naming but different import. Be sure to import corresponding classes from native player sdk:
-
import com.dailymotion.nativeplayer.android.sdk.Dailymotion -
import com.dailymotion.nativeplayer.android.sdk.PlayerError -
import com.dailymotion.nativeplayer.android.sdk.models.PlayerListener -
import com.dailymotion.nativeplayer.android.sdk.models.AdListener -
import com.dailymotion.nativeplayer.android.sdk.views.mobile.PlayerView
5. Update Ad Integration (If Using Ads)
The Native Player SDK uses the Dailymotion Ad SDK instead of Google IMA.
Remove Google IMA Dependencies
// REMOVE THESE
implementation("com.dailymotion.player.android:ads:2.1.1")
implementation("com.google.ads.interactivemedia.v3:interactivemedia:3.33.0")
Add Dailymotion Ad SDK Dependencies
// REMOVE THESE
implementation("com.dailymotion.player.android:ads:2.1.1")
implementation("com.google.ads.interactivemedia.v3:interactivemedia:3.33.0")
Add AD_ID Permission
Add to AndroidManifest.xml:
<uses-permission android:name="com.google.android.gms.permission.AD_ID"/>Implement AdListener
adListener = object : AdListener {
override fun onAdReadyToFetch(playerView: PlayerView) {
Log.d(TAG, "Ad is ready to be fetched")
}
override fun onAdSkipped(playerView: PlayerView) {
Log.d(TAG, "Ad was skipped")
}
}
6. Update Cast Integration (If using Chromecast)
Cast integration now requires explicit Google Cast SDK setup
Prerequisites
Follow the Google Cast Android Sender Setup Guide first.
Add Cast Dependencies
dependencies {
implementation("com.dailymotion.nativeplayer.android:cast:1.0.0-beta-01")
implementation("com.google.android.gms:play-services-cast-framework:22.2.0")
implementation("androidx.media3:media3-cast:1.8.0")
implementation("androidx.media3:media3-session:1.8.0")
implementation("androidx.mediarouter:mediarouter:1.7.0")
}Update CastOptionsProvider
import com.dailymotion.nativeplayer.android.sdk.cast.DailymotionCast
import com.google.android.gms.cast.framework.CastOptions
import com.google.android.gms.cast.framework.OptionsProvider
import com.google.android.gms.cast.framework.SessionProvider
class CastOptionsProvider : OptionsProvider {
override fun getCastOptions(context: Context): CastOptions {
// Use DailymotionCast.castOptionsBuilder() instead of CastOptions.Builder()
return DailymotionCast.castOptionsBuilder(context).build()
}
override fun getAdditionalSessionProviders(context: Context): List<SessionProvider>? {
return null
}
}Key Changes:
Same class naming but different import. Be sure to import corresponding classes from native player sdk:
import com.dailymotion.nativeplayer.android.sdk.cast.DailymotionCast
Note:
The Dailymotion Native Player Cast SDK automatically provides the ReceiverApplicationId.
Migration Checklist
Use this checklist to ensure a complete migration:
- Update build.gradle.kts with new dependencies
- Remove old SDK dependencies (sdk, ads, cast modules)
- Enable Core Library Desugaring
- Update minSdk to 24
- Create/update Application class with SDK initialization
- Declare Application class in AndroidManifest.xml
- Update Dailymotion.createPlayer() calls with new parameters
- Update imports for PlayerView, PlayerError, PlayerListener, AdListener
- Add PlayerListener for fullscreen handling
- Update Ad integration (if using ads)
- Replace Google IMA with Dailymotion Ad SDK
- Add AD_ID permission
- Implement AdListener
- Update imports for AdListener
- Update Cast integration (if using Chromecast)
- Implement Google Cast SDK
- Add Cast dependencies
- Update CastOptionsProvider
- Update import to use DailymotionCast
- Test player functionality
- Test configuration changes (rotation)
- Test ads (if applicable)
- Test Chromecast (if applicable)
Common Migration Issues
Issue: "Invoke-customs are only supported starting with Android O"
Cause: Core Library Desugaring not enabled
Solution:
android {
compileOptions {
isCoreLibraryDesugaringEnabled = true
}
}
dependencies {
coreLibraryDesugaring("com.android.tools:desugar_jdk_libs:2.1.5")
}Issue: Player fails to initialize
Cause: Missing SDK initialization
Solution: Ensure Dailymotion.initializeSdkManager(this) is called in Application.onCreate()
Issue: Compilation errors with PlayerView or PlayerListener
Cause: Wrong imports from old SDK
Solution: Update imports to use classes from com.dailymotion.nativeplayer.android.sdk package
Issue: Ads not showing
Cause: Missing Ad SDK dependencies
Solution:
- Add Dailymotion Ad SDK dependencies
- Add AD_ID permission to AndroidManifest.xml
- Implement TCF2 CMP for GDPR compliance
Issue: Cast button not appearing
**Cause:**Missing Cast dependencies or configuration
Solution:
- Ensure Google Cast SDK is properly set up
- Add all Cast dependencies
- Use
DailymotionCast.castOptionsBuilder()in CastOptionsProvider - Update import to
com.dailymotion.nativeplayer.android.sdk.cast.DailymotionCast
Updated 3 days ago
