import { getLibraries, getArtists, getArtistAlbums, getAlbumTracks, audioStreamUrl } from '../embyApi.js'; import { leaveParty, connectParty, addTrackToQueue } from '../party.js'; import { navigate } from '../router.js'; import { escapeHtml, formatDuration, colorForName, initialsFor } from '../tiles.js'; /** * Music half of the party route (see player.js's dispatcher). Deliberately * NOT full-viewport/theater-mode like the video player: there's no image * to declutter around, so the sidebar stays up and this renders as a * normal page - which also means "browse and add a track" can happen * inline, right here, instead of navigating away and losing player state. * * Permission model (chosen, not assumed - see session history): anyone can * add a track to the shared queue at any time; anyone can pause/resume; * skipping the current track needs a strict majority vote of currently * connected members. No host-only controls at all - see * server/src/musicQueueService.js for the full reasoning and the * server-authoritative auto-advance timer that drives this without any * single client having to be "in charge". */ export function renderMusicPlayer(root, partyId, party) { root.innerHTML = `
-
0:00 / 0:00

Rien en attente.

`; const audio = root.querySelector('#audio'); const presenceOverlay = root.querySelector('#presenceOverlay'); const trackImage = root.querySelector('#trackImage'); const trackName = root.querySelector('#trackName'); const trackArtist = root.querySelector('#trackArtist'); const playPauseBtn = root.querySelector('#playPauseBtn'); const trackPosition = root.querySelector('#trackPosition'); const voteSkipBtn = root.querySelector('#voteSkipBtn'); const queueList = root.querySelector('#queueList'); const browsePanel = root.querySelector('#browsePanel'); let conn = null; let hls = null; let currentItemId = null; let currentDurationSeconds = 0; let suppressLocalEvents = false; // avoid feeding our own correction back as a new event - same pattern as player.js let positionTicker = null; let latestMembers = []; // Same HLS pipeline as the video player (player.js's loadVideo) - Emby's // PlaybackInfo negotiation isn't video-specific, so its TranscodingUrl // for a music track just as plausibly comes back HLS-shaped, and most // browsers (everything but Safari) have no native .m3u8 support at all - // an