File tree Expand file tree Collapse file tree 3 files changed +39
-58
lines changed
28 - Video Speed Controller Expand file tree Collapse file tree 3 files changed +39
-58
lines changed Load Diff This file was deleted.
Load Diff This file was deleted.
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 y = e . pageY - this . offsetTop ;
24
+ const percent = y / this . offsetHeight ;
25
+ const min = 0.4 ;
26
+ const max = 4 ;
27
+ const height = Math . round ( percent * 100 ) + '%' ;
28
+ const playbackRate = percent * ( max - min ) + min ;
29
+ bar . style . height = height ;
30
+ bar . textContent = playbackRate . toFixed ( 2 ) + 'x' ;
31
+ video . playbackRate = playbackRate ;
32
+ console . log ( percent ) ;
33
+ }
34
+ speed . addEventListener ( 'mousemove' , handleMove ) ;
35
+
36
+
37
+ </ script >
38
+ </ body >
39
+ </ html >
You can’t perform that action at this time.
0 commit comments