Changeset 73cffc3 in Klonkt for src/assets/js/audio-player.js
- Timestamp:
- 06/28/2026 10:47:29 AM (2 months ago)
- Branches:
- main
- Children:
- 2eca083
- Parents:
- 515cf1a
- File:
-
- 1 edited
-
src/assets/js/audio-player.js (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
src/assets/js/audio-player.js
r515cf1a r73cffc3 560 560 attachSeek(sheetSeek); 561 561 562 audio.volume = 0.8; 562 // Volume + mute persist across sessions/pages via localStorage. 563 const VOL_KEY = 'pcmsVolume', MUTE_KEY = 'pcmsMuted'; 564 const saveVol = () => { try { localStorage.setItem(VOL_KEY, String(audio.volume)); localStorage.setItem(MUTE_KEY, audio.muted ? '1' : '0'); } catch (e) { /* private mode */ } }; 565 let _initVol = parseFloat(localStorage.getItem(VOL_KEY)); 566 if (!isFinite(_initVol) || _initVol < 0 || _initVol > 1) _initVol = 0.8; 567 audio.volume = _initVol; 568 volumeSlider.value = Math.round(_initVol * 100); 569 if (localStorage.getItem(MUTE_KEY) === '1') audio.muted = true; 570 root.classList.toggle('is-muted', audio.muted || audio.volume === 0); 563 571 volumeSlider.addEventListener('input', () => { 564 572 audio.volume = volumeSlider.value / 100; 565 573 if (volumeSlider.value > 0) audio.muted = false; 566 }); 567 muteBtn.addEventListener('click', () => { audio.muted = !audio.muted; }); 574 saveVol(); 575 }); 576 muteBtn.addEventListener('click', () => { audio.muted = !audio.muted; saveVol(); }); 568 577 569 578 // ============================================================
Note:
See TracChangeset
for help on using the changeset viewer.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)