Table of content

Android SDK Migration guide


This guide is intended to help you migrate from the legacy native SDK to our new Android SDK.

Sunset notice legacy SDK:

 

From February 3rd 2025, the legacy Android SDK will be officially sunset and will no longer be supported.

To avoid any disruption, it is required for all Partners still using the legacy SDK to migrate to the new Android SDK as soon as possible following guidelines below.

If you have questions or need assistance, please reach out to our Support team.

Overview

New repositoryNew Android SDK available on Nexus
Sample applicationsAndroid sample app: Download the sample app on your device and explore the SDK functionalities in a user-friendly UI
Source code: Access the sample app source code, customize it as you wish and easily integrate the SDK into your projects
Key features– Developed in Kotlin 1.9.0 (compatible with version 1.8.20 and above)
– Remote Player management
– Verified Google IMA integration
– OMSDK support
– TCF2 support
– Fullscreen playback management
– Access to Player events and state facilitated
– Chromecast support
Minimum supported version21 (Lollipop)

Implementation resources


Benefits

Key benefits of the new Android SDK:

  • More customization: The new Android SDK offers more customization options and greater flexibility in managing Player configurations via the Studio. Embedding and controlling your Players is easier and more efficient thanks to Player IDs.
  • Better monetization: The new SDK complies with Google IMA standards and TCF2 to help you handle monetization more effectively
  • Improved developer experience: The new SDK provides an easier way to embed and control custom Players, and simplified access to various data

Integration principles

Find the key technical steps required to implement our new Android SDK the best way and benefit from improved functionalities and flexibility compared to the legacy one.

Player customization

While the legacy SDK could only offer limited customization options and control, the new SDK is built around Player IDs. They carry your Player configuration, providing more flexibility and control over the Player’s behavior and appearance without requiring heavy customization within your code:

  • Manage from Studio: You can easily create and manage custom Player configurations from the Dailymotion Studio
  • Embed Player IDs: Each Player configuration is linked to a unique Player ID which is required for Player initialization in your Android app, and accurate monetization, targeting and attribution
  • Optimize with API: Additional customization can be added programmatically using the Player methods, events and state

Learn more about how to create and manage Players from the Studio.

Advertising dependencies

The IMA SDK is already integrated into the new SDK, however, it requires declaring additional dependencies to load the IMA libraries.

Those additional dependencies can be found in Android IMA SDK integration guide.

Fullscreen management

The new Android SDK provides an out-of-the-box fullscreen implementation as well as a custom fullscreen implementation supporting navigation stack using either Android standard FragmentManager or Android Jetpack Navigation library.

See how to implement fullscreen with the new SDK.

Destroy/release Player

The Player instance can be automatically destroyed by the Android system’s garbage collector or manually destroyed using the destroy() method.

See how to destroy the Player.

The Android SDK complies with IAB TCF2 standards to manage user consent using a recognized CMP. The Player will automatically attempt to access consent strings stored in the CMP.

See how to implement TCF2.


Mapping

This section provides a mapping of the methods, events and state from the legacy SDK to the new Android SDK to help you update your integration.

Methods

Legacy Android methodsNew Android methods
initialize()dailymotion.createPlayer(
context: Context,
playerId: String,
videoId: String?,
playlistId: String?,
playerParameters: PlayerParameters,
playerListener: PlayerListener?,
videoListener: VideoListener?,
adListener: AdListener?,
playerSetupListener: PlayerSet)
load()load​Content(video​Id: String?, playlist​Id:​ String?, start​Time:​ Long?)
play()play()
pause()pause()
setFullScreenButton(Boolean)setFullScreen(fullscreen: Boolean, orientation: Orientation)
Learn more
setCustomConfig()setCustomConfig(customConfig:)
Learn more
unmute()setMute()
mute()setMute()
callPlayermethod(String, Object)No longer supported. All public methods can be found here.
setPlayWhenReady(Boolean)Control of playback functionality managed in Player configuration (Autostart)
setQuality(String)setQuality(wantedQuality: String)
setSubtitle(String)setSubtitles(wantedSubtitle: String)
setVolume(float)No longer supported on native. Volume managed by device controls.
release()destroy()
setIsWebContentDebuggingEnabled()Error tracking available with setLogLevel(LogLevel.String)
setMinimizeProgress(float)No longer supported with latest Player UI design
setWebViewErrorListener(WebViewErrorListener)Use PlayerSetupListener.onPlayerSetupFailed() and PlayerListener.onPlayerError()
showControls()No longer supported. Ad and playback controls are now managed in Player configuration.
toggleControls()No longer supported. Ad and playback controls are now managed in Player configuration.
togglePlay()Use play() or pause()
getBufferedTime()Property available from Player state:
getState(callback: PlayerStateCallback)
getVideoPaused()Property available from Player state:
getState(callback: PlayerStateCallback)
getVolume()Property available from Player state:
getState(callback: PlayerStateCallback)
isEnded()Property available from Player state:
getState(callback: PlayerStateCallback)
isSeeking()Property available from Player state:
getState(callback: PlayerStateCallback)
getDuration()Property available from Player state:
getState(callback: PlayerStateCallback)
getPosition()Property available from Player state:
getState(callback: PlayerStateCallback)

Find the complete list of methods for the new Android SDK.

Events

DescriptionLegacy eventsNew events
Sent when the Player is ready to accept API commands. Do not try to call functions before receiving this event.ApiReadyEventonPlayerSetupSuccess
Sent the first time the Player attempts to start the playback.StartEventonPlayerStart
Sent when a new video has been loaded in the Player.VideoChangeEventonPlayerVideoChange
Sent when the Player starts to play an ad media resource.AdStartEventonAdstart
Sent when the playback position of an ad changes.AdTimeUpdateEventonAdTimeChange
Sent when the Player starts the playback of an ad.AdPlayEventonAdPlay
Sent when the Player pauses an ad resource.AdPauseEventonAdPause
Sent when the Player reaches the end of an ad media resource.AdEndEventonAdPause
Sent when the Player starts to play the media resource.VideoStartEventonVideoStart
Sent when the playback position changes.TimeUpdateEventonVideoTimeChange
Sent when the Player is starting to seek to another position in the video.SeekingEventonVideoSeekStart
Sent when the Player has completed a seeking operation.SeekedEventonVideoSeekStart
Sent when the browser is fetching the media data.ProgressEventonVideoProgress
Sent when the duration property of the video becomes available or changes after a new video load.DurationChangeEventonVideoDurationChange
Sent when the content media resource playback has started.PlayingEventonVideoPlaying
Sent when the content media resource playback has paused.PauseEventonVideoPause
Sent when the Player reaches the end of the content media resource.VideoEndEventonVideoEnd
Sent when playback starts after the play method returns.PlaybackReadyEventonVideoPlay
Sent when qualities are available.QualitiesAvailableEventonVideoQualitiesReady
Sent when the video quality changes.QualityChangeEventonVideoQualityChange
Sent when the volume or mute state changes.VolumeChangeEventonPlayerVolumeChange
Sent when the fullscreen mode is requested.FullScreenToggleRequestedEventonFullscreenRequested

Find the complete list of events for the new Android SDK.

Player state and properties

Legacy SDK

The legacy SDK provided limited access to Player properties: it required specific events to be triggered to be able to retrieve associated Player properties.

dailyMotionVideoPlayer.setEventListener { event ->
    when (event) {
        is ApiReadyEvent -> ...
        is StartEvent -> ...
        is ProgressEvent -> ...
        is DurationChangeEvent -> ...
        /* And many more event */
        else -> {
            /* In case a POJO is not available you can directly access the raw data */
            if (event.name == "_generic_") {
                /* Do some stuff for my event: parse the raw date to extract the event name or values */
                Log.d("Event with payload: ${event.payload}")
            }
        }
    }
}

New SDK

The new Android SDK provides more data with easier access: any value within the Player state can be retrieved at any time using the method getState(callback: PlayerStateCallback), without having to rely on specific events.

To retrieve the Player state, simply pass an object implementing PlayerView.PlayerStateCallback to PlayerView#queryPlayerState(...)method.

playerView.queryPlayerState(object: PlayerView.PlayerStateCallback {
    fun onPlayerStateReceived(playerView: PlayerView, playerState: PlayerEvent.PlayerState)
        // Use playerState
    }
)

See full list of available state properties.

If you need assistance with the migration:

 

Please reach out to your dedicated Dailymotion Account Manager or our Support team