Java Media Framework
≈ 2 min read
Names in other languages
No names in other languages are held for this entry yet.
Article bodies are English and are not machine-translated. A name in another language is not a translation of the article.
The Java Media Framework (JMF) is a Java library that enables audio, video and other time-based media to be added to Java applications and applets. This optional package, which can capture, play, stream, and transcode multiple media formats, extends the Java Platform, Standard Edition (Java SE) and allows development of cross-platform multimedia applications.
The Java Media Framework (JMF) is a Java library that enables audio, video and other time-based media to be added to Java applications and applets. This optional package, which can capture, play, stream, and transcode multiple media formats, extends the Java Platform, Standard Edition (Java SE) and allows development of cross-platform multimedia applications. package org.wikipedia.examples; import java.awt.Component; import java.awt.FileDialog; import java.awt.Frame; import java.io.File; import java.io.IOException; import java.net.MalformedURLException; import javax.media.Manager; import javax.media.Player; import javax.media.MediaException; public class TrivialJMFPlayer extends Frame { public TrivialJMFPlayer() throws IOException, MalformedURLException, MediaException { FileDialog fd = new FileDialog(this, "TrivialJMFPlayer", FileDialog.LOAD); fd.setVisible(true); File f = new File(fd.getDirectory(), fd.getFile()); Player p = Manager.createRealizedPlayer(f.toURI().toURL()); Component c = p.getVisualComponent(); add(c); p.start(); } public static void main(String[] args) { try { Frame f = new TrivialJMFPlayer(); f.pack(); f.setVisible(true); } catch (Exception e) { e.printStackTrace(); } } } Much of the example is involved with the building of the AWT GUI. Only two lines touch JMF. Manager.createRealizedPlayer() implicitly creates a javax.media.protocol.DataSource from a URL representation of the file, creates a Player , and realizes it, meaning that all resources necessary for playback are allocated and initialized. The getVisualComponent() asks the javax.media.Player for a java.awt.Component suitable for use in a GUI. If a control component were desired, it would be obtained with getControlPanelComponent() and added to the GUI separately. Note that the developer is not concerned with the format of the media - this code works equally well for any media format that JMF can import and read. ==References==
Text derived from https://en.wikipedia.org/w/index.php?oldid=1363122959 under CC BY-SA 4.0; modifications have been made.