Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html>
- <body>
- <div style="text-align:center">
- <canvas id="canvas" style="overflow:auto"></canvas>
- </div>
- <div style="text-align:center">
- <button onclick="pp()">Odtwórz/Zapauzuj</button>
- <button onclick="zatrzymaj()">Zatrzymaj</button>
- <button onclick="pwp()">5sec w przód</button>
- <button onclick="pwt()">5sec w tył</button>
- <button onclick="losuj()">Losuj moment</button>
- <br><br>
- <video id="video1" width="560" autoplay><source src="http://www.w3schools.com/html/mov_bbb.mp4" type="video/mp4"></video>
- </div>
- <br>
- <br>
- <script>
- var myVideo = document.getElementById("video1");
- let interval = window.setInterval(capture, 1000);
- myVideo.addEventListener("ended", resetVideo, false);
- function resetVideo() {
- this.src = this.src
- }
- function zatrzymaj(){
- myVideo.pause();
- myVideo.currentTime=0;
- }
- function losuj() {
- myVideo.currentTime = Math.random()*myVideo.duration
- }
- function pp() {
- if (myVideo.paused)
- myVideo.play();
- else
- myVideo.pause();
- }
- function pwp() {
- myVideo.currentTime += 5;
- }
- function pwt() {
- myVideo.currentTime -= 5;
- }
- function capture() {
- var canvas = document.getElementById('canvas');
- var video = document.getElementById('video1');
- canvas.width = video.videoWidth;
- canvas.height = video.videoHeight;
- canvas.getContext('2d').drawImage(video, 0, 0, video.videoWidth, video.videoHeight);
- }
- </script>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement