JMF Supported Formats
帮朋友调试一个JMF的程序,发现换个格式的文件就不行了,故想找下JMF支持哪些格式的文件。官网有详细的说明,故在此记录下。
不能播放的格式一般报如下的错误:
Cannot find a Player for: com.sun.media.protocol.file.DataSource
1:官方比较详细的 JMF 2.1.1 - Supported Formats
http://www.oracle.com/technetwork/java/javase/formats-138492.html
2:官方泛泛的说明
What media types does JMF 2.1.1 support?
http://www.oracle.com/technetwork/java/javase/index-135148.html#jmf2-support
JMF 2.1.1 supports a wide array of media types, including
- protocols: FILE, HTTP, FTP, RTP
- audio: AIFF, AU, AVI, GSM, MIDI, MP2, MP3*, QT, RMF, WAV
- video: AVI, MPEG-1, QT, H.261, H.263
- other: HotMedia
*MP3 is supported only on the Windows platform.
3:通过查看官方JAVA API文档并找源码实现的方式
首先找核心Manager的API文档
然后结合错误并留意到如下一段说明:
Finding Players by Content Type
A Player is a MediaHandler. A MediaHandler is a an object that reads data from a DataSource. There are three types of supported MediaHandler: MediaProxy, Player and Processor.
MediaHandlers are identified by the content type that they support. A DataSource identifies the content type of the data it produces with the getContentType method. Manager uses the content type name to find instances of MediaHandler.
To find a MediaHandler using a content type name, Manager constructs a list of class names from the content package-prefix list and the content type name. For each class name in the constructed list a new MediaHandler is instantiated, and the DataSource is attached to the MediaHandler using MediaHandler.setSource.
If the MediaHandler is a Player and the setSource was successful the process is finished and the Player is returned. If the setSource failed, another name in the list is tried.
If the MediaHandler is a MediaProxy then a new DataSource is obtained from the MediaProxy, a new list is created for the content type the DataSource supports and the whole thing is tried again.
If a valid Player is not found then the whole procedure is repeated with "unknown" substituted for the content-type name. The "unknown" content type is supported by generic Players that are capable of handling a large variety of media types, often in a platform dependent way.
The detailed creation algorithm is specified in the methods below.
找到重点在于 MediaHandlers 这个类的实现类,ok开始在eclipse中看其有哪些实现类,实现类中主要看Parser即可。

ok,代码实现和官方文档基本吻合。