I have a video
in a div
with a 40% width. In the html, width="100%" height="auto"
makes the video disappear. Setting a specific size in pixels won't fit the div
. Leaving the html blank leaves the video the wrong size and with black bars on the sides.
I've tried the suggestions in most other posts, but can't seem to get it to work.
<div id="box"><video id="trialvid" class="video-js vjs-default-skin"
controls preload="auto" width="auto" height="auto" poster="images/reelthumbnail.jpg"
data-setup='{"example_option":true}'>
<source src="http://video-js.zencoder.com/oceans-clip.mp4" type='video/mp4' />
<source src="http://video-js.zencoder.com/oceans-clip.webm" type='video/webm' />
<source src="http://video-js.zencoder.com/oceans-clip.ogv" type='video/ogg' />
</video>
</div>
In version 5 of videojs you can use vjs-16-9
vjs-4-3
class on video object,
<video class="video-js vjs-default-skin vjs-16-9" ...>
...
</video>
or use fluid
option
<video class="video-js vjs-default-skin" data-setup='{"fluid": true}' ...>
...
</video>
Source: https://coolestguidesontheplanet.com/videodrome/videojs/