blob: 91d44946efbbff12398280742f865a91d92af2b1 (
plain)
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
39
40
41
42
43
44
45
46
47
48
49
50
51
|
import { DeckButton } from './deck-button.js';
const pressSound = new Audio("audio/button-press.mp3");
export function DeckControls(params) {
const { deck } = params;
return {
go: function () {
deck.elem.src = deck.images.go;
deck.isPlaying = true;
deck.playButton.toggle();
},
start: function () {
deck.hasStarted = true;
this.playButton.initSound.onended = (event) => { deck.cassette.play(); };
this.playButton.initSound.play();
this.go();
},
pause: function () {
this.playButton.toggle();
this.playButton.pressSound.play();
deck.cassette.pause();
deck.elem.src = deck.images.stop;
deck.isPlaying = false;
},
resume: function () {
this.playButton.pressSound.play();
this.go();
deck.cassette.play();
},
playButton: {
elem: document.getElementById("play-button"),
state: "off",
up: "images/play-button-up.jpg",
down: "images/play-button-down.jpg",
initSound: new Audio("audio/tape-start.mp3"),
pressSound: pressSound,
toggle: function () {
if (this.state === "off") {
this.elem.src = this.down;
this.state = "on";
} else {
this.elem.src = this.up;
this.state = "off";
}
}
},
ffButton: DeckButton("ff"),
rewindButton: DeckButton("rewind"),
};
}
|