在 iOS 中获取文件类型(音频或视频)

发布于 2024-10-08 03:00:38 字数 209 浏览 0 评论 0原文

我有一个应用程序,可以打开并显示下载并保存在设备上的各种文件。

我已经将数据加载到 UIImage 中,如果文件不是图像,则相当于 nil,但是在确定文件是音频还是视频文件时我陷入了困境。

我正在使用 MPMoviePlayerViewController 来播放视频,它也会很高兴地播放声音,但我想知道是否没有视频并通过自己的不同界面呈现

有什么想法吗?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

赏烟花じ飞满天 2024-10-15 03:00:38

好吧,您随时可以查看文件扩展名,并自行确定内容类型! =)

Google 搜索应该能够告诉您很多信息,但这里有一些 AVAudioPlayer 和 MPMoviePlayerController 支持的格式的起始信息,无需您进行任何额外的工作:

音频文件:MP3、M4P、M4A / AAC、WAV 和 CAF

视频文件:M4V、MPV、MP4、MOV、3GP

(注意:我不知道上面是否是完整的格式列表,但它应该可以帮助您入门。)

有时视频文件可能只包含音轨,但我不确定在哪里指导您以编程方式解决这个问题。也许其他人有一些想法——我也想知道!

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!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文