The mobile terminal uses canvas to capture the video cover, how to intercept the other frames instead of the first frame?

the screenshot I took in Wechat"s development tool is OK, but the screenshot on the phone has become completely transparent.
I guess it"s the first frame of the video
screenshot of Wechat"s development tool


my code:
JS:

function captureImage(video) {
                var scale=1
                var canvas = document.createElement("canvas");
                
                var vw=$(video).width()
                var vh=$(video).height()
                console.log(vw,vh)
                canvas.width = vw* scale;
                canvas.height =  vh* scale;
                canvas.getContext("2d").drawImage(video, 0, 0, canvas.width, canvas.height);
    
                var img = document.createElement("img");
                img.className="poster"
                img.src = canvas.toDataURL("image/png");
                $(video).prop("poster",canvas.toDataURL("image/png"))
        };

HTML tag:

<video src="./show.mp4" class="video" onloadeddata="captureImage(this)"></video>
Mar.14,2021

if the video on the mobile phone is not played, it will not be loaded, so there is no screenshot to use. Just skip it.

learn about the restrictions on video playback on mobile phones.


poster
the URL, of a poster frame is used to display before the user plays or skips the frame. If the attribute is not specified, nothing is displayed until the first frame is available; then the first frame is displayed like a poster frame.

see ideo" rel=" nofollow noreferrer "> https://developer.mozilla.org.

<video src="./show.mp4" poster="./your-picture.png"></video>

clipboard.png

clipboard.png

Menu