how do you play an uploaded song in Apple Music for the Android SDK?

50 Views Asked by At

Normally in Apple Music for Android, if you want to play a song you can do, first you add it to the queue like this:MediaSessionCompat.QueueItem(mediaItem.description, mediaItem.mediaId!!.toLong()) and play it like this:

override fun play() {
    if (!prepared) {
        prepare()
        val queueProviderBuilder = CatalogPlaybackQueueItemProvider.Builder()
        val tracksIds = currentTracksInQueue.map { it.description.mediaId }
        queueProviderBuilder.items(MediaItemType.SONG, *tracksIds.toTypedArray())
        queueProviderBuilder.startItemIndex(queueIndex)
        playerController.prepare(queueProviderBuilder.build(), true)
        Log.i(TAG, "playing: ${tracksIds.toTypedArray().contentToString()}")
        prepared = true
    } else {
        playerController.play()
    }
}

, where the media Id of the song is a Long. But uploaded songs id can go like this:"i.123abc456de". In MusicKit you can play and uploaded song like this:```let music = MusicKit.getInstance();

music.api.library.song('i.NJv0Aogfl9QoJ3g', { include: 'albums' }).then(function(results) {
  console.log(results);
}).catch(function(error) {
  window.alert(error);
});

is there something I may be missing to play an uploaded song in Android? Thanks for any insight.

0

There are 0 best solutions below