简体   繁体   中英

Resize the video using vlcj

I am creating a desktop application that plays a video using vlcj. The video plays fine when added with the Jframe. But i have to play two more videos in the same frame.So i added the video player to canvas and then canvas to Jframe.The video plays well. Since i need to play two more videos, i need to resize the videos to a particular resolution.I tried to set size for the canvas but it did not work.So is there any way to resize the resolution of the video using vlcj?

Any help is appreciated?

An embedded media player should automatically resize itself to its container. So to resize the video just change the size of the video container.

It sounds like you are resizing normal containers rather than the video container.

See this link for info on an EmbeddedMediaPlayerComponent: http://caprica.github.io/vlcj/javadoc/2.1.0/

Here is an example of how to use and resize a single embedded media component.

First create the jframe as normal:

JFrame frame = new JFrame();
frame.setSize(1050, 600);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);

Now create and add the media component:

EmbeddedMediaPlayerComponent mediaPlayerComponent = new EmbeddedMediaPlayerComponent();
frame.add(mediaPlayerComponent);

Resizing the "media component":

/*Insert your code to calculate width and height here, and use below*/
mediaPlayerComponent.setSize(width, height);

And play media as normal:

 mediaPlayerComponent.getMediaPlayer().playMedia(mrl);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM