The TIDAL Player client for iOS.
The Player module encapsulates the playback functionality of TIDAL media products. The implementation uses Apple's AVPlayer
as the media player. Check AVPlayer.
- Streaming and playing TIDAL catalog content.
- Core playback functionality.
- Media streaming, caching and error handling.
- Automatic management of playback session event reporting.
- 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.
Add the dependency to your existing Package.swift
file.
dependencies: [
.package(url: "https://tidal-music.github.io/tidal-sdk-ios", from: "<VERSION>"))
]
- Select
"File » Add Packages Dependencies..."
and enter the repository URLhttps://github.com/tidal-music/tidal-sdk-ios
into the search bar (top right). - Set the Dependency Rule to
"Up to next major"
, and the version number to that you want. - When
"Choose Package Products for tidal-sdk-ios"
appears, make sure to add Player, Auth and EventProducer at least to your target.
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.
let player = Player.bootstrap(
listener: self,
credentialsProvider: TidalAuth.shared,
eventSender: TidalEventSender.shared
)
- Load and play a
MediaProduct
track.
player.load(
MediaProduct(
productType: ProductType.TRACK,
productId: "PRODUCT_ID"
)
)
player.play()
- The listener passed in the bootstrap process will receive the player events callbacks for the
PlayerListener
delegate.
let player = Player.bootstrap(
..
listener: self,
..
)
extension ViewModel: PlayerListener {
func stateChanged(to state: State) {
print("New player state: \(state)")
}
}
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 PlayerViewModel
class:
private let CLIENT_ID = "YOUR_CLIENT_ID"
private let CLIENT_SECRET = "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.