Post

Replies

Boosts

Views

Activity

ApplicationMusicPlayer automatically turns Shuffle Mode On
Hi all, I am playing songs via ApplicationMusicPlayer with MusicKit for Swift and I am running into an issue where shuffle mode is sometimes automatically turned on. Even though there was no code related to shuffle mode. Here's a snippet //myQueue is an array of Tracks let player = ApplicationMusicPlayer.shared player.queue = ApplicationMusicPlayer.Queue(for: myQueue) // player.state.shuffleMode = .off // I tried explicitly setting shuffle mode off, which has no effect try await player.play() This issue is not easily reproducible, it occurs rarely and at random. But once this issue occurs it persists even after uninstalling and reinstalling the app. When I tried it to reproduce it with another device and everything works properly. Anyone else running into this issue? For Apple Engineers, here is the ticket: FB9816030
2
0
1.5k
Feb ’22
How to detect end of hasNextBatch?
Hello, In MusicKit I would like to know how I can detect the end of hasNextBatch for a MusicItemCollection. Let's say, I have a playlist with 100+ songs in my library. Initially, I get 100 songs from the response and hasNextBatch is true. If I use a while loop, every response includes the hasNextBatch = true. So I do not know when to stop or how many limited loop to make. Is there way I can get the playlist loaded completely with all the songs loaded using nextBatch and stop when I have hit the end?
2
0
1.7k
Mar ’22
App crashes after showing Music Subscription offer sheet
Hi all, I ma displaying the Music Subscription offer sheet in my app. Shortly after the sheet is presented, when the user dismisses the offer, the app crashes with error: Fatal error: CloudServiceSetupView.makeUIViewController() was called with an unexpected presentation state: idle. 2021-11-30 11:56:28.974626-0800 AppName[16276:4525658] _MusicKit_SwiftUI/CloudServiceSetupView.swift:31: Fatal error: CloudServiceSetupView.makeUIViewController() was called with an unexpected presentation state: idle. What am I doing wrong? Related Ticket for Apple Engineers: FB9789040
3
0
1.2k
Dec ’21
Album Artwork is not loading when music is playing
Hi Apple Engineers, In my app Caset, the album artwork is no longer displaying correctly, instead the console is printing with error: [Artwork] [MPArtwork] Failed to create directory at 'file:///var/mobile/Media/iTunes_Control/iTunes/Artwork/Caches/96x96/61/' with error: Error Domain=NSCocoaErrorDomain Code=513 "You don’t have permission to save the file “61” in the folder “96x96”." UserInfo={NSFilePath=/var/mobile/Media/iTunes_Control/iTunes/Artwork/Caches/96x96/61, NSUnderlyingError=0x280552dc0 {Error Domain=NSPOSIXErrorDomain Code=1 "Operation not permitted"}} Here is the code I am using to display the album artwork of the current item: @ObservedObject private var playerQueue = ApplicationMusicPlayer.shared.queue //In the BODY switch playerQueue.currentEntry?.item {     case .song(let song):     if let artwork = song.artwork {         ArtworkImage(artwork, width: 40, height: 40)        } case .musicVideo(let video):        if let artwork = video.artwork {           ArtworkImage(artwork, width: 70, height: 40)         }                case nil:        EmptyView()  } Related bug has been filed here: FB10189431 This unexpected behavior is new and was previously worked as expected in early versions of iOS 15.
3
0
1.3k
Jun ’22
How to decode the JSON response from MusicKit Search Suggestion
Hello everyone, I am trying to understand how to decode the JSON response returned by the suggestions/top results endpoint in MusicKit As you can see the response returns suggestions, which has two different types, Albums and Songs within the same 'suggestions' array. How can I decode the response even if there are different types using a single struct? { "results" : { "suggestions" : [ { "content" : { "attributes" : { "url" : "https:\/\/music.apple.com\/us\/artist\/megan-thee-stallion\/1258989914", "name" : "Megan Thee Stallion", "genreNames" : [ "Hip-Hop\/Rap" ] }, "id" : "1258989914", "relationships" : { "albums" : { "data" : [ { "href" : "\/v1\/catalog\/us\/albums\/1537889223", "type" : "albums", "id" : "1537889223" } ], "next" : "\/v1\/catalog\/us\/artists\/1258989914\/albums?offset=25", "href" : "\/v1\/catalog\/us\/artists\/1258989914\/albums" } }, "href" : "\/v1\/catalog\/us\/artists\/1258989914", "type" : "artists" }, "kind" : "topResults" }, { "content" : { "href" : "\/v1\/catalog\/us\/artists\/991187319", "attributes" : { "genreNames" : [ "Hip-Hop\/Rap" ], "url" : "https:\/\/music.apple.com\/us\/artist\/moneybagg-yo\/991187319", "name" : "Moneybagg Yo" }, "id" : "991187319", "type" : "artists", "relationships" : { "albums" : { "href" : "\/v1\/catalog\/us\/artists\/991187319\/albums", "data" : [ { "id" : "1550876571", "href" : "\/v1\/catalog\/us\/albums\/1550876571", "type" : "albums" } ], "next" : "\/v1\/catalog\/us\/artists\/991187319\/albums?offset=25" } } }, "kind" : "topResults" } ] } }
5
0
3.2k
Jun ’22
How to start playback of System Music Player?
Hi all, I am trying to start the playback of the current queue in the system music player using: let player = SystemMusicPlayer.shared try await player.play() But there is no playback, what am I doing wrong? Please keep in mind that there are already songs in the queue. I am simply unable start the playback.
6
0
2.9k
Apr ’22