FazBrowse Wikipedia Viewer | Main Page |
Search Wikipedia:
|
Viewing: https://en.wikipedia.org/wiki/Java_Media_Framework

Java Media Framework

"},"caption":{"wt":"JMF's simple '''JMStudio''' application playing a [[QuickTime]] movie"},"developer":{"wt":"[[Sun Microsystems]]"},"latest_release_version":{"wt":"2.1.1e"},"latest_release_date":{"wt":"{{release_date|2003|5|23}}"},"latest_preview_version":{"wt":""},"latest_preview_date":{"wt":""},"operating_system":{"wt":"[[Cross-platform]]"},"programming_language":{"wt":"[[Java (programming language)|Java]]"},"genre":{"wt":"[[Library (computing)|Library]] for multimedia"},"license":{"wt":""},"website":{"wt":"[http://www.oracle.com/technetwork/java/javase/tech/index-jsp-140239.html Java Media Framework API (JMF), on Oracle.com]"}},"i":0}}]}'>
Java Media Framework
DeveloperSun Microsystems
packageorg.wikipedia.examples; importjava.awt.Component; importjava.awt.FileDialog; importjava.awt.Frame; importjava.io.File; importjava.io.IOException; importjava.net.MalformedURLException; importjavax.media.Manager; importjavax.media.Player; importjavax.media.MediaException; publicclass TrivialJMFPlayerextendsFrame{ publicTrivialJMFPlayer()throwsIOException,MalformedURLException,MediaException{ FileDialogfd=newFileDialog(this,"TrivialJMFPlayer",FileDialog.LOAD); fd.setVisible(true); Filef=newFile(fd.getDirectory(),fd.getFile()); Playerp=Manager.createRealizedPlayer(f.toURI().toURL()); Componentc=p.getVisualComponent(); add(c); p.start(); } publicstaticvoidmain(String[]args){ try{ Framef=newTrivialJMFPlayer(); f.pack(); f.setVisible(true); }catch(Exceptione){ 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

edit
Platforms
Technologies
Sun, Oracle
Platform
Major
third-party
History
Platform
languages
Community
Conferences
Organizations
People

View original on Wikipedia | Back | FazBrowse Home