File tree Expand file tree Collapse file tree 1 file changed +19
-0
lines changed
28 - Video Speed Controller Expand file tree Collapse file tree 1 file changed +19
-0
lines changed Original file line number Diff line number Diff line change 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 "> 1×</ 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 >
You can’t perform that action at this time.
0 commit comments