1 回答
慕容708150
TA贡献1831条经验 获得超4个赞
截取页面可以试试html2canvas,但是这个也不算真正的“截”取,毕竟自定义性太差,
截取video的,你试试:
<video width="400" height="300" id="video" src="//video-source-url"></video>
<img width="400" height="300" id="image" />
<button id="button">截图</button>
var video = document.querySelectorAll('#video')
var image = document.querySelectorAll('#image')
var button = document.querySelectorAll('#button')
var canvas = document.createElement('canvas')
canvas.width = 400
canvas.height = 300
var canvasContext = canvas.getContext('2d')
button.onclick = function () {
canvasContext.drawImage(video, 0, 0, 400, 300)
image.src = canvas.toDataURL('image/jpeg')
}
添加回答
举报
0/150
提交
取消