The Music macOS app shows various info about a song in the Get Info window. Most of this metadata is available in the iOS SDK via MPMediaItem. I'm wanting to access the information displayed in the File tab but I'm not seeing several pieces of data in the API. Is this possible?
□ Kind - Apple Music AAC audio file - ?
☑︎ Duration - 3:00 - playbackDuration
□ Size - 10 MB - ?
□ Bit rate - 256 kbps - ?
□ Sample rate - 44.100 kHz - ?
□ Date modified - 1/1/2001 - ?
☑︎ Date added - 1/1/2001 - dateAdded
□ Cloud status - Apple Music - ?
☑︎ Location - Cloud - isCloudItem
Selecting any option will automatically load the page
Post
Replies
Boosts
Views
Activity
Given an Apple Music trackId is it possible to query the user’s media library to see if they’ve added it to their library? Something like:
let predicate = MPMediaPropertyPredicate(value: "1440818675", forProperty: MPMediaItemPropertyPersistentID)
let query = MPMediaQuery(filterPredicates: Set([predicate]))
let songs = query.items
let isInLibrary = !songs.isEmpty
I'd like to get a song's bit rate, for example 256 kbps, from a MPMediaItem retrieved via MPMediaPickerController. Is this possible?
I tried to get it via:
AVAsset(url: mediaItem.assetURL).tracks.first?.estimatedDataRate
but this is 0 for most songs I've tried, and it's 127999 for a song that's really 64 kbps.
I can get the sample rate of 44100 via:
let trackDescription = AVAsset(url: url).tracks.first?.formatDescriptions.first
let basicDescription = CMAudioFormatDescriptionGetStreamBasicDescription(trackDescription as! CMAudioFormatDescription)?.pointee
let sampleRate = basicDescription.mSampleRate
Supposedly one can calculate the bit rate given the sample rate, bit depth, and channels count, but I'm seeing mBitsPerChannel is always 0 in my testing.
iOS 14 users can change the default email app. What effect, if any, does this have on MFMailComposeViewController?
Currently if canSendMail() returns false I instruct the user to set up an account in the Mail app. Maybe the wording needs to be different?