MusicController
A controller that simplifies interaction with the
MusicKit
framework.
To access Apple Music data, make sure to include
NSAppleMusicUsageDescription
key-values in the applications
Info.plist. Not doing so will crash the app at runtime.
Usage
Request access to the users Apple Music library:
Task {
let authorized = await MusicController.requestAuthorization()
if authorized {
// authorized: play tracks from Apple Music.
} else {
// denied/restricted: show error UI
}
}