{#if musicPlayerConfig.enable} {#if showError}
{errorMessage}
{/if}
{#if showPlaylist}

{i18n(Key.playlist)}

{#each playlist as song, index}
playSong(index)} onkeydown={(e) => { if (e.key === 'Enter' || e.key === ' ') { e.preventDefault(); playSong(index); } }} role="button" tabindex="0" aria-label="播放 {song.title} - {song.artist}">
{#if index === currentIndex && isPlaying} {:else if index === currentIndex} {:else} {/if}
{song.title}
{song.title}
{/each}
{/if}
{ if (e.key === 'Enter' || e.key === ' ') { e.preventDefault(); toggleCollapse(); } }} role="button" tabindex="0" aria-label={i18n(Key.musicExpand)}> {#if isLoading} {:else if isPlaying}
{:else} {/if}
封面
{currentSong.title}
{currentSong.artist}
{formatTime(currentTime)} / {formatTime(duration)}
{ if (e.key === 'Enter' || e.key === ' ') { e.preventDefault(); const rect = progressBar?.getBoundingClientRect(); if (rect) { const percent = 0.5; const newTime = percent * duration; if (audio) { audio.currentTime = newTime; currentTime = newTime; } } } }} role="slider" tabindex="0" aria-label={i18n(Key.musicProgress)} aria-valuemin="0" aria-valuemax="100" aria-valuenow={duration > 0 ? (currentTime / duration * 100) : 0}>
{ if (e.key === 'Enter' || e.key === ' ') { e.preventDefault(); if (e.key === 'Enter') toggleMute(); } }} role="slider" tabindex="0" aria-label={i18n(Key.musicVolume)} aria-valuemin="0" aria-valuemax="100" aria-valuenow={volume * 100}>
{/if}