December 22, 2012

JMF: java media framework example in java



Description :
import javax.media.*;
import java.io.File;
import java.awt.*;

public class JavaMusicPlayer extends Frame {

public static void main (String[] args) {
try {
Frame playerFrame = new JavaMusicPlayer();
playerFrame.pack();
playerFrame.setVisible (true);
} catch (Exception e) {
e.printStackTrace();
}
}
public JavaMusicPlayer()
throws java.io.IOException,
java.net.MalformedURLException,
javax.media.MediaException {
FileDialog rioDeJaneiroFileDialog = new FileDialog
(this, "JavaMusicPlayer", FileDialog.LOAD);
rioDeJaneiroFileDialog.setVisible(true);
File file = new File(rioDeJaneiroFileDialog.getDirectory(), rioDeJaneiroFileDialog.getFile());
Player javaMusicPlayer = Manager.createRealizedPlayer
(file.toURI().toURL());
Component musicComponent = javaMusicPlayer.getVisualComponent();
add(musicComponent);
javaMusicPlayer.start();
}
}

http://belazy.blog.com/

No comments:

Post a Comment

Your feedback may help others !!!

Facebook comments