player
The TIDAL Player client for Android.
The Player module encapsulates the playback functionality of TIDAL media products. The implementation depends on a fork of AndroidX Media repository and uses ExoPlayer
as the media player. Check tidal-androidx-media.
Features
Streaming and playing TIDAL catalog content.
Core playback functionality.
Media streaming, caching and error handling.
Automatic management of playback session event reporting.
Documentation
Read the documentation for a detailed overview of the player functionality.
Check the API documentation for the module classes and methods.
Visit our TIDAL Developer Platform for more information and getting started.
Usage
Installation
We are using the TrueTime library internally, so you need to add the following to your repositories list:
maven {
url = uri("https://jitpack.io")
}
Add the dependency to your
build.gradle.kts
file.
dependencies {
implementation("com.tidal.sdk:player:<VERSION>")
}
Playing a TIDAL track
The Player depends on the Auth and EventProducer modules for authentication and event reporting handling. For detailed instructions on how to set them up, please refer to their guide.
Here's how to setup the Player and play a TIDAL track:
Initialise the Player which depends on a
CredentialsProvider
from the Auth module and anEventSender
from the EventProducer module.
val player = Player(
application = application,
credentialsProvider = auth.credentialsProvider,
eventSender = eventSender
)
Load and play a
MediaProduct
track.
val mediaProduct = MediaProduct(ProductType.TRACK, "PRODUCT_ID")
player.playbackEngine.load(mediaProduct)
player.playbackEngine.play()
(Optional) Listen to player events.
player.playbackEngine.events.onEach {
Log.d(TAG, "Event=$it")
}.launchIn(coroutineScope)
Running the test app
The player module includes a test app that demonstrates how to setup the player and showcases its different functionalities.
As a prerequisite for the player to work, the client is required to be authenticated. You can learn more about the authentication flows in the Auth module. Note that currently only the ``Client Credentials``
flow is publicly supported. This enables the test app to play 30-second tracks previews. Full length playback is only enabled when the client is authenticated through ``Device Login``
or ``Authorization Code Flow``
.
In order to run the test app, please declare your client credentials in the top-level ``local.properties``
file:
tidal.clientid="YOUR_CLIENT_ID"
tidal.clientsecret="YOUR_CLIENT_SECRET"
Note: you can obtain the ``client id``
and ``client secret``
after signing up and creating an application in the TIDAL Developer Platform.