mirror of
https://codeberg.org/armin/noiz.git
synced 2026-09-01 05:50:52 +02:00
feat: separate play/pause into individual buttons, add stop button
This commit is contained in:
parent
c07220e809
commit
42861dba9d
1 changed files with 16 additions and 8 deletions
22
index.html
22
index.html
|
|
@ -160,6 +160,8 @@ footer .footer-track { flex: 1; min-width: 0; white-space: nowrap; overflow: hid
|
|||
<div class="controls">
|
||||
<button id="prevBtn" title="Previous">◀◀</button>
|
||||
<button class="play-btn" id="playBtn" title="Play">▶</button>
|
||||
<button id="pauseBtn" title="Pause">▮▮</button>
|
||||
<button id="stopBtn" title="Stop">■</button>
|
||||
<button id="nextBtn" title="Next">▶▶</button>
|
||||
</div>
|
||||
<div class="volume-row">
|
||||
|
|
@ -681,6 +683,8 @@ const trackArtist = document.getElementById('trackArtist');
|
|||
const playBtn = document.getElementById('playBtn');
|
||||
const prevBtn = document.getElementById('prevBtn');
|
||||
const nextBtn = document.getElementById('nextBtn');
|
||||
const pauseBtn = document.getElementById('pauseBtn');
|
||||
const stopBtn = document.getElementById('stopBtn');
|
||||
const waveformCanvas = document.getElementById('waveform');
|
||||
const waveformWrap = document.getElementById('waveformWrap');
|
||||
const timeCurrent = document.getElementById('timeCurrent');
|
||||
|
|
@ -1471,12 +1475,8 @@ function onEnded(e) {
|
|||
}
|
||||
}
|
||||
function onPlay(e) {
|
||||
if (e.target !== audio) return;
|
||||
playBtn.innerHTML = '▮▮'; playBtn.title = 'Pause';
|
||||
}
|
||||
function onPause(e) {
|
||||
if (e.target !== audio) return;
|
||||
playBtn.innerHTML = '▶'; playBtn.title = 'Play';
|
||||
}
|
||||
audioElA.addEventListener('loadedmetadata', onLoadedmetadata);
|
||||
audioElB.addEventListener('loadedmetadata', onLoadedmetadata);
|
||||
|
|
@ -1502,12 +1502,20 @@ playBtn.addEventListener('click', () => {
|
|||
playTrack(idx);
|
||||
} else if (currentIndex < 0) {
|
||||
playTrack(0);
|
||||
} else if (audio.paused) {
|
||||
audio.play().catch(() => {});
|
||||
} else {
|
||||
audio.play().catch(() => {});
|
||||
}
|
||||
});
|
||||
pauseBtn.addEventListener('click', () => {
|
||||
if (currentIndex < 0) return;
|
||||
audio.pause();
|
||||
if (isCrossfading) audioNext.pause();
|
||||
}
|
||||
});
|
||||
stopBtn.addEventListener('click', () => {
|
||||
if (currentIndex < 0) return;
|
||||
audio.pause();
|
||||
if (isCrossfading) audioNext.pause();
|
||||
audio.currentTime = 0;
|
||||
});
|
||||
prevBtn.addEventListener('click', prevTrack);
|
||||
nextBtn.addEventListener('click', nextTrack);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue