How do I make JavaFX MediaView stretch media to fill parent container?

前端 未结 4 1031
故里飘歌
故里飘歌 2020-12-17 20:38

I\'m trying to make my video\'s dimensions stretch automatically and fill the MediaView and maintain the original aspect ratio of the video. Basically, I want my MediaPlayer

4条回答
  •  自闭症患者
    2020-12-17 21:34

    Just realized no-one answered this so I'll answer it.

    Just set the media player fitWidthProperty to that of the MediaView so:

    player.fitWidthProperty().bind(mediaView.widthProperty());
    

    and the same for the height (if you wanted) and also preserveRatio and stuff.

提交回复
热议问题