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"), }; }