From cd6a0f52e22d3b940137a66c26732a5bda28b6c8 Mon Sep 17 00:00:00 2001 From: filesite Date: Tue, 16 Jul 2024 09:00:57 +0800 Subject: [PATCH] js improve --- www/js/beauty.js | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/www/js/beauty.js b/www/js/beauty.js index e523b16..4d0a511 100644 --- a/www/js/beauty.js +++ b/www/js/beauty.js @@ -229,7 +229,6 @@ if ($('#pr-player').length > 0 && typeof(videojs) != 'undefined') { var videoItem = noSnapVideos.pop(); mc_video_id = videoItem.id; - console.log(mc_video_id, videoItem.url); try { myPlayer.src(videoItem.url); myPlayer.play(); @@ -254,18 +253,20 @@ if ($('#pr-player').length > 0 && typeof(videojs) != 'undefined') { ctx.drawImage( video, 0, 0, canvas.width, canvas.height ); var snapshotImg = canvas.toDataURL('image/jpeg'); + var duration = myPlayer.duration(); //更新视频封面图和视频时长 - $('#poster_'+mc_video_id).attr('src', snapshotImg); - $('#poster_'+mc_video_id).parent('a').find('.duration').text(formatDuration(myPlayer.duration())); + if (duration && snapshotImg) { + $('#poster_'+mc_video_id).attr('src', snapshotImg); + $('#poster_'+mc_video_id).parent('a').find('.duration').text(formatDuration(duration)); + } saveVideoMeta(mc_video_id, { - duration: myPlayer.duration(), + duration: duration, snapshot: snapshotImg }); - mc_video_id = null; - + mc_video_id = ''; //reset tryToGetVideoSnapshot(); //go next } });