How to play video and take screenshots dynamically by html5
Editor to share with you how html5 can play video and take dynamic screenshots. I hope you will get something after reading this article. Let's discuss it together.
Chrom is not supported at this time. Support safari. Other untested
Reference the jquery address first. Choose Sina.
The code is as follows:
Add a video tag
The code is as follows:
And then js
The code is as follows:
Ready (function () {)
Var video, output
Var scale = 0.25
Var initialize = function () {
Output = $("# output")
Video = $("# video") .get (0)
$("# capture") .click (captureImage)
}
Var captureImage = function () {
Var canvas = document.createElement ("canvas")
Canvas.width = video.videoWidth * scale
Canvas.height = video.videoHeight * scale
Canvas.getContext ('2d')
.drawImage (video, 0,0, canvas.width, canvas.height)
Var img = document.createElement ("img")
Img.src = canvas.toDataURL ()
Output.prepend (img)
}
$(initialize)
});
After reading this article, I believe you have a certain understanding of "how to play video and dynamic screenshots in html5". If you want to know more about it, you are welcome to follow the industry information channel. Thank you for reading!