views:

392

answers:

2

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?

Thank you

+3  A: 

For videos since the only thing you have is the URL, yes dataWithContentsofFile is probably the best way to get the data for it.

Daniel
A: 

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.

Peter Hosey
Huh? What was unhelpful about my answer?
Peter Hosey
+1 bizarre down-vote on a perfectly fine answer.
Rob Napier