-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplay-button.js
38 lines (29 loc) · 909 Bytes
/
play-button.js
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
34
35
36
37
38
// This class will represent the play button in the MusicScreen. Clicking on
// it toggles audio playback.
//
// See HW4 writeup for more hints and details.
class PlayButton {
constructor(container) {
// TODO(you): Implement the constructor and add fields as necessary.
this.container = container;
}
// TODO(you): Add methods as necessary.
createPlayButton(){
const img = document.createElement('img');
img.src = 'images/play.png';
img.style.width = '60px';
img.style.height = '60px';
img.addEventListener('click', this._playEvent);
this.container.appendChild(img);
}
toggle(playButtonImg){
if (playButtonImg.src.includes('images/pause.png')){
playButtonImg.src = 'images/play.png';
app.music.audioPlayer.play();
}
else{
playButtonImg.src = 'images/pause.png';
app.music.audioPlayer.pause();
}
}
}