From 7c1b822d90a20976550cf403732aa7899f57766e Mon Sep 17 00:00:00 2001 From: filesite Date: Tue, 16 Jul 2024 08:14:18 +0800 Subject: [PATCH] improve video aspect --- www/js/beauty.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/www/js/beauty.js b/www/js/beauty.js index c42eb5e..5344b41 100644 --- a/www/js/beauty.js +++ b/www/js/beauty.js @@ -269,12 +269,13 @@ if ($('#my-player').length > 0 && typeof(videojs) != 'undefined') { myPlayer.one('play', function() { myPlayer.pause(); + var height = myPlayer.videoHeight(), width = myPlayer.videoWidth(), + aspect = height / width; var canvas = document.createElement('canvas'); var video = $('video.vjs-tech').get(0); - //360p - canvas.width = 640; - canvas.height = 360; + canvas.width = Math.ceil(360/aspect); + canvas.height = 360; //360p var ctx = canvas.getContext('2d'); ctx.drawImage( video, 0, 0, canvas.width, canvas.height );