Display VlcJ in JavaFX using SwingNode

本小妞迷上赌 提交于 2019-12-07 12:00:30

In short, it won't work this way.

From the Javdoc for SwingNode here: http://docs.oracle.com/javase/8/javafx/api/javafx/embed/swing/SwingNode.html

It states, in part:

The hierarchy of components contained in the JComponent instance should not contain any heavyweight components, otherwise SwingNode may fail to paint it.

In the case of vlcj, the EmbeddedMediaPlayerComponent extends Panel, a heavyweight AWT component.

To use with vlcj with JavaFX you will likely have to render the video data directly yourself. This is what vlcj's so-called DirectMediaPlayerComponent is for. The essence of this approach is that the DirectMediaPlayerComponent receives each frame of video data to render, and you would then render this yourself using a PixelWriter or some other means that you come up with.

There is a vlcj-javafx project here https://github.com/caprica/vlcj-javafx, and this approach works up to Java7. It does not work with Java8 due to wrong threading, documented here: https://github.com/caprica/vlcj-javafx/issues/3

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!