Implementation of video upload preview image on mobile terminal

make an input type=file selection video for webapp, then preview it on the page, and then upload it.

was found on the Internet.
   var objectURL = URL.createObjectURL(this.files[0]);
    $(".previewVideo").html("<video src="" +
                objectURL +
                "" controls></video>");
    setTimeout(function () {
         var scale = 0.25,
                video = $("video")[0],
                canvas = document.createElement("canvas"),
                canvasFill = canvas.getContext("2d");
            canvas.width = video.videoWidth * scale;
            canvas.height = video.videoHeight * scale;
            canvasFill.drawImage(video, 0, 0, canvas.width, canvas.height);
            var src = canvas.toDataURL("image/jpeg");
            $(".previewImg").html("<img id="imgSmallView" src="" + src + "" alt="" />");
    }, 500);
  
  pc
  

clipboard.png

clipboard.png
is there any solution? I read on the Internet that I used html2canvas to get screenshots, but I don"t know how feasible it is.

Oct.12,2021

I guess the mobile video hasn't been loaded yet, so you can't intercept the event that
listens for video to start playing, and then process the screenshot

.

video.addEventListener ('playing', function () {/ *. * /});


Hello, have you solved this finally?

Menu