0

this is a videoplayer in javafx.how we can support mkv,vob,avi etc extension ? is this possible to use gstreamer in javafx to support other extension? how can we use gstreamer or if not then plz say any other way to make the videoplayer other extension supported...

import javafx.application.Application;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.control.Slider;
import javafx.scene.layout.VBox;
import javafx.scene.media.Media;
import javafx.scene.media.MediaPlayer;
import javafx.scene.media.MediaView;
import javafx.scene.paint.Color;
import javafx.stage.Stage;


public class MoviePlayer extends Application {

/**
 * 
 */
    public static void main(String args[])
    {
        launch(args);
    }

    @Override
    public void start(Stage arg0) throws Exception {

    final Stage stage=new Stage();
    stage.setTitle("Video Player");
    Group root = new Group();
    Media media = new Media("file:///C:/Users/vi/downloads/Video/a.mp4");
    final MediaPlayer player=new MediaPlayer(media);
    MediaView view=new MediaView(player);

    //  System.out.println("media.Width"+media.getWidth());

    final VBox vbox=new VBox();
    Slider slider=new Slider();


    root.getChildren().add(view);
    root.getChildren().add(vbox);
    root.getChildren().add(slider);

    Scene scene=new Scene(root, 400,400,Color.BLACK);
    stage.setScene(scene);
    stage.show();

    player.play();
    player.setOnReady(new Runnable() {

        @Override
        public void run() {
            int w=player.getMedia().getWidth();
            int h=player.getMedia().getHeight();

            stage.setMinWidth(w);
            stage.setMinHeight(h);

            vbox.setMinSize(w,100 );
            vbox.setTranslateY(h);

           }
        });



    }


}
  • 1
    The media playback capabilities in JavaFX are not meant to be extended by users of the framework. If you are willing to make your own build of JavaFX, you can have a look at [this article](http://berry120.blogspot.fr/2014/03/expanding-javafxs-media-support.html). IMO, a more realistic solution is to use another media playback library entirely, like [vlcj](https://github.com/caprica/vlcj), which already supports a wide variety of media formats (but it won't be as easy to use as JavaFX's MediaPlayer). – Cyäegha Nov 17 '14 at 16:39
  • possible duplicate of [Adding other video codecs / DVD support to JavaFX 2.2](http://stackoverflow.com/questions/8153227/adding-other-video-codecs-dvd-support-to-javafx-2-2) – jewelsea Nov 17 '14 at 23:17

1 Answers1

0

Old topic, but stumbling around today brought up a gstreamer-java repo on GitHub. It's a few years old. But lately there are fresh gst1-java and gst1-java-fx projects there. As in updated 11 days ago. It would be interesting to try out the examples and see if they can accept other movie formats. But it looks like the documentation is sparse to none.

Another alternative is to use ffmpeg or handbrake to remux the videos into another container format.

hellork
  • 324
  • 2
  • 8