caprica / vlcj

Java framework for the vlc media player
http://www.capricasoftware.co.uk/projects/vlcj
1.1k stars 260 forks source link

Issue: VlcJ 4 - EmbeddedMediaPlayerComponent black when moving between components #1185

Closed lov3b closed 1 year ago

lov3b commented 1 year ago

Hello!

Firstly, I would like to thank you for developing the VlcJ 4 library. I have been using it and it has been working like a charm.

I have however encountered a problem that I would like to bring to your attention. I am embedding Vlc in a JPane that is in a JTabbedPane. I noticed that when I use JTabbedPane.setVisable(false), it leaves an empty void of everything it displayed. I assumed that hiding the JTabbedPane would hide all its tabs, including active ones.

To troubleshoot the issue, I tried moving the EmbeddedMediaPlayerComponent to a new JFrame that I then put in fullscreen. Unfortunately, it did not work. Apparently, when moving the EmbeddedMediaPlayerComponent from one Component to another, it becomes black, which appears to be true for all Components. It seems that you cannot move them between JFrames.

I am writing to ask if any of you have encountered this issue before and if you have any ideas on how to solve it. I would greatly appreciate your insights and suggestions as I do not have any more ideas.

Thank you very much for your time and for creating this amazing library.

Best regards, Love

caprica commented 1 year ago

This is a limitation of the native library, you can not "reparent" a media player to a new component. After you move the component you would have to set the video surface again, and you can NOT set the video surface again until you stop/play the media player again.

That is clearly not optimal.

What you can do is come up with some way to hide the panel other than doing setVisible(false).

It depends how exactly you want to hide the video palyer.

Some ideas:

So there is no nice solution here, everything is a compromise.

Again, it comes down to what are you actually trying to achieve by hiding the video player.

lov3b commented 1 year ago

Thanks for getting back to me so quickly. It sounds like you understood what I was trying to accomplish. Basically, I have a tabbed user interface with a media player located in one of the tabs. My goal is to allow the user to search for movies in one tab and then easily switch to the media player tab to start playing the selected movie without any interruption.

I appreciate the ideas you suggested, and I'll definitely give them a try. I'll go through them and choose the one that seems to be the most efficient.

I have just one sidequestion. Is there some internal API that is possible to use from the outside, where you can manually draw the images from VLC, and rewire it between JFrames or perhaps move it out of the JTabbedPane?

caprica commented 1 year ago

There is no "internal" API.

But, you can manually render the frames from VLC when you use the "direct" rendering media player, using the CallbackMediaPlayer or CallbackMediaPlayerComponent.

This is effectively software rendering, so will take more CPU than the normal EmbeddedMediaPlayer, and it might not be possible to play 4k 60FPS video this way due to the required bandwidth.

On the other hand, this would be the recommended approach if you use JavaFX and PixelBuffer, the PixelBuffer approach is probably the best performance you can achieve without hardware rendering.

lov3b commented 1 year ago

Okay, thanks for the help!