Post

Replies

Boosts

Views

Activity

Reply to ITLibrary musicFolderLocation wrong?
I have this problem as well using Xcode 13.2.1 and Swift 5.5.2. I think Apple broke something in the ITLibrary framework. When I call musicFolderLocation method on the ITLibrary, the URL path returned is completely fubar. It has “/Volumes/Music 1/iTunes/iTunes Media“. First of all, I don't even have a volume named “Music 1“ and I haven't used “iTunes“, or that naming convention, since Apple moonlighted it a long time ago. So I wanted to find out where the problem was, and it appears the ITLibrary is using a UserDefaults value from “iTunes-media-folder-url“ in “com.apple.AMPLibraryAgent.“ So I guess they still haven't gotten everything right with Music. The Music app is buggy as hell and I reported that to them since Catalina and it remains the same, if not worse with each new OS release. Anyway, I don't know if it would harm anything to manually rewrite that UserDefault or not, but until Apple fixes this, right now I don't see a way around it.
Topic: Programming Languages SubTopic: Swift Tags:
Mar ’22
Reply to Why no artwork in iTunesLibrary Framework?
Maybe this can help someone in the future as I am sure you've already worked this out after 5 years. I use this to get album artwork that is embedded in the MP3 file (all my music in my library is MP3 music).       let playerItem = AVPlayerItem(url: mp3URL)       let mp3Details = playerItem.asset.metadata       for item in mp3Details {         guard let key = item.key?.description, let value = item.value else {           continue         }         /*          TPE1 = Album artist          TPE2 = Artist          USLT = Lyrics          COMM = Comments          TCON = Genre          TRCK = Track of tracks          TCOM = Composer          TSSE = Encoder          TPOS = Disk of Disks          TDRC = Year released          TALB = Album Name          TBPM = Beats per minute          */         switch key {         case "TIT2": mp3Info["title"] = value as? String ?? nil         case "TPE1": mp3Info["artist"] = value as? String ?? nil         case "APIC" where value is NSData : mp3Info["artwork"] = NSImage(data: (value as! NSData) as Data) ?? nil         case "TALB": mp3Info["album"] = value as? String ?? nil         case "USLT": mp3Info["lyrics"] = value as? String ?? nil         case "TBPM": mp3Info["bpm"] = value as? Int ?? nil         default: continue         }       } Of course, this will probably not work on downloaded artwork, since that is an Apple product/service. But if you have MP3 files and you add artwork manually, like I do for my music, then this should work for retrieval.
Mar ’22