1
1
function switchPlayAndPause ( ) {
2
- const ctrl = document . querySelector ( '.player__button' ) ;
2
+ const ctrl = document . querySelector ( '.player__button[title="Toggle Play"] ' ) ;
3
3
4
4
if ( video_application . paused ) {
5
5
video_application . play ( ) ;
@@ -17,7 +17,7 @@ const video_application = document.querySelector('.player__video');
17
17
video_application . addEventListener ( 'click' , switchPlayAndPause ) ;
18
18
19
19
//play button
20
- const play_or_pause_ctrl = document . querySelector ( '.player__button' ) ;
20
+ const play_or_pause_ctrl = document . querySelector ( '.player__button[title="Toggle Play"] ' ) ;
21
21
play_or_pause_ctrl . addEventListener ( 'click' , switchPlayAndPause ) ;
22
22
23
23
//process
@@ -40,12 +40,12 @@ video_application.setProcess = function (percen_num) {
40
40
// initial process
41
41
const process = document . querySelector ( '.progress__filled' ) ;
42
42
process . style . flexBasis = '0%' ;
43
+ video_application . currentTime = 0 ;
43
44
44
45
//show
45
46
setInterval ( function ( ) {
46
47
let process_watched = document . querySelector ( '.progress__filled' ) ;
47
48
process_watched . style . flexBasis = video_application . getProcess ( ) ;
48
- console . log ( 'currentTime: ' , video_application . getProcess ( ) ) ;
49
49
} , 1000 ) ;
50
50
51
51
//change
@@ -58,16 +58,37 @@ function changeProcess(e) {
58
58
59
59
const process_all = document . querySelector ( '.progress' ) ;
60
60
process_all . addEventListener ( 'click' , changeProcess ) ;
61
- // process_all.addEventListener('mousemove', changeProcess);
62
61
63
62
64
- //volume
63
+ //range ctrl
64
+ function changeRange ( ) {
65
+ video_application [ this . name ] = this . value ;
66
+ }
65
67
66
68
// initial volume
67
- function changeVolume ( ) {
68
- console . log ( video_application . volume ) ;
69
- }
70
- const volume_ctrl = document . querySelector ( 'input[name=volume]' ) ;
71
- volume_ctrl . value = 0 ;
72
- volume_ctrl . addEventListener ( 'change' , changeVolume ) ;
73
- volume_ctrl . addEventListener ( 'mousemove' , changeVolume ) ;
69
+ video_application . volume = 0.5 ;
70
+ // initial playbackRate
71
+ video_application . playbackRate = 1 ;
72
+ // playbackRate
73
+ const range_ctrls = document . querySelectorAll ( '.player__slider' ) ;
74
+ range_ctrls . forEach ( ctrl => {
75
+ ctrl . addEventListener ( 'change' , changeRange ) ;
76
+ ctrl . addEventListener ( 'mousemove' , changeRange ) ;
77
+ } ) ;
78
+
79
+ //player__button add 10s
80
+ const jump_sec_ctrls = document . querySelectorAll ( '.player__button' ) ;
81
+ jump_sec_ctrls . forEach ( ctrl => {
82
+ ctrl . addEventListener ( 'click' , ( ) => {
83
+ if ( ! ctrl . title ) {
84
+ const newTime = video_application . currentTime + Number ( ctrl . dataset . skip ) ;
85
+ // const str = `currentTime: ${video_application.currentTime} + ctrl.dataset.skip: ${Number(ctrl.dataset.skip)} = ${newTime}`;
86
+ // console.log(str);
87
+ video_application . currentTime = newTime ;
88
+ }
89
+ } ) ;
90
+ } ) ;
91
+
92
+ // setInterval(() => {
93
+ // console.log(video_application.currentTime);
94
+ // }, 1000);
0 commit comments