我最近发现 javafx 2.1 对我制作视频播放器的项目非常有用,但是在成功之后我遇到了视频大小尺寸的问题。换句话说,当我运行程序并且视频正常播放时,我看不到整个视频,因为它的尺寸大于我的屏幕分辨率。我可以在下面的代码中做什么来调整 windows7 64bit 中视频的实际大小:
public class HelloFx extends Application {
public static void main(String[] args){
launch(args);
}
@Override
public void start(final Stage stage) throws Exception {
stage.setTitle("Movie Player");
final BorderPane root = new BorderPane();
final Media media = new Media("file:///Users//user//Videos//Sintel.mp4");
final MediaPlayer player = new MediaPlayer(media);
final MediaView view = new MediaView(player);
// System.out.println("media.width: "+media.getWidth());
root.getChildren().add(view);
final Scene scene = new Scene(root, 400, 400, Color.BLACK);
stage.setScene(scene);
stage.show();
player.play();
player.setOnReady(new Runnable() {
@Override
public void run() {
int w = player.getMedia().getWidth();
int h = player.getMedia().getHeight();
stage.setMinWidth(w);
stage.setMinHeight(h);
}
});
//player.play();
}
}