Skip to Main Content

JavaFX MediaPlayer

4301785Aug 5 2020 — edited Aug 5 2020

I've been trying to create a Video Player in JavaFX using the Media/MediaView and MediaPlayer libraries. Everything seems to be working just fine except for the Media library, which crashes the program before anything display. I'm getting an error saying that I don't have the media library, or more specifically, the library. I've tried this on two different devices with different installations as well. I saw another similar issue on stack overflow where someone posted this problem, but their was no response. Any suggestions?

My current version:

package application;


import javafx.application.Application;

import javafx.stage.Stage;

import javafx.scene.Scene;

import javafx.scene.control.Button;

import javafx.scene.control.Label;

import javafx.scene.layout.GridPane;

import javafx.scene.layout.HBox;

import javafx.scene.layout.Pane;

import javafx.scene.layout.StackPane;

import javafx.scene.layout.TilePane;

import javafx.scene.layout.VBox;




public class Main extends Application  {

public static void main(String args[]){       




public void start(Stage primaryStage) throws Exception {

String file = "";

Media media = new Media(new File(file).toURI().toString());

MediaPlayer mediaplayer = new MediaPlayer(media);

MediaView mediaView = new MediaView (mediaplayer);

Button button1 = new Button("Play");

button1.setOnAction(e -> {;


GridPane layout = new GridPane();



layout.add(mediaView, 1, 0);

layout.add(button1, 0, 1);

Scene scene = new Scene(layout, 300, 200);

primaryStage.setTitle("JavaFX example");




I've tried looking all over the place, but can't find a solution. I've tried directly copy pasting code from working examples and tried to run it but it doesn't work. This kind of implies that the problem is with me. I have all the required files (I double checked) and I've installed everything correctly. I've been learning JavaFX from this site for over a month now.

Post Details
Added on Aug 5 2020