-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplayerElements.js
More file actions
33 lines (30 loc) · 1.41 KB
/
playerElements.js
File metadata and controls
33 lines (30 loc) · 1.41 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import{secondsToMinutes} from "./utils.js";
export default{
get(){
this.cover = document.querySelector(".card-image");
this.title = document.querySelector(".card-content h5");
this.artist= document.querySelector(".artist");
this.audio = document.querySelector("audio");
this.playPause = document.querySelector("#play-pause");
this.vol = document.querySelector("#vol");
this.volume = document.querySelector("#vol-control");
this.seekbar = document.querySelector("#seekbar");
this.currentDuration = document.querySelector("#current-duration")
this.totalDuration = document.querySelector("#total-duration")
},
createAudioElement(audio){
this.audio = new Audio(audio);
},
actions(){
this.audio.onended = () => this.next();
this.audio.ontimeupdate = () => this.timeUpdate();
this.playPause.onclick = () => this.togglePlayPause();
this.vol.onclick = () => this.toggleMute();
this.volume.oninput = () => this.setVolume(this.volume.value);
this.volume.onchange = () => this.setVolume(this.volume.value);
this.seekbar.onchange = () => this.setSeek(this.seekbar.value);
this.seekbar.onchange = () => this.setSeek(this.seekbar.value);
this.seekbar.max = this.audio.duration;
this.totalDuration.innerText = secondsToMinutes(this.audio.duration);
}
};