diff --git a/src/components/VideoPlayer.vue b/src/components/VideoPlayer.vue index 40378759..8693adb8 100644 --- a/src/components/VideoPlayer.vue +++ b/src/components/VideoPlayer.vue @@ -6,7 +6,7 @@ :class="{ 'player-container': !isEmbed }" > - + 100 ? frame.frameWidth : frame.frameWidth * 2; + canvas.height = frame.frameWidth > 100 ? frame.frameHeight : frame.frameHeight * 2; // draw the thumbnail preview into the canvas by cropping only the relevant part - ctx.drawImage(originalImage, offsetX, offsetY, newWidth, newHeight, 0, 0, canvas.width, canvas.height); + ctx.drawImage( + originalImage, + offsetX, + offsetY, + frame.frameWidth, + frame.frameHeight, + 0, + 0, + canvas.width, + canvas.height, + ); // calculate the thumbnail preview offset and display it const seekbarPadding = 2; // percentage of seekbar padding @@ -727,7 +740,7 @@ export default { // ineffective algorithm to find the thumbnail corresponding to the currently hovered position in the video getFrame(position) { let startPosition = 0; - let framePage = this.video.previewFrames.at(-1); + const framePage = this.video.previewFrames.at(-1); for (let i = 0; i < framePage.urls.length; i++) { for (let positionY = 0; positionY < framePage.framesPerPageY; positionY++) { for (let positionX = 0; positionX < framePage.framesPerPageX; positionX++) { @@ -737,8 +750,8 @@ export default { url: framePage.urls[i], positionX: positionX, positionY: positionY, - framesPerPageX: framePage.framesPerPageX, - framesPerPageY: framePage.framesPerPageY, + frameWidth: framePage.frameWidth, + frameHeight: framePage.frameHeight, }; } startPosition = endPosition; @@ -750,7 +763,7 @@ export default { // creates a new image from an URL loadImage(url) { return new Promise(r => { - let i = new Image(); + const i = new Image(); i.onload = () => r(i); i.src = url; });