0

I have an app where I open and display a variety of files that are downloaded and saved on the device.

I already have the data load into a UIImage, which equates to nil is the file isn't an image, but I'm stuck when it comes to finding out if the file is an audio or video file.

I'm using MPMoviePlayerViewController to play videos, which will quite happily play sound as well, but I'd rather know if there was no video and present by own different interface

Any ideas?

Eimantas
  • 48,927
  • 17
  • 132
  • 168
Ben Robinson
  • 1,602
  • 3
  • 16
  • 30

1 Answers1

3

Well, you can always take a look at file extensions, and determine the content type yourself! =)

Google-searching should be able to tell you a lot, but here's some starting info for formats that the AVAudioPlayer and MPMoviePlayerController support without any extra work from you:

Audio Files: MP3, M4P, M4A / AAC, WAV, and CAF
Video Files: M4V, MPV, MP4, MOV, 3GP

(Note: I do not know whether the above is a complete list of formats, but it should get you started.)

Sometimes a video file may only contain an audio track, but I'm not sure where to direct you to figure that one out programmatically. Maybe someone else has some ideas--I'd like know to as well!

MechEthan
  • 5,703
  • 1
  • 35
  • 30
  • Thanks for the reply - extensions keeps coming to mind, but it seems like a bad idea - something I've constantly keep aware of (as new support is added!) - but if it's the only way?!? – Ben Robinson Dec 19 '10 at 15:40
  • Well, its the only way I've found to handle it in my app, this is quite literally what I am doing in something we're about to ship. Honestly, I feel looking at file extensions is a safe thing to do, because as with any software, you're going to have to update it as the things it depends on change. (Like going from 3.2 SDK to 4.2 SDK!) – MechEthan Dec 20 '10 at 03:58