videojs-seek-buttons | videojs plugin which adds buttons to seek forward or back n seconds | Plugin library
kandi X-RAY | videojs-seek-buttons Summary
kandi X-RAY | videojs-seek-buttons Summary
video.js plugin which adds buttons to seek forward or back n seconds
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of videojs-seek-buttons
videojs-seek-buttons Key Features
videojs-seek-buttons Examples and Code Snippets
Community Discussions
Trending Discussions on videojs-seek-buttons
QUESTION
So I am trying to overlay a HTML canvas element over a 500x500 video. I always want the video to be 500x500. In my code, I've set the canvas height and width to be the same as the video height and width so they overlay right on top of one another. Unfortunately, whenever I run this, the canvas element always outputs a width of 800 and a height of 600. I believe this may have something to do with the size of the original video. However, I'm really not sure why my canvas elements won't pick up on those values. I also tried directly setting my canvas height and width to 500 but when I do that it won't overlay right on top of the video. I was just wondering if anyone knew why this might be occurring and if there is anything striking out to you in my code where I am setting these elements that is causing this to occur. I have also looked at other stack overflow posts before making this one and tried to get some context from those solutions but nothing has worked for me yet.
This is my .php file:
...ANSWER
Answered 2021-Apr-06 at 11:14I've made a demo below which shows the video element with a canvas overlay. The canvas renders the video with the same position and size as the video itself. If you Run code snippet and then Full page you'll get the best result.
To make sure that both the video and canvas are the same size, set the container to 500x500 with the video and canvas to 100% width and height.
I've use object-fit: cover;
to make the video fully expand the width and height of the container.
Now, the video might be a lot larger than 500x500, so we'll need to convert a (for example) 1920x1080 video to a 500x500 viewport. To do this we'll need to make some calculations.
We start off by calculating the shrink factor. The height of the video will be the same height of the canvas, but the width of the video must shrink the same amount of pixels to make sure that the aspect ratio of the video stays the same.
Therefor we calculate height of canvas / height of video x 100
. This gives us percentage that the video must shrink to fit the height of the canvas while keeping the right aspect ratio.
Now because the width of the video is still larger than the width of the canvas, we'll need to offset the video a bit to the left to center our video. We do this by doing (new video width - canvas width) / 2
. This is the number in pixels the video needs to move left.
Use these values to draw the video in canvas element with the right dimensions.
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install videojs-seek-buttons
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page