What is the best approach to retrieve playlists using MusicKit. I can't seem to guess from the docs how to use the API to accomplish this, as well as retrieving tracks from a playlist.
I am in the process of migrating code from Apple Music API to MusicKit and I potentially could use MusicDataRequest to retrieve playlists using the Apple Music API endpoints, but I want to be sure there are no better alternatives.
Sample code would definitely help.
Post
Replies
Boosts
Views
Activity
Hi there,
Has something changed with AVAudioPlayer with new Swift/SwiftUI version or when building for iOS 15?
This piece of code below used to work without issues when building the app for iOS 14. I use AVAudioPlayer to listen to a preview track from iTunes, e.g. https://audio-ssl.itunes.apple.com/itunes-assets/AudioPreview115/v4/7c/33/61/7c33611a-0fc8-546b-d737-287e75867ddb/mzaf_7738318112069179681.plus.aac.p.m4a.
However, I am not hearing any sound on a test device on which I reinstalled the app built with iOS 15 (rather than iOS 14). I did use the exact same code and I am referring to the same URL...
Both devices are running iOS 15.3.
In short: with production app (built with deployment target iOS 14.x) I can hear sound; test app (built with deployment target iOS 15.3) I cannot hear sound...
Code is like
class PreviewTrack {
static var audioPlayer: AVAudioPlayer!
static func playTheOldWay(sound: String, status: Bool) {
let previewURL = URL(string: sound)
print("Preview Track URL: \(sound)")
let task = URLSession.shared.dataTask(with: previewURL!) { data, _, error in
guard let _ = data,
error == nil else {
Logger.viewCycle.info("PreviewTrack - \(error?.localizedDescription ?? "Response Error")")
return }
if let data = data {
self.audioPlayer = try? AVAudioPlayer(data: data)
if status {
Logger.viewCycle.info("PreviewTrack - Playing Track...")
self.audioPlayer.play()
}
else {
Logger.viewCycle.info("PreviewTrack - Stoppimng Track...")
self.audioPlayer.stop()
}
}
}
task.resume()
}
}
I am retrieving successfully chart information using MusicCatalogChartsRequest() but I can see the results returned are always based on the country (store) I am connected to as a user (i.e. the Netherlands). Is it possible using the MusicKit API to retrieve chart details from other countries (i.e. USA)?
Is it possible using MusicKit API's to access the About information displayed on an artist page in Apple Music?
I hoped Artist.editiorialNotes would give me the information but there is scarce information in there. Even for Taylor Swift, only editorialNotes.short displays brief info: "The genre-defying singer-songwriter is the voice of a generation."
If currently not possible, are there plans for it in the future?
Also, with the above in mind, and never seen any editorialNotes for a song, is it safe to assume editorialNotes are mainly used for albums?
I am trying to retrieve same information about a song as is available on the music.apple.com page (see screenshot).
It seems neither MusicKit and/or Apple Music API's deliver that depth of information. For example, the names listed for Production and Techniques.
Am I correct?
I can't seem to find an album using MusicKit containing RecordLabel. I am using album.with([..., .recordLabels, ...] but I only see an empty recordLabels collection returned for every album I am trying...
Is this actually available / populated through MusicKit?