video.js
video.js copied to clipboard
Vertical video on mobile and horizontal video on desktop
Hi I was wondering which is the proper way to display a vertical video on mobile devices and an horizontal video on desktops.
Something like this:
<video id="vertical" class="video-js" preload="auto" autoplay loop muted playsinline>
<source src="video-640x720.mp4" type="video/mp4">
</video>
<video id="horizontal" class="video-js" preload="auto" autoplay loop muted playsinline>
<source src="video-1280x720.mp4" type="video/mp4">
</video>
Hi, did you find a solution to your problem?
Hello, not yet.
Loading the source conditionally is one option
const src = /* condition for mobile */ ? 'video1.mp4' : 'video2.mp4';
player.src({ src, type: 'video/mp4});
Thanks Mr. Ben, would you please share a working codepen?