mac os jdk 1.8 problems vlc control JAWT not load

故事扮演 提交于 2019-12-31 02:55:14

问题


JavaVM WARNING: JAWT_GetAWT must be called after loading a JVM
Exception in thread "AWT-EventQueue-0" java.lang.UnsatisfiedLinkError: Can't load JAWT
    at com.sun.jna.Native.getWindowHandle0(Native Method)
    at com.sun.jna.Native$AWT.getComponentID(Native.java:1879)
    at com.sun.jna.Native.getComponentID(Native.java:253)
    at uk.co.caprica.vlcj.player.embedded.videosurface.CanvasVideoSurface.attach(CanvasVideoSurface.java:69)
    at uk.co.caprica.vlcj.player.embedded.DefaultEmbeddedMediaPlayer.attachVideoSurface(DefaultEmbeddedMediaPlayer.java:156)
    at uk.co.caprica.vlcj.player.embedded.DefaultEmbeddedMediaPlayer.onBeforePlay(DefaultEmbeddedMediaPlayer.java:315)
    at uk.co.caprica.vlcj.player.DefaultMediaPlayer.play(DefaultMediaPlayer.java:705)
    at uk.co.caprica.vlcj.player.DefaultMediaPlayer.playMedia(DefaultMediaPlayer.java:222)
    at viziosecure360.Travizia.AddPlayer(Travizia.java:675)
    at viziosecure360.Travizia.setDefault(Travizia.java:234)
    at viziosecure360.Travizia$1.run(Travizia.java:187)
    at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:311)
    at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:744)
    at java.awt.EventQueue.access$400(EventQueue.java:97)
    at java.awt.EventQueue$3.run(EventQueue.java:697)
    at java.awt.EventQueue$3.run(EventQueue.java:691)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:75)
    at java.awt.EventQueue.dispatchEvent(EventQueue.java:714)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:201)
    at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
    at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)

回答1:


vlcj/LibVLC requires a heavyweight AWT component to render its video.

There is no longer any AWT in JDK 1.7 and later on OSX. The UI toolkit on OSX is now fully lightweight.

So the optimal way of using vlcj on OSX no longer works.

What you have to do is use the so-called "direct" media player [1] rather than the "embedded" one.

The downside to using the direct media player is that you have to render the video yourself somehow, using a BufferedImage, a hardware accelerated volatile image, a PixelWriter or something else.

This approach typically uses more memory and more CPU, and is a bit more inconvenient.

On the plus side, it is possible to achieve smooth HD video playback using this method.

Also on the plus side, you can process the video buffer in some way if you want, and easily overlay lightweight widgets/labels on top of the video using this approach.

There is an example provided in the vlcj test sources that shows one way how to do this (there is too much code to reproduce here so I'll provide a stable link [2]).

There is also a long discussion in the project issue tracker [3] on this subject.

[1] http://caprica.github.io/vlcj/javadoc/3.0.0/uk/co/caprica/vlcj/player/direct/DirectMediaPlayer.html

[2] https://github.com/caprica/vlcj/blob/vlcj-3.0.1/src/test/java/uk/co/caprica/vlcj/test/direct/DirectTestPlayer.java

[3] https://github.com/caprica/vlcj/issues/205

Amazingly there's a potential, though clearly sub-optimal, solution which is to use a Windows 1.7/1.8 JVM on OSX using Wine. I have not tried it but I have been told it works.



来源:https://stackoverflow.com/questions/25638820/mac-os-jdk-1-8-problems-vlc-control-jawt-not-load

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