Skip to Main Content

Java SE (Java Platform, Standard Edition)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Embed VLC video output into a Scene Graph

948163Jul 9 2012 — edited Jul 10 2012
Hello,

I'm trying to embed a VLC player in a JavaFX 2.2 application.
For that I'm using the libvlc.dll library's API.

VLC provided two ways to render a video:
1. Call API function that takes HWND: +libvlc_media_player_set_hwnd (libvlc_media_player_t p_mi, void drawable)+ Set a Win32/Win64 API window handle (HWND) where the media player should render its video output.
2. Register a callback that gets called every time a frame should be rendered: +libvlc_video_display_cb (void opaque, void picture) Callback prototype to display a picture.+

With the HWND approach, I managed to extract an HWND pointer of the Scene using Glass framework, causing the video to render on the whole scene, no other nodes are visible.
With the Callback approach, and by using JavaFX 2.2 new javafx.scene.canvas.Canvas node, I was able to throw pixels at the canvas, but it turns to be very inefficient in terms of memory and thread usage.

I would love to have a solution as with AWT + JNA: the HWND can be extracted from java.awt.Canvas component (using JNA), and be given to libvlc API function. This canvas can be placed anywhere in the frame, not occupying all the entire window.

Hard Guidelines:
1. Integrating AWT/Swing with FX application is not an option, I want it to be a pure JavaFX application.
2. Using JavaFX Media API for playback is not an option, since I have a requirement to modify the media player's source code.
3. The video must not occupy the entire window, allowing other components to be visible.

Possible solution is to create my own node or control that will wrap Glass component View that has a HWND but I don't know how to bind and make it work with other Glass components.

Any help would be appreciated.

Thank you.

Eli.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Aug 7 2012
Added on Jul 9 2012
4 comments
1,669 views