This is the next question from my post on How to encrypt mp3 files in iOS .
How can I load a track into AVPlayerItem using NSData and not the file path / URL?
thanks
[/*name of NSData*/ writeToFile:/*save file path*/ atomically: YES]; NSURL *filepath = [NSURL fileURLWithPath:/*save file path*/]; AVPlayerItem *player = [AVPlayerItem playerItemWithURL:filepath];
Unconfirmed, but should work.
Update 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)