Compare commits
1 Commits
main
...
dev/player
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e1991d4a12 |
@@ -8,6 +8,9 @@ document.addEventListener('DOMContentLoaded', function () {
|
||||
const playPauseBtn = document.getElementById('playPauseBtn');
|
||||
const nextBtn = document.getElementById('nextBtn');
|
||||
const prevBtn = document.getElementById('prevBtn');
|
||||
const volumeControl = document.getElementById('volumeControl');
|
||||
const savedVolume = localStorage.getItem('audioPlayerVolume');
|
||||
|
||||
|
||||
const progressBar = document.getElementById('audioProgress');
|
||||
const currentTimeElem = document.getElementById('currentTime');
|
||||
@@ -34,6 +37,17 @@ document.addEventListener('DOMContentLoaded', function () {
|
||||
if (currentTimeElem) currentTimeElem.textContent = formatTime(current || 0);
|
||||
if (durationElem) durationElem.textContent = formatTime(duration || 0);
|
||||
}
|
||||
// Восстановление сохраненного уровня громкости
|
||||
if (savedVolume !== null) {
|
||||
audioPlayer.volume = parseFloat(savedVolume);
|
||||
}
|
||||
|
||||
// Управление громкостью
|
||||
if (volumeControl) {
|
||||
volumeControl.addEventListener('input', () => {
|
||||
audioPlayer.volume = volumeControl.value;
|
||||
});
|
||||
}
|
||||
|
||||
// Обновление прогресса при воспроизведении
|
||||
audioPlayer.addEventListener('timeupdate', () => {
|
||||
|
||||
@@ -15,6 +15,16 @@
|
||||
<button class="control-btn" id="prevBtn"><i class="fas fa-backward"></i></button>
|
||||
<button class="control-btn" id="playPauseBtn"><i class="fas fa-play"></i></button>
|
||||
<button class="control-btn" id="nextBtn"><i class="fas fa-forward"></i></button>
|
||||
|
||||
<input
|
||||
type="range"
|
||||
id="volumeControl"
|
||||
min="0"
|
||||
max="1"
|
||||
step="0.01"
|
||||
value="1"
|
||||
title="Громкость"
|
||||
>
|
||||
</div>
|
||||
</div>
|
||||
<audio id="audioPlayer" class="audio-player" preload="metadata">
|
||||
|
||||
Reference in New Issue
Block a user