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 d开发者_高级运维o this?
For videos since the only thing you have is the URL, yes dataWithContentsofFile is probably the best way to get the data for it.
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.
精彩评论