- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to take a snapshot of HTML5-JavaScript based video player?
You can try to run the following code to take a snapshot of HTML5-JavaScript-based video player −
Example
<html> <body> <video controls> <source src = "new.mp4" type = "video/mp4"></source> </video> <canvas id = "canvas" width = "600" height = "300"></canvas> <button id = "snap" onclick = "snap()">Snapshot</button> <script> var video = document.querySelector('video'); var canvas = document.querySelector('canvas'); var context = canvas.getContext('2d'); var myWidth, myHeight, ratio; video.addEventListener('loadedmetadata', function() { ratio = video.videoWidth/video.videoHeight; myWidth = video.videoWidth-100; myHeight = parseInt(w/ratio,10); canvas.width = myWidth; canvas.height = myHeight; },false); function snap() { context.fillRect(0,0,myWidth,myHeight); context.drawImage(video,0,0,myWidth,myHeight); } </script> </body> </html>
- Related Articles
- Streaming a video file to an HTML5 video player with Node.js so that the video controls continue to work
- HTML5 video full preload in JavaScript
- Creating a responsive Video Player using Video.js\n
- Use CSS width property for a responsive video player
- Setting up a Poster for a Video in Video.js Player
- Commonly used Video formats while using HTML5 video
- Use CSS max-width property responsive for video player
- Display video inside HTML5 canvas
- Play local (hard-drive) video file with HTML5 video tag?
- Converting video to HTML5 ogg / ogv and mpg4
- HTML5 video not playing in Firefox
- How to take screenshot of a div with JavaScript
- How to get a snapshot of information about Process API in Java 9?
- Facing Problem in retrieving HTML5 video duration
- Snapshot of Agile Software Development

Advertisements