Reputation: 847
I developed a Media Player in JavaFx and that plays Media with format (.mp4) files.
But, When I try to play (.MKV) files, the player is not working.
How to make this player works with (.MKV) files?
import java.io.File;
import java.io.InputStreamReader;
import java.net.URI;
import java.net.URL;
import javafx.application.Application;
import javafx.scene.Group;
import javafx.scene.Scene;
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 WmvFileMoviePlayer extends Application{
public static void main (String [] args){
launch(args);
}
@Override
public void start(Stage stage) throws Exception {
Group root = new Group();
try{
Media media = new Media("video/Indian_Sept_2017.wmv");
MediaPlayer player = new MediaPlayer(media);
MediaView view = new MediaView(player);
root.getChildren().add(view);
Scene scene = new Scene(root, 400, 400, Color.BLACK);
stage.setScene(scene);
stage.show();
player.play();
}
catch(Exception e)
{
e.printStackTrace();
}
}}
Upvotes: 0
Views: 1493
Reputation: 10640
.wmv is not one of the supported media formats of JavaFX. See here:SupportedMediaTypes You could try something like this instead: https://github.com/caprica/vlcj-javafx
Upvotes: 1