@david-apple @JoeKun As a follow-up to this conversation, I was curious when about fetching nextBatch as a user scrolls down a list. Let's say, for example, the user tapped on the top songs link on Coldplay's artist page in the Apple Music app, that would load a MusicItemCollection with many next batches. Now let's say they tapped on a song to play in that collection. It is my understanding that the you would need to pass the MusicItemCollection to the ApplicationMusicPlayer along with the song to play. However, if the next batches have not been fetched, then not all songs will be passed to the ApplicationMusicPlayer. My first instinct would be to append next batches to the tail of the ApplicationMusicPlayer queue as more batches are fetched.
However, the question that comes up for me in this instance is how would I be able to tell the difference between a user tapping the same song in an album versus a collection of top songs? This is fairly important because I shouldn't be adding top songs to the tail of the ApplicationMusicPlayer queue if they are playing Coldplay's Yellow from the album Parachutes versus Yellow in the top songs category (when I would want to append songs to the tail as more next batches are fetched). If there isn't an easy way to tell when to append top songs in a next batch to the ApplicationMusicPlayer queue (beyond comparing all songs in the queue against all songs in the top songs collection to verify they are the same), then I would assume if user taps to play a song in a collection, it would be wise to go ahead and fetch the entire collection if the user plays a song from that collection and append it to the queue at that point.
Let me know if I'm missing something obvious here or if my question is unclear! Thank you for any help/pointers.
Post
Replies
Boosts
Views
Activity
Yes, this seems like it should be a part of the API as Apple Music uses it extensively (on the search screen there are genres/categories, you can browse by generic the More To Explore section of the Browse tab).
I tried to get playlists for the Blues genre, for example:
var genrePlaylistRequest = MusicCatalogChartsRequest(genre: genre, types: [Playlist.self])
let genrePlaylistReponse = try await genrePlaylistRequest.response()
and here was the response:
MusicDataRequest.Error(
status: 404,
code: 40400,
title: "Resource Not Found",
detailText: "No chart(s) found for type(s) 'playlists', contexts '', genre '2'",
id: "5BXPJ5652TVENA3NBWAR2XCD24",
originalResponse: MusicDataResponse(
data: 184 bytes,
urlResponse: <NSHTTPURLResponse: 0x0000000282804120>
)
)
As an added thought, this probably is intended behavior because playlists are not technically "charted" in the same way albums and songs are. However, I still think there should be a way to get playlists for a specific genre in the same way the Apple Music app can via MusicKit (maybe there is but I'm not exactly sure how).