Android SDK Migration guide
This guide is intended to help you migrate from the legacy native SDK to our new Android SDK.
Overview
New repository | – New Android SDK available on Nexus |
Sample applications | – Android 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 version | 21 (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.
TCF2 consent management
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 methods | New Android methods |
---|---|
initialize() | dailymotion.createPlayer( |
load() | loadContent(videoId: String?, playlistId: String?, startTime: 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
Description | Legacy events | New events |
---|---|---|
Sent when the Player is ready to accept API commands. Do not try to call functions before receiving this event. | ApiReadyEvent | onPlayerSetupSuccess |
Sent the first time the Player attempts to start the playback. | StartEvent | onPlayerStart |
Sent when a new video has been loaded in the Player. | VideoChangeEvent | onPlayerVideoChange |
Sent when the Player starts to play an ad media resource. | AdStartEvent | onAdstart |
Sent when the playback position of an ad changes. | AdTimeUpdateEvent | onAdTimeChange |
Sent when the Player starts the playback of an ad. | AdPlayEvent | onAdPlay |
Sent when the Player pauses an ad resource. | AdPauseEvent | onAdPause |
Sent when the Player reaches the end of an ad media resource. | AdEndEvent | onAdPause |
Sent when the Player starts to play the media resource. | VideoStartEvent | onVideoStart |
Sent when the playback position changes. | TimeUpdateEvent | onVideoTimeChange |
Sent when the Player is starting to seek to another position in the video. | SeekingEvent | onVideoSeekStart |
Sent when the Player has completed a seeking operation. | SeekedEvent | onVideoSeekStart |
Sent when the browser is fetching the media data. | ProgressEvent | onVideoProgress |
Sent when the duration property of the video becomes available or changes after a new video load. | DurationChangeEvent | onVideoDurationChange |
Sent when the content media resource playback has started. | PlayingEvent | onVideoPlaying |
Sent when the content media resource playback has paused. | PauseEvent | onVideoPause |
Sent when the Player reaches the end of the content media resource. | VideoEndEvent | onVideoEnd |
Sent when playback starts after the play method returns. | PlaybackReadyEvent | onVideoPlay |
Sent when qualities are available. | QualitiesAvailableEvent | onVideoQualitiesReady |
Sent when the video quality changes. | QualityChangeEvent | onVideoQualityChange |
Sent when the volume or mute state changes. | VolumeChangeEvent | onPlayerVolumeChange |
Sent when the fullscreen mode is requested. | FullScreenToggleRequestedEvent | onFullscreenRequested |
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.