Apple Music & iCloud Music Library - no audio file access

Hey all,


I'm not sure if the following is a bug or deliberate policy on Apple's part, so I thought I'd post to the Apple forums first.


I've been developing a high-quality "looper" app for iPad, intended to help musicians practice against songs from their library by isolating passages in the music using graphical breakpoints. My app CANNOT use streaming music data; it depends on lightning-fast high-precision seek times, waveform graphing of audio data, and control of playback speed and pitch. All those 1s & 0s have to be down on the device, stored in a local audio file.


About three months ago (maybe May), I purchased an Apple Music subscription to test with my app. So far, so good. I could browse the Music app on my iPad, select a song I'd never owned before through Apple Music, then hit the download icon to put the audio file on my device. Once downloaded, I could open my looper app and play the downloaded file with no issue. The fact that my app could work with any song "rented" through Apple Music was pretty awesome.


I'm not sure, but I believe when my device was upgraded to iOS 10.3.3, this ability was promptly barred. With an Apple Music description, and the iPad's iCloud Music Library turned on through Settings > Music > iCloud Music Library, I could still supposedly download songs to my device, but when I attempted to open that same song in my own looper app, the MPMediaItem's file asset URL is now nil. In fact, I could not play any song, whether originally ripped form CD, bought from the Store, or "rented" from Apple Music. The only workaround is to go into device settings and turn iCloud Music Library off, then sync my iPad the old-fashioned way through my Mac's iTunes. Now I can play my songs again, (those ripped from CDs or bought from the Store)...but I can't use my Apple Music subscription anywhere, on any device or Mac, until I turn iCloud Music Library back on. Then I can't play any songs in my app again.


Thankfully, I had not yet released my app into the Store, but this would have totally hosed me for any customers who might have bought my app to use with music obtained through an Apple Music subscription. Suddenly they wouldn't have been able to play anything. There is no warning I can find from Apple concering the change, nor any description of how Apple Music & iCloud Music Library work with local audio files downloaded to the user device:


This Apple Music API FAQ is of little help:

https://affiliate.itunes.apple.com/resources/blog/apple-music-api-faq/

The only thing I could find in the entire FAQ that even remotely pertained to this issue is this: "There is no support currently for DJ style apps." What does that mean?


This is extremely frustrating. Basically, potential users of my app would have to turn off iTunes Music Library, thereby freezeing themselves entirely out of their Apple Music subscription, for all their Apple products. Surely I can't be the only developer with this dilemma.


Thanks for reading. Any insight would be greatly appreciated.


Yours,

Geoff

I'm replying to myself here, to report further investigation.


I did some digging around in CoreAudio with the file formats of audio data files downloaded from a user's iCloud account. I opened the files in this way:


1) Obtained the audio file asset's CFURLRef url.

2) Obtained the audio file's ExtAudioFileRef through a call to ExtAudioFileOpenURL.

3) Used the ExtAudioFileRef to get the file's kExtAudioFileProperty_FileDataFormat property through a call to ExtAudioFileGetProperty.

Now I have the files' respective formats, contained in an AudioStreamBasicDescription struct.

GOOD FILE (downloaded from iCloud likely prior to 10.3.3?)

(AudioStreamBasicDescription) $0 = {

mSampleRate = 44100

mFormatID = 1885430115

mFormatFlags = 0

mBytesPerPacket = 0

mFramesPerPacket = 1024

mBytesPerFrame = 0

mChannelsPerFrame = 2

mBitsPerChannel = 0

mReserved = 0

}


BAD FILE (downloaded on device running 10.3.3 or later?)

(AudioStreamBasicDescription) $0 = {

mSampleRate = 44100

mFormatID = 1633772320 // <- only difference

mFormatFlags = 0

mBytesPerPacket = 0

mFramesPerPacket = 1024

mBytesPerFrame = 0

mChannelsPerFrame = 2

mBitsPerChannel = 0

mReserved = 0

}


The only different between the two is the mFormatID. Let's see what those UInt32s say when converted to 4-character ASCII:


GOOD: mFormatID 1885430115 --> 'aac '

BAD: mFormatID 1633772320 --> 'paac '


So it seems we have a new file format...one that I cannot find any documentation for anywhere. I'm really, really hoping it's not something like 'protected AAC', and that Apple is not deliberately baring third-party code from playing these files directly on the device.


I'm also hoping this reply gives my posting a bump, and gets some attention from Apple engineers to confirm.


NOTE: I have not yet figured out the cases that cause one to download 'aac' vs. 'paac'. It seems to vary by iOS version, and by the iCloud status field (Matched vs Uploaded vs Purchased vs whatever).

Hi,

unfortunately 'paac' really stands for 'Protected AAC', DRM protected files, so it cannot be played using CoreAudio stack. Files obtained via Apple Music subscription are DRM protected, user's own music (purchased or uploaded) in iCloud should not be. That's what I've learned so far.

Apple Music & iCloud Music Library - no audio file access
 
 
Q