Forum Academy Marketplace Showcase Pricing Features

Adjust the height of Video.js plugin accordingly to a fixed width

Hi,

I found the free Video.js plugin created by @no-code-co. Unfortunately, it came without the option that adjusts the height to maintain the aspect ratio of the video. Through the research and the tests that I have done, I have to play with the dimension of the canvas. So my question is how?

plugin code page

Thank you in advance,

Hi,
Talking about my latest progress, I found a method to change the dimensions of the canvas using the plugin editor. First I assigned an ID attribute to the element (canva in my case), then inside the plugin editor, I add these lines to the update tab with a height of 200px. such a twisted method but it works.

instance.data.obj =$("#" + "canva"); 
 //   *** height of objects ***
instance.data.obj.innerHeight(200);

my problem now is how to get the height of the video?
Any advice and suggestions will be greatly appreciated. Thank you in advance,


I believe videoJS has a method to return the actual video height.
If you’re recording the element ID then you can run a line like this to grab the height…

videojs.players.videoElement_69978.videoHeight();

Or maybe enabling Fluid mode or even setting the object-fit CSS property will overflow the video to fill the container perhaps.