how can i use Gstreamer in javafx videoplayer?

泪湿孤枕 提交于 2019-12-13 05:26:05

问题


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);

           }
        });



    }


}

来源:https://stackoverflow.com/questions/26959282/how-can-i-use-gstreamer-in-javafx-videoplayer

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!