Reputation: 563
I'm trying to play a short .mp4 animation from my local machine. I've installed Javafx to try and help me with this, but I'm completely unfamiliar with how to use it, since my only experience is with swing. I've successfully got a video to play with online sources (using help from Play a video using javafx). I assume this only works with an online clip as a .flv file instead of mp4. Anyway the code I have is
package application;
import javafx.application.Application;
import javafx.scene.*;
import javafx.scene.media.*;
import javafx.stage.Stage;
public class VideoPlayerExample extends Application {
public static void main(String[] args) throws Exception { launch(args); }
@Override public void start(final Stage stage) throws Exception {
final MediaPlayer oracleVid = new MediaPlayer(
new Media("http://download.oracle.com/otndocs/products/javafx/oow2010-2.flv")
);
stage.setScene(new Scene(new Group(new MediaView(oracleVid)), 540, 208));
stage.show();
oracleVid.play();
}
}
I'm trying to see if there's a simple way I can replace the url when creating oracleVid with my own .mp4 file with a build path from my local machine? Is what I have here completely opposite from what I'm looking for?
Upvotes: 0
Views: 239
Reputation: 168835
I'm trying to see if there's a simple way I can replace the url when creating oracleVid with my own .mp4 file with a build path from my local machine?
Use file.toURI().toURL()
..
Upvotes: 1