I am building a small Swing application that I would like to embed a movie within. Importantly, this application is a WebStart application - and the library should be able t
Some considerations for JavaFX as a solution as a Java based media playback framework.
Here is a sample JavaFX app which plays a video:
import javafx.application.Application;
import javafx.scene.*;
import javafx.scene.media.*;
import javafx.stage.Stage;
public class VideoPlayerExample extends Application {
public static void main(String[] args) throws Exception { launch(args); }
@Override public void start(final Stage stage) throws Exception {
final MediaPlayer oracleVid = new MediaPlayer(
new Media("http://download.oracle.com/otndocs/products/javafx/oow2010-2.flv")
);
stage.setScene(new Scene(new Group(new MediaView(oracleVid)), 540, 208));
stage.show();
oracleVid.play();
}
}
Although I have not had any problems with formats compatibility o JMF you can take a look in JavaFX that was designed to be a competitor to Flash, so should support all media formats and codecs. You can also embed Flash player into java application using JNI/JNA but it seems too complicated. I'd recommend you to start with JMF and look for other solution only if you really have problems.
..have tried JMF but the format compatibility I believe to be relatively poor when compared to other frameworks out there.
You are right about the lack of support for modern codecs, but it works just fine for older codecs. It might be a viable option if:
While the 'performance pack' version of the JMF which uses natives supports more formats, the core Java JMF API also provides some basic formats.