mueve selector de dispositivo al panel de admin
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -44,17 +44,6 @@
|
||||
<span class="volume-icon">🔊</span>
|
||||
</div>
|
||||
|
||||
<!-- Selector de dispositivo -->
|
||||
<div class="device-section">
|
||||
<label class="section-label">Dispositivo</label>
|
||||
<div class="device-row">
|
||||
<select id="device-select" class="select" onchange="setDevice(this.value)">
|
||||
<option value="">Cargando dispositivos...</option>
|
||||
</select>
|
||||
<button class="btn-sm" onclick="loadDevices()">↻</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Playlists / Votación -->
|
||||
<div class="playlist-section">
|
||||
<div class="playlist-section-header">
|
||||
@@ -88,7 +77,6 @@
|
||||
|
||||
<script>
|
||||
let isPlaying = false;
|
||||
let currentDeviceId = null;
|
||||
let votingOpen = false;
|
||||
let myVotedPlaylistId = null;
|
||||
let cooldownRemaining = 0;
|
||||
@@ -128,8 +116,7 @@ async function fetchCurrent() {
|
||||
|
||||
async function togglePlay() {
|
||||
const endpoint = isPlaying ? '/player/pause' : '/player/play';
|
||||
const body = (!isPlaying && currentDeviceId) ? JSON.stringify({ device_id: currentDeviceId }) : '{}';
|
||||
await fetch(endpoint, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body });
|
||||
await fetch(endpoint, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: '{}' });
|
||||
setTimeout(fetchCurrent, 300);
|
||||
}
|
||||
|
||||
@@ -155,29 +142,6 @@ function setVolume(val) {
|
||||
}, 200);
|
||||
}
|
||||
|
||||
async function loadDevices() {
|
||||
const res = await fetch('/player/devices');
|
||||
const devices = await res.json();
|
||||
const sel = document.getElementById('device-select');
|
||||
sel.innerHTML = devices.length === 0
|
||||
? '<option value="">Sin dispositivos activos</option>'
|
||||
: devices.map(d => `<option value="${d.id}">${d.name} (${d.type})</option>`).join('');
|
||||
if (devices.length > 0) {
|
||||
currentDeviceId = devices[0].id;
|
||||
sel.value = currentDeviceId;
|
||||
}
|
||||
}
|
||||
|
||||
function setDevice(deviceId) {
|
||||
if (!deviceId) return;
|
||||
currentDeviceId = deviceId;
|
||||
fetch('/player/device', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ device_id: deviceId }),
|
||||
});
|
||||
}
|
||||
|
||||
async function playItem(spotifyId, spotifyType) {
|
||||
const uri = `spotify:${spotifyType}:${spotifyId}`;
|
||||
const body = {};
|
||||
@@ -186,7 +150,6 @@ async function playItem(spotifyId, spotifyType) {
|
||||
} else {
|
||||
body.context_uri = uri;
|
||||
}
|
||||
if (currentDeviceId) body.device_id = currentDeviceId;
|
||||
await fetch('/player/play', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
@@ -395,7 +358,6 @@ function closeTracksModal(event) {
|
||||
|
||||
async function playTrackFromModal(trackId) {
|
||||
const body = { uris: [`spotify:track:${trackId}`] };
|
||||
if (currentDeviceId) body.device_id = currentDeviceId;
|
||||
await fetch('/player/play', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
@@ -410,7 +372,6 @@ document.addEventListener('keydown', e => {
|
||||
if (e.key === 'Escape') closeTracksModal();
|
||||
});
|
||||
|
||||
loadDevices();
|
||||
fetchCurrent();
|
||||
fetchVotingStatus();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user