Reputation:
my code id
public class Video1 extends Application {
private static String arg1;
@Override public void start(Stage stage) {
stage.setTitle("Media Player");
// Create media player
Media media = new Media("/home/ubuntu/NetBeansProjects/VideoPaly/src/videopaly/vid.flv");
javafx.scene.media.MediaPlayer mediaPlayer = new javafx.scene.media.MediaPlayer(media);
mediaPlayer.setAutoPlay(true);
mediaPlayer.setCycleCount(javafx.scene.media.MediaPlayer.INDEFINITE);
// Print track and metadata information
media.getTracks().addListener(new ListChangeListener<Track>() {
public void onChanged(Change<? extends Track> change) {
System.out.println("Track> "+change.getList());
}
});
media.getMetadata().addListener(new MapChangeListener<String,Object>() {
public void onChanged(MapChangeListener.Change<? extends String, ? extends Object> change) {
System.out.println("Metadata> "+change.getKey()+" -> "+change.getValueAdded());
}
});
// Add media display node to the scene graph
MediaView mediaView = new MediaView(mediaPlayer);
Group root = new Group();
Scene scene = new Scene(root,800,600);
root.getChildren().add(mediaView);
stage.setScene(scene);
stage.show();
}
public static void main(String[] args) {
if (args.length > 0) {
arg1 = args[0];
}
Application.launch(args);
}
}
I want to Play Video From Resource of Ubuntu when i run above code it give error like java.lang.IllegalArgumentException: uri.getScheme() == null! at line
Media media = new Media("/home/ubuntu/NetBeansProjects/VideoPaly/src/videopaly/vid.flv");
any idea about that?
Upvotes: 1
Views: 963
Reputation: 8900
From JavafX2 Media Class constructor doc :
Constructs a Media instance. This is the only way to specify the media source. The source must represent a valid URI and is immutable. Only HTTP, FILE, and JAR URLs are supported. If the provided URL is invalid then an exception will be thrown
Throws: java.lang.IllegalArgumentException - if the URI string does not conform to RFC-2396 or, if appropriate, the Jar URL specification, or is in a non-compliant form which cannot be modified to a compliant form.
so your source uri should be like this :
file://path to your media
Upvotes: 1