저는 JavaFX 8의 MultiMedia 클래스를 사용하여 자체 멀티미디어 응용 프로그램을 작성하고 있습니다. 처음부터 (내 시작) 내 프로그램을 실행할 때 너비와 높이가 내 Stage
과 같습니다. 미디어 (비디오)의 넓이와 높이.JavaFX MediaPlayer - 스테이지 크기
mp.setOnReady(new Runnable() {
@Override
public void run() {
Timeline slideIn = new Timeline();
Timeline slideOut = new Timeline();
stage.getScene().setOnMouseEntered(e -> {
slideIn.play();
});
stage.getScene().setOnMouseExited(e -> {
slideOut.play();
});
// here I get the width and heigth of the media
int w = mp.getMedia().getWidth();
int h = mp.getMedia().getHeight();
// width is 1280 and heigth is 720 (both values are correct)
if (w != 0 && h != 0) {
//Here Im setting the width and the height of stage
//But when I run my app, stage is a little bit smaller than
//MediaView and I have to resize the stage manually by cca 20px to get the whole view
stage.setWidth(w);
stage.setHeight(h);
stage.centerOnScreen();
//On the other hand, animation works pretty well and
//correctly with the "w" and "h"
mediaBar.setMinSize(w - 100, 100);
mediaBar.setTranslateY(h - 100);
mediaBar.setTranslateX(50);
mediaBar.setOpacity(0);
slideIn.getKeyFrames().addAll(new KeyFrame(new Duration(0), new KeyValue(mediaBar.translateYProperty(), h), new KeyValue(mediaBar.opacityProperty(), 0.0)),
new KeyFrame(new Duration(300), new KeyValue(mediaBar.translateYProperty(), h - 100), new KeyValue(mediaBar.opacityProperty(), 0.9))
);
slideOut.getKeyFrames().addAll(new KeyFrame(new Duration(0), new KeyValue(mediaBar.translateYProperty(), h - 100), new KeyValue(mediaBar.opacityProperty(), 0.9)),
new KeyFrame(new Duration(300), new KeyValue(mediaBar.translateYProperty(), h), new KeyValue(mediaBar.opacityProperty(), 0.0))
);
background.setWidth(w - 100);
background.setHeight(100);
background.setTranslateY(h - 100);
background.setTranslateX(50);
background.setOpacity(0);
slideIn.getKeyFrames().addAll(new KeyFrame(new Duration(0), new KeyValue(background.translateYProperty(), h), new KeyValue(background.opacityProperty(), 0.0)),
new KeyFrame(new Duration(300), new KeyValue(background.translateYProperty(), h - 100), new KeyValue(background.opacityProperty(), 1))
);
slideOut.getKeyFrames().addAll(new KeyFrame(new Duration(0), new KeyValue(background.translateYProperty(), h - 100), new KeyValue(background.opacityProperty(), 1)),
new KeyFrame(new Duration(300), new KeyValue(background.translateYProperty(), h), new KeyValue(background.opacityProperty(), 0.0))
);
} else {
//music
}
duration = mp.getMedia().getDuration();
updateValues();
}
});
그래서 내가 아직 모르는 Stage
클래스에 대해 중요한 것이 있다고 생각합니다.
initStyle
을 Stage
에서 StageStyle.UNDECORATED
으로 설정하면 전체 MediaView
을 볼 수 있습니다. 그러나 나는이 스타일을 원하지 않는다.
누구든지이 문제를 해결할 수 있습니까? 이 질문이 처음 도움말 요청이기 때문에 올바르게 문제를 설명했기를 바랍니다. 감사.