http
HTTP/1.1 200 OK
Content-Type: text/html
Permissions-Policy: speaker-selection=(self)
<!DOCTYPE html>
<html>
<head><title>Music Player</title></head>
<body>
<audio id="player" controls src="/music.mp3"></audio>
<select id="speakers"></select>
<script>
navigator.mediaDevices.enumerateDevices().then(devices => {
devices.filter(d => d.kind === 'audiooutput').forEach(device => {
const option = document.createElement('option');
option.value = device.deviceId;
option.text = device.label;
document.getElementById('speakers').appendChild(option);
});
});
document.getElementById('speakers').addEventListener('change', async (e) => {
const audio = document.getElementById('player');
await audio.setSinkId(e.target.value);
});
</script>
</body>
</html>