Skip to content

Commit 0f11b9a

Browse files
committed
28 finished
1 parent fcdc827 commit 0f11b9a

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

28 - Video Speed Controller/index.html

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,31 @@
99

1010
<div class="wrapper">
1111
<video class="flex" width="765" height="430" src="http://clips.vorwaerts-gmbh.de/VfE_html5.mp4" loop controls></video>
12+
<p>
1213
<div class="speed">
1314
<div class="speed-bar"></div>
1415
</div>
1516
</div>
1617

1718
<script>
19+
const speed = document.querySelector('.speed');
20+
const bar = speed.querySelector('.speed-bar');
21+
const video = document.querySelector('.flex');
22+
23+
function handleMove(e) {
24+
const y = e.pageY - this.offsetTop;
25+
const percent = y / this.offsetHeight;
26+
const min = 0.4;
27+
const max = 4;
28+
const height = Math.round(percent * 100) + '%';
29+
const playbackRate = percent * (max - min) + min;
30+
bar.style.height = height;
31+
bar.textContent = playbackRate.toFixed(2) + '×';
32+
video.playbackRate = playbackRate;
33+
}
34+
35+
speed.addEventListener('mousemove', handleMove);
36+
1837
</script>
1938
</body>
2039
</html>

0 commit comments

Comments
 (0)