简体   繁体   English

使用vlcj调整视频大小

[英]Resize the video using vlcj

I am creating a desktop application that plays a video using vlcj. 我正在创建一个使用vlcj播放视频的桌面应用程序。 The video plays fine when added with the Jframe. 与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. 但是我必须在同一帧中再播放两个视频。所以我将视频播放器添加到画布上,然后将画布添加到Jframe。视频播放良好。 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? 由于我需要再播放两个视频,因此需要将视频的大小调整为特定的分辨率。我尝试设置画布的大小,但没有用,是否有任何方法可以使用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/ 有关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:

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);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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