title: How do I play a video file in Javafx? -> Sample code
body: <p>I am trying to play a video (format doesn´t matter - I have converted it to flv, mov and mp4) in a simple javafx application. I just want to play the video in a window.</p>
  
  <p>The sample code below already works fine - but only with a URL Video from the oracle Website. I cannot make it work with a local file on my computer, even if I give the Media object a File with location. </p>
  
  <p>How do I need to modify the code to make a file in my project folder play?</p>
  
  <p>Here´s the code: </p>
  
  <pre><code>package Video;
  
  import javafx.application.Application;
  import javafx.scene.Group;
  import javafx.scene.Scene;
  import javafx.scene.layout.StackPane;
  import javafx.scene.media.Media;
  import javafx.scene.media.MediaPlayer;
  import javafx.scene.media.MediaView;
  import javafx.stage.Stage;
  
  public class player extends Application{
  
  StackPane stack = new StackPane();
  
  
  
  public void start(Stage primaryStage) throws Exception {
  
  Media media = new 
  Media("http://download.oracle.com/otndocs/products/javafx/oow2010-
  2.flv");
  
  MediaPlayer player = new MediaPlayer(media);
  
  
  primaryStage.setScene(new Scene(new Group(new MediaView(player)), 540, 
  208));
  primaryStage.setTitle("Title");
  primaryStage.show();
  
  player.play();
  }
  
  public static void main(String [] args) {
      Application.launch();
  }
  
  }
  </code></pre>