import javafx.application.Application; import javafx.collections.ListChangeListener; import javafx.collections.MapChangeListener; import javafx.scene.Group; import javafx.scene.Scene; import javafx.scene.media.Media; import javafx.scene.media.MediaView; import javafx.scene.media.Track; import javafx.stage.Stage; /** * A sample media player which loops indefinitely over the same video */ public class MediaPlayer extends Application { private static final String MEDIA_URL = ""; private static String arg1; @Override public void start(Stage stage) { stage.setTitle("Media Player"); // Create media player //Media media = new Media((arg1 != null) ? arg1 : MEDIA_URL); //Media media = new Media("file:///Users/gnomo/EasyReach/test/2.mp4"); //Media sampleMedia = new Media("file:///Users/gnomo/test/sample_iTunes.mov"); //Media sampleMedia = new Media("file:///Users/gnomo/test/Movie.flv"); //Media sampleMedia = new Media("file:///Users/gnomo/EasyReach/test/Movie.mp4"); //Media sampleMedia = new Media("file:///Users/gnomo/EasyReach/NetBeansProjects/EasyReachServer/src/it/contexta/easyreach/gui/samplemovie.flv"); //Media sampleMedia = new Media("file:///Users/gnomo/EasyReach/NetBeansProjects/EasyReachServer/src/it/contexta/easyreach/gui/samplemovie.mp4"); //Media sampleMedia = new Media("file:///Users/gnomo/EasyReach/NetBeansProjects/EasyReachServer/src/it/contexta/easyreach/gui/barsandtone.flv"); //Media sampleMedia = new Media("file:///Users/gnomo/EasyReach/NetBeansProjects/EasyReachServer/media/2012-02-15-23-44-29_movie.mp4"); Media sampleMedia = new Media("file:///Users/gnomo/EasyReach/NetBeansProjects/EasyReachServer/media/2012-02-15-23-44-29_movie.m4v"); javafx.scene.media.MediaPlayer mediaPlayer = new javafx.scene.media.MediaPlayer(sampleMedia); mediaPlayer.setAutoPlay(true); mediaPlayer.setCycleCount(javafx.scene.media.MediaPlayer.INDEFINITE); /* // Print track and metadata information media.getTracks().addListener(new ListChangeListener() { @Override public void onChanged(Change change) { System.out.println("Track> " + change.getList()); } }); media.getMetadata().addListener(new MapChangeListener() { @Override public void onChanged(MapChangeListener.Change change) { System.out.println("Metadata> " + change.getKey() + " -> " + change.getValueAdded()); } }); * */ // Add media display node to the scene graph MediaView mediaView = new MediaView(mediaPlayer); Group root = new Group(); Scene scene = new Scene(root, 800, 600); root.getChildren().add(mediaView); stage.setScene(scene); stage.show(); } public static void main(String[] args) { if (args.length > 0) { arg1 = args[0]; } Application.launch(args); } }