点击按钮对页面或者video画面截屏,能实现吗

前端能实现点击按钮对页面或者页面video画面截屏吗

有只小跳蛙
浏览 384回答 1
1回答

慕容708150

截取页面可以试试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 = 400canvas.height = 300var canvasContext = canvas.getContext('2d')button.onclick = function () {&nbsp; &nbsp; canvasContext.drawImage(video, 0, 0, 400, 300)&nbsp; &nbsp; image.src = canvas.toDataURL('image/jpeg')}
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

JavaScript