3

I need to know what the Uniform Type Identifier is for an AAC audio file.

Context: I'm building an audio player app that plays DRM'd AAC files using HLS. I want to support offline playback, but I don't want to use AVFoundation's offline stuff (via AVAssetDownloadTask) because it'll delete the files out from under me when it needs to reclaim disk space (according to this WWDC 2016 session). So I'm downloading the files myself and using AVAssetResourceLoaderDelegate (walkthrough here) to serve files from the disk instead of the network when I want to. But the player just buffers forever. I tried serving a plain, unecrypted AAC file with no HLS involvement, and it failed the same way. I tried a plain, unencrypted MP3 file, and it worked. I changed the UTI provided to loadingRequest.contentInformationRequest.contentType in resourceLoader:shouldWaitForLoadingOfRequestedResource: from the correct audio.mp3 to audio.aac and it failed the same way. From this I infer that what I need is the correct UTI for an AAC file.

Update: Interestingly, public.aifc-audio and public.aac-audio work to play an unencrypted AAC audio file, but not the encrypted one with HLS involved.

Tom Hamming
  • 10,577
  • 11
  • 71
  • 145
  • I mean have you tried every type of audio UTI type provided by apple? there are only about 4 or 5 of them. [`kUTTypeAppleProtectedMPEG4Audio`](https://developer.apple.com/documentation/coreservices/kuttypeappleprotectedmpeg4audio) looks promising since in developer docs it says it covers "iTunes music store format" which AAC could fall under. – NSGangster Apr 02 '18 at 22:53
  • https://en.wikipedia.org/wiki/Advanced_Audio_Coding says AAC shares audio compression schemes with MPEG-4 so setting the UTI type I suggested above should in theory be more compatible with the file format. I know its a bit of a shotgun approach but if its not working I would try all of the `MPEG-4' UTI types listed in apple's "System-Declared" UTI's. – NSGangster Apr 02 '18 at 22:58
  • @NSGangster no luck with encrypted or unencrypted AAC with that UTI (`com.apple.protected-​mpeg-4-audio`). – Tom Hamming Apr 02 '18 at 23:02
  • @NSGangster also no luck on the unencrypted AAC test file with `public.mpeg-4-audio` or `public.mpeg-4`. – Tom Hamming Apr 02 '18 at 23:05
  • If the entire file is downloaded, in what sense is it streaming? – matt Apr 02 '18 at 23:27
  • @matt it's not streaming when it's downloaded...I don't think I said it was. My goal is to be able to download DRM'd .aac files that would normally be played over the network via HLS (involving .m3u8 playlist files) and be able to play them locally when offline. – Tom Hamming Apr 03 '18 at 16:23
  • Right but my question is, once they are downloaded, you don't need AVAssetResourceLoaderDelegate any more: you have the file on disk and can just play it directly in the normal way. Of course I could be wrong, but that's the question. – matt Apr 03 '18 at 16:29
  • @matt it's a DRM'd file though. I still need to use `.m3u8` files to specify that there's a key. Can't just point at the file directly. – Tom Hamming Apr 03 '18 at 20:17

0 Answers0