如何检查视频或音频文件格式是否可以在iPhone中以编程方式播放? [英] How to check whether a video or audio file format is playable in iPhone programmatically?

查看:122
本文介绍了如何检查视频或音频文件格式是否可以在iPhone中以编程方式播放?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在服务器中存储了一些音频和视频文件.我需要播放它们,但我不知道iphone支持的服务器中存储的文件可以播放,

I have some audio and video files stored in a server. I need to play them, but I do not know the files stored in server supported by iphone to play,

在开始播放之前,如何检查iPhone是否支持该文件,我正在使用MPMoviePlayerController播放文件.

How can I check whether the file is supported by IPhone before start playing, I am using MPMoviePlayerController to play the files.

推荐答案

在播放之前,无法识别.将错误的文件格式传递给电影播放器​​时,电影播放器​​将引发错误. 为此,首先必须注意通知:MPMoviePlayerLoadStateDidChangeNotification如下:

Before playing them, its not possible to identify. Movie player will throw error when incorrect format of file is passed to it. For that, first you have to observe for noticiation: MPMoviePlayerLoadStateDidChangeNotification as following:

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(moviePlayerLoadStateChanged:) name:MPMoviePlayerLoadStateDidChangeNotification object:nil];

当您收到此通知时,请检查玩家的加载状态.如果其loadState为"MPMovieLoadStateUnknown",则可以说在播放电影/音频时发生了一些错误.

When you catch this notification, check for players load state. If its loadState is "MPMovieLoadStateUnknown", then you can say that some error occured while playing the movie/audio.

这篇关于如何检查视频或音频文件格式是否可以在iPhone中以编程方式播放?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆