This is a follow-on question from my post about How to Encrypt mp3 Files in iOS.
How would I go about loading a track into an AVPlayerItem using NSData rather than a fil
Updating Dustin's answer for Swift 5:
var audioData: Data // some audio data var fileURL: URL // some local path, probably appending NSTemporaryDirectory() try! audioData.write(to: fileURL) let item = AVPlayerItem(url: fileURL)