File tree Expand file tree Collapse file tree 1 file changed +36
-0
lines changed
28 - Video Speed Controller Expand file tree Collapse file tree 1 file changed +36
-0
lines changed Original file line number Diff line number Diff line change 1+ <!DOCTYPE html>
2+ < html lang ="en ">
3+ < head >
4+ < meta charset ="UTF-8 ">
5+ < title > Video Speed Scrubber</ title >
6+ < link rel ="stylesheet " href ="style.css ">
7+ </ head >
8+ < body >
9+
10+ < div class ="wrapper ">
11+ < video class ="flex " width ="765 " height ="430 " src ="https://www.dropbox.com/s/nf6jfkwck1glsyo/12%20-%20flex-wrapping-and-columns.mp4?dl=1 " loop controls > </ video >
12+ < div class ="speed ">
13+ < div class ="speed-bar "> 1×</ div >
14+ </ div >
15+ </ div >
16+
17+ < script >
18+ const speed = document . querySelector ( '.speed' )
19+ const bar = speed . querySelector ( '.speed-bar' )
20+ const video = document . querySelector ( '.flex' )
21+
22+ function handleMove ( e ) {
23+ const pct = ( e . pageY - this . offsetTop ) / this . offsetHeight
24+ const min = 0.4
25+ const max = 3
26+ const height = Math . round ( pct * 100 ) + '%'
27+ bar . style . height = height
28+ const playbackRate = ( min + ( max - min ) * pct ) . toFixed ( 1 )
29+ bar . textContent = playbackRate + 'x'
30+ video . playbackRate = playbackRate
31+ }
32+
33+ speed . addEventListener ( 'mousemove' , handleMove )
34+ </ script >
35+ </ body >
36+ </ html >
You can’t perform that action at this time.
0 commit comments