开发者

Getting file type (Audio or Video) in iOS

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 fil开发者_JAVA技巧e 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?


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!

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜