简体   繁体   中英

Converting audio and video to NSData

I would like to confirm what the recommended ways are to convert audio and video files into NSData objects. Is + dataWithContentsOfFile: the best way to do this?

对于视频,因为你唯一拥有的是URL,是的dataWithContentsofFile可能是获取数据的最佳方式。

That's not a conversion, and it doesn't matter what's in the file—video, audio, text, game data, random garbage, or nothing at all. NSData just gives you the plain bytes; you'll need to pass either the data or the original pathname or URL to a higher-level class (such as UIImage, AVAudioPlayer, or MPMoviePlayerController) to actually show or play it.

In fact, MPMoviePlayerController does not even accept a data object—it only accepts URLs.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM