Advertisement
polpoteu

TIWP kolos 1.1

Jan 12th, 2021
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.53 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html>
  3. <body>
  4. <div style="text-align:center">
  5. <canvas id="canvas" style="overflow:auto"></canvas>
  6. </div>
  7. <div style="text-align:center">
  8. <button onclick="pp()">Odtwórz/Zapauzuj</button>
  9. <button onclick="zatrzymaj()">Zatrzymaj</button>
  10. <button onclick="pwp()">5sec w przód</button>
  11. <button onclick="pwt()">5sec w tył</button>
  12. <button onclick="losuj()">Losuj moment</button>
  13. <br><br>
  14. <video id="video1" width="560" autoplay><source src="http://www.w3schools.com/html/mov_bbb.mp4" type="video/mp4"></video>
  15. </div>
  16. <br>
  17. <br>
  18.  
  19.  
  20. <script>
  21. var myVideo = document.getElementById("video1");
  22. let interval = window.setInterval(capture, 1000);
  23.  
  24. myVideo.addEventListener("ended", resetVideo, false);
  25. function resetVideo() {
  26. this.src = this.src
  27. }
  28. function zatrzymaj(){
  29. myVideo.pause();
  30. myVideo.currentTime=0;
  31. }
  32. function losuj() {
  33. myVideo.currentTime = Math.random()*myVideo.duration
  34. }
  35.  
  36. function pp() {
  37. if (myVideo.paused)
  38. myVideo.play();
  39. else
  40. myVideo.pause();
  41. }
  42.  
  43. function pwp() {
  44. myVideo.currentTime += 5;
  45. }
  46.  
  47. function pwt() {
  48. myVideo.currentTime -= 5;
  49. }
  50.  
  51. function capture() {
  52. var canvas = document.getElementById('canvas');
  53. var video = document.getElementById('video1');
  54. canvas.width = video.videoWidth;
  55. canvas.height = video.videoHeight;
  56. canvas.getContext('2d').drawImage(video, 0, 0, video.videoWidth, video.videoHeight);
  57. }
  58. </script>
  59. </body>
  60. </html>
  61.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement