fixes for soundboard, added volume switch
This commit is contained in:
parent
1658321b67
commit
232f250aa5
@ -25,6 +25,11 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div id="sb-content" style="display:none">
|
<div id="sb-content" style="display:none">
|
||||||
|
<div class="mb-4">
|
||||||
|
<label class="form-label fw-bold">Lautstärke</label>
|
||||||
|
<input type="range" class="form-range" id="sb-volume" min="0" max="100" value="80" step="5">
|
||||||
|
<small class="text-muted">Wirkt global auf alle Soundboard-Kanäle.</small>
|
||||||
|
</div>
|
||||||
<div id="sb-backgrounds" class="mb-4"></div>
|
<div id="sb-backgrounds" class="mb-4"></div>
|
||||||
<div id="sb-sounds" class="mb-4"></div>
|
<div id="sb-sounds" class="mb-4"></div>
|
||||||
<div id="sb-random" class="mb-4"></div>
|
<div id="sb-random" class="mb-4"></div>
|
||||||
@ -44,6 +49,9 @@
|
|||||||
const content = document.getElementById('sb-content');
|
const content = document.getElementById('sb-content');
|
||||||
|
|
||||||
let currentSB = null;
|
let currentSB = null;
|
||||||
|
const statusBox = (msg, type='info') => {
|
||||||
|
console.log(msg);
|
||||||
|
};
|
||||||
|
|
||||||
async function loadSoundboard(filename) {
|
async function loadSoundboard(filename) {
|
||||||
loadBtn.disabled = true;
|
loadBtn.disabled = true;
|
||||||
@ -107,7 +115,8 @@
|
|||||||
function renderRandom(list) {
|
function renderRandom(list) {
|
||||||
const container = document.getElementById('sb-random');
|
const container = document.getElementById('sb-random');
|
||||||
if (!list.length) { container.innerHTML=''; randBtn.disabled=true; return; }
|
if (!list.length) { container.innerHTML=''; randBtn.disabled=true; return; }
|
||||||
container.innerHTML = '<p class="text-muted">Zufallspool: ' + list.length + ' Dateien, max 2x pro Stunde je Datei.</p>';
|
const items = list.map(s => `<li>${s.name || s.id || s.file}</li>`).join('');
|
||||||
|
container.innerHTML = '<h4>Zufallspool</h4><p class="text-muted">max 2x pro Stunde je Datei.</p><ul>' + items + '</ul>';
|
||||||
}
|
}
|
||||||
|
|
||||||
async function playSound(sound) {
|
async function playSound(sound) {
|
||||||
@ -122,7 +131,7 @@
|
|||||||
body: JSON.stringify(payload)
|
body: JSON.stringify(payload)
|
||||||
});
|
});
|
||||||
const data = await res.json();
|
const data = await res.json();
|
||||||
if (!data.success) alert(data.message || 'Fehler beim Abspielen');
|
if (!data.success) statusBox(data.message || 'Fehler beim Abspielen', 'warn');
|
||||||
}
|
}
|
||||||
|
|
||||||
async function stopSound(channel) {
|
async function stopSound(channel) {
|
||||||
@ -132,16 +141,29 @@
|
|||||||
body: JSON.stringify({ channel })
|
body: JSON.stringify({ channel })
|
||||||
});
|
});
|
||||||
const data = await res.json();
|
const data = await res.json();
|
||||||
if (!data.success) alert(data.message || 'Fehler beim Stoppen');
|
if (!data.success) statusBox(data.message || 'Fehler beim Stoppen', 'warn');
|
||||||
}
|
}
|
||||||
|
|
||||||
loadBtn.onclick = () => loadSoundboard(selectEl.value);
|
loadBtn.onclick = () => loadSoundboard(selectEl.value);
|
||||||
randBtn.onclick = async () => {
|
randBtn.onclick = async () => {
|
||||||
const res = await fetch('/api/soundboard/play_random', { method: 'POST' });
|
const res = await fetch('/api/soundboard/play_random', { method: 'POST' });
|
||||||
const data = await res.json();
|
const data = await res.json();
|
||||||
if (!data.success) alert(data.message || 'Random fehlgeschlagen');
|
if (!data.success) statusBox(data.message || 'Random fehlgeschlagen', 'warn');
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Lautstärke
|
||||||
|
const vol = document.getElementById('sb-volume');
|
||||||
|
if (vol) {
|
||||||
|
vol.addEventListener('input', async () => {
|
||||||
|
const v = parseInt(vol.value, 10) / 100;
|
||||||
|
await fetch('/api/set_volume', {
|
||||||
|
method: 'POST',
|
||||||
|
headers: { 'Content-Type': 'application/json' },
|
||||||
|
body: JSON.stringify({ volume: v })
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
// Autoload erstes Thema (falls vorhanden)
|
// Autoload erstes Thema (falls vorhanden)
|
||||||
if (selectEl && selectEl.value) {
|
if (selectEl && selectEl.value) {
|
||||||
loadSoundboard(selectEl.value);
|
loadSoundboard(selectEl.value);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user