如何将NSData加载到AVPlayerItem?

Kir*_*sar 5 cocoa-touch objective-c nsdata ios avplayer

这是我关于如何在iOS中加密mp3文件的帖子中的后续问题.

我如何使用NSData而不是文件路径/ URL将轨道加载到AVPlayerItem?

谢谢

Dus*_*tin 9

[/*name of NSData*/ writeToFile:/*save file path*/ atomically: YES];
NSURL *filepath = [NSURL fileURLWithPath:/*save file path*/];
AVPlayerItem *player = [AVPlayerItem playerItemWithURL:filepath];
Run Code Online (Sandbox Code Playgroud)

未经测试,但应该工作.