Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to play video and take screenshots dynamically by html5

2025-04-01 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

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!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 286

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report