我尝试使用 javafx 在 java 中构建视频播放,您可以在其中将文件路径添加到视频存储在计算机上的位置,
但出现错误:
Error: Could not find or load main class javafxapplication1.MoviePlayer
当我尝试上课时
package javafxapplication1;
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;
/**
* @author goldAnthony
*/
public class MoviePlayer extends Application {
public static void main (String [] args) {
launch(args);
}
@Override
public void start(Stage stage) throws Exception {
Group root = new Group();
Media media = new Media("C:\\Users\\goldAnthony\\Videos\\Whistle.mp4");
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();
}
}
请帮忙