MadProgrammer is right. VLCJ attaches a native video surface to a java.awt.Canvas. You can supply your own Canvas with overridden paint(..) method but that won't help. This is what happens internally on Linux in LinuxVideoSurfaceAdapter
:
public void attach(LibVlc libvlc, MediaPlayer mediaPlayer, long componentId) {
Logger.debug("attach(componentId={})", componentId);
libvlc.libvlc_media_player_set_xwindow(mediaPlayer.mediaPlayerInstance(), (int)componentId);
}
The native java.awt.Canvas X11 window is used as a target for VLC output.
My best bet is to use the overlay mechanism like madprogrammer mentioned. Basically you'll need to supply a Window or JWindow by subclassing EmbeddedMediaPlayerComponent. As transparency is quite platform dependent you'll want to check if the desired type of transparency/transluncency is supported by your target environment (careful: complex graphics configurations might have different capabilities for each screen device!):
final boolean perPixelTranslucencySupported = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice().isWindowTranslucencySupported(WindowTranslucency.PERPIXEL_TRANSLUCENT);
Create a subclass of EmbeddedMediaPlayerComponent:
mediaPlayerComponent = new EmbeddedMediaPlayerComponent() {
@Override
protected Window onGetOverlay() {
final JWindow transparentWindow = new JWindow();
// Set basic window opacity if required - the window system must support WindowTranslucency (i.e. PERPIXEL_TRANSLUCENT)!
transparentWindow.setOpacity(0.8f);
// White with transparent alpha channel - WindowTranslucency is required for translucency.
transparentWindow.setBackground(new Color(1.0f, 1.0f, 1.0f, 0.0f));
final JLabel superImposedLightweigtLabel = new JLabel("Hello, VLC.", JLabel.CENTER);
superImposedLightweigtLabel.setOpaque(false);
transparentWindow.getContentPane().add(superImposedLightweigtLabel);
return transparentWindow;
}
...
}
After making the main JFrame visible, enable the overlay:
mediaPlayerComponent.getMediaPlayer().enableOverlay(true);
I couldn't verify the results as I am working in a virtual machine without transparency features right now so my actual JWindow overlay is NOT transparent for obvious reasons. Please let us know if it works as desired and if there are any other pitfalls.