Java Fx 2.0 Simple Media Player

In Java Fx 2.0 is fully a UI based Application in which we can easily create all types of desktop and web based component .Here i have explained a sample media player program which  it can play all type of you tube files.for running this application you need netbeans 7.1. with javafx 2.0
// Comment

package SimpleMediaPlayer;

import javafx.application.Application;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.paint.Color;
import javafx.stage.Stage;

 * @author
public class SimpleMediaPlayer extends Application {

     * @param args the command line arguments
    public static void main(String[] args) {

    public void start(Stage stage) {
     //At First Step You have to create a Scence For Showing the Screen.
     Scene scene = new Scene(new Group(), 540, 209,Color.BLUEVIOLET);

     // Name and display the Stage.
     stage.setTitle("Welcome to Java Fx 2.0 Media Player Example");;
     // Create the media source. which is possible to get the file from the Embeddedjar itself
     Media media = new Media(SimpleMediaPlayer.class.getResource("You Belong To Me - JX.flv").toString());

     // Create the player for playing media.
     MediaPlayer mediaPlayer = new MediaPlayer(media);
     //set player property to autoplay

     // Create the view and add it to the Scene.
     MediaView mediaView = new MediaView(mediaPlayer);
     ((Group) scene.getRoot()).getChildren().add(mediaView);
test Web Developer


  1. I copied this code but it doesn't work..

  2. Initially the code failed. But when I used an .mp4 video file instead of a .flv file, The code ran PERFECTLY.
    Thank a lot mate...:)


Related Posts Plugin for WordPress, Blogger...