fix: MiniPlayer restore button, seekbar updates, and UI improvements

- Removed isMiniplayerMode guards that prevented restore
- Added startPolling/stopPolling for seekbar to update properly
- Removed border-radius to fix white corners issue
- Added queue button with track count badge
- Simplified CSS to solid background color
This commit is contained in:
vicrodh committed 2026-01-12 08:19:27 -06:00
1 parent 645fe8bb4e
commit 86af410ab0
2 files changed
+106 -106

No files matched your search

+9 -41
View File
@@ -17,30 +17,12 @@ const MINIPLAYER_HEIGHT = 150;
let originalSize: PhysicalSize | null = null; let originalSize: PhysicalSize | null = null;
let originalPosition: PhysicalPosition | null = null; let originalPosition: PhysicalPosition | null = null;
let originalMaximized = false; let originalMaximized = false;
let isMiniplayerMode = false;
// Callbacks for state management
let onModeChangeCallback: ((isMini: boolean) => void) | null = null;
/**
* Set callback for mode changes
*/
export function onModeChange(callback: (isMini: boolean) => void): void {
onModeChangeCallback = callback;
}
/**
* Check if currently in miniplayer mode
*/
export function isInMiniplayerMode(): boolean {
return isMiniplayerMode;
}
/** /**
* Enter miniplayer mode - resize window and navigate to miniplayer route * Enter miniplayer mode - resize window and navigate to miniplayer route
*/ */
export async function enterMiniplayerMode(): Promise<void> { export async function enterMiniplayerMode(): Promise<void> {
if (isMiniplayerMode) return; console.log('[MiniPlayer] Entering miniplayer mode...');
try { try {
const window = getCurrentWindow(); const window = getCurrentWindow();
@@ -50,7 +32,7 @@ export async function enterMiniplayerMode(): Promise<void> {
originalSize = await window.innerSize(); originalSize = await window.innerSize();
originalPosition = await window.innerPosition(); originalPosition = await window.innerPosition();
console.log('[MiniPlayer] Saving original state:', { console.log('[MiniPlayer] Saved original state:', {
size: originalSize, size: originalSize,
position: originalPosition, position: originalPosition,
maximized: originalMaximized maximized: originalMaximized
@@ -70,9 +52,6 @@ export async function enterMiniplayerMode(): Promise<void> {
// Navigate to miniplayer route // Navigate to miniplayer route
await goto('/miniplayer'); await goto('/miniplayer');
isMiniplayerMode = true;
onModeChangeCallback?.(true);
console.log('[MiniPlayer] Entered miniplayer mode'); console.log('[MiniPlayer] Entered miniplayer mode');
} catch (err) { } catch (err) {
console.error('[MiniPlayer] Failed to enter miniplayer mode:', err); console.error('[MiniPlayer] Failed to enter miniplayer mode:', err);
@@ -83,63 +62,52 @@ export async function enterMiniplayerMode(): Promise<void> {
* Exit miniplayer mode - restore original window state * Exit miniplayer mode - restore original window state
*/ */
export async function exitMiniplayerMode(): Promise<void> { export async function exitMiniplayerMode(): Promise<void> {
if (!isMiniplayerMode) return; console.log('[MiniPlayer] Exiting miniplayer mode...');
console.log('[MiniPlayer] Original state:', { originalSize, originalPosition, originalMaximized });
try { try {
const window = getCurrentWindow(); const window = getCurrentWindow();
// Restore window properties // Restore window properties first
await window.setAlwaysOnTop(false); await window.setAlwaysOnTop(false);
await window.setDecorations(true); await window.setDecorations(true);
await window.setResizable(true); await window.setResizable(true);
// Restore size // Restore size
if (originalSize) { if (originalSize) {
console.log('[MiniPlayer] Restoring size:', originalSize);
await window.setSize({ type: 'Physical', width: originalSize.width, height: originalSize.height }); await window.setSize({ type: 'Physical', width: originalSize.width, height: originalSize.height });
} else { } else {
// Fallback to default size // Fallback to default size
console.log('[MiniPlayer] No original size, using default');
await window.setSize({ type: 'Physical', width: 1280, height: 800 }); await window.setSize({ type: 'Physical', width: 1280, height: 800 });
} }
// Restore position // Restore position
if (originalPosition) { if (originalPosition) {
console.log('[MiniPlayer] Restoring position:', originalPosition);
await window.setPosition({ type: 'Physical', x: originalPosition.x, y: originalPosition.y }); await window.setPosition({ type: 'Physical', x: originalPosition.x, y: originalPosition.y });
} }
// Restore maximized state // Restore maximized state
if (originalMaximized) { if (originalMaximized) {
console.log('[MiniPlayer] Restoring maximized state');
await window.maximize(); await window.maximize();
} }
// Navigate back to main // Navigate back to main
await goto('/'); await goto('/');
isMiniplayerMode = false;
onModeChangeCallback?.(false);
console.log('[MiniPlayer] Exited miniplayer mode'); console.log('[MiniPlayer] Exited miniplayer mode');
} catch (err) { } catch (err) {
console.error('[MiniPlayer] Failed to exit miniplayer mode:', err); console.error('[MiniPlayer] Failed to exit miniplayer mode:', err);
} }
} }
/**
* Toggle between normal and miniplayer modes
*/
export async function toggleMiniplayerMode(): Promise<void> {
if (isMiniplayerMode) {
await exitMiniplayerMode();
} else {
await enterMiniplayerMode();
}
}
/** /**
* Set miniplayer always on top * Set miniplayer always on top
*/ */
export async function setMiniplayerAlwaysOnTop(alwaysOnTop: boolean): Promise<void> { export async function setMiniplayerAlwaysOnTop(alwaysOnTop: boolean): Promise<void> {
if (!isMiniplayerMode) return;
try { try {
const window = getCurrentWindow(); const window = getCurrentWindow();
await window.setAlwaysOnTop(alwaysOnTop); await window.setAlwaysOnTop(alwaysOnTop);
+97 -65
View File
@@ -15,7 +15,8 @@
Maximize2, Maximize2,
Volume2, Volume2,
VolumeX, VolumeX,
Volume1 Volume1,
ListMusic
} from 'lucide-svelte'; } from 'lucide-svelte';
import { import {
subscribe as subscribePlayer, subscribe as subscribePlayer,
@@ -23,6 +24,8 @@
togglePlay, togglePlay,
seek as playerSeek, seek as playerSeek,
setVolume as playerSetVolume, setVolume as playerSetVolume,
startPolling,
stopPolling,
type PlayerState type PlayerState
} from '$lib/stores/playerStore'; } from '$lib/stores/playerStore';
import { import {
@@ -44,6 +47,7 @@
let isDragging = $state(false); let isDragging = $state(false);
let isDraggingProgress = $state(false); let isDraggingProgress = $state(false);
let isDraggingVolume = $state(false); let isDraggingVolume = $state(false);
let queueCount = $state(0);
// Refs // Refs
let progressRef: HTMLDivElement; let progressRef: HTMLDivElement;
@@ -51,7 +55,6 @@
// Derived state // Derived state
const progress = $derived(playerState.duration > 0 ? (playerState.currentTime / playerState.duration) * 100 : 0); const progress = $derived(playerState.duration > 0 ? (playerState.currentTime / playerState.duration) * 100 : 0);
const hasTrack = $derived(playerState.currentTrack !== null);
function formatTime(seconds: number): string { function formatTime(seconds: number): string {
const mins = Math.floor(seconds / 60); const mins = Math.floor(seconds / 60);
@@ -63,7 +66,12 @@
let unsubscribePlayer: (() => void) | null = null; let unsubscribePlayer: (() => void) | null = null;
let unsubscribeQueue: (() => void) | null = null; let unsubscribeQueue: (() => void) | null = null;
onMount(() => { onMount(async () => {
console.log('[MiniPlayer] Mounting, starting polling...');
// Start listening for playback events
await startPolling();
// Subscribe to player state // Subscribe to player state
unsubscribePlayer = subscribePlayer(() => { unsubscribePlayer = subscribePlayer(() => {
playerState = getPlayerState(); playerState = getPlayerState();
@@ -74,17 +82,21 @@
const qState = getQueueState(); const qState = getQueueState();
isShuffle = qState.isShuffle; isShuffle = qState.isShuffle;
repeatMode = qState.repeatMode; repeatMode = qState.repeatMode;
queueCount = qState.tracks.length;
}); });
// Initial queue state // Initial state
const qState = getQueueState(); const qState = getQueueState();
isShuffle = qState.isShuffle; isShuffle = qState.isShuffle;
repeatMode = qState.repeatMode; repeatMode = qState.repeatMode;
queueCount = qState.tracks.length;
}); });
onDestroy(() => { onDestroy(() => {
console.log('[MiniPlayer] Unmounting, stopping polling...');
unsubscribePlayer?.(); unsubscribePlayer?.();
unsubscribeQueue?.(); unsubscribeQueue?.();
stopPolling();
}); });
// Playback controls // Playback controls
@@ -187,6 +199,7 @@
// Window controls // Window controls
async function handleRestore(): Promise<void> { async function handleRestore(): Promise<void> {
console.log('[MiniPlayer] Restore button clicked');
await exitMiniplayerMode(); await exitMiniplayerMode();
} }
@@ -206,6 +219,12 @@
isDragging = false; isDragging = false;
} }
} }
// Queue info (placeholder - will open queue panel later)
function handleOpenQueue(): void {
console.log('[MiniPlayer] Queue button clicked, tracks:', queueCount);
// TODO: Open queue panel or switch to expanded mode
}
</script> </script>
<div <div
@@ -311,8 +330,19 @@
</button> </button>
</div> </div>
<!-- Volume Control --> <!-- Right Controls: Queue + Volume -->
<div class="volume-control"> <div class="right-controls">
<button
class="control-btn small"
onclick={handleOpenQueue}
title="Queue ({queueCount} tracks)"
>
<ListMusic size={14} />
{#if queueCount > 0}
<span class="queue-badge">{queueCount > 99 ? '99+' : queueCount}</span>
{/if}
</button>
<button class="control-btn small" onclick={handleMuteToggle} title={playerState.volume === 0 ? 'Unmute' : 'Mute'}> <button class="control-btn small" onclick={handleMuteToggle} title={playerState.volume === 0 ? 'Unmute' : 'Mute'}>
{#if playerState.volume === 0} {#if playerState.volume === 0}
<VolumeX size={14} /> <VolumeX size={14} />
@@ -343,24 +373,14 @@
</div> </div>
<style> <style>
:global(body) {
margin: 0;
padding: 0;
background: transparent;
overflow: hidden;
}
.miniplayer { .miniplayer {
display: flex; display: flex;
width: 100%; width: 100%;
height: 100%; height: 100%;
background: linear-gradient(135deg, #1a1a1f 0%, #252530 100%); background: #18181b;
border-radius: 12px;
color: white; color: white;
user-select: none; user-select: none;
overflow: hidden; overflow: hidden;
box-shadow: 0 8px 32px rgba(0, 0, 0, 0.6);
border: 1px solid rgba(255, 255, 255, 0.08);
} }
.miniplayer.dragging { .miniplayer.dragging {
@@ -374,6 +394,7 @@
flex-shrink: 0; flex-shrink: 0;
cursor: grab; cursor: grab;
position: relative; position: relative;
background: #0f0f11;
} }
.artwork-section:active { .artwork-section:active {
@@ -384,18 +405,16 @@
width: 100%; width: 100%;
height: 100%; height: 100%;
object-fit: cover; object-fit: cover;
border-radius: 12px 0 0 12px;
} }
.artwork-placeholder { .artwork-placeholder {
width: 100%; width: 100%;
height: 100%; height: 100%;
background: linear-gradient(135deg, #2a2a35 0%, #1f1f28 100%); background: linear-gradient(135deg, #27272a 0%, #18181b 100%);
display: flex; display: flex;
align-items: center; align-items: center;
justify-content: center; justify-content: center;
color: rgba(255, 255, 255, 0.3); color: rgba(255, 255, 255, 0.3);
border-radius: 12px 0 0 12px;
} }
/* Content Section */ /* Content Section */
@@ -403,7 +422,7 @@
flex: 1; flex: 1;
display: flex; display: flex;
flex-direction: column; flex-direction: column;
padding: 12px 16px; padding: 12px 14px;
min-width: 0; min-width: 0;
} }
@@ -412,7 +431,7 @@
display: flex; display: flex;
justify-content: space-between; justify-content: space-between;
align-items: flex-start; align-items: flex-start;
margin-bottom: 8px; margin-bottom: 6px;
cursor: grab; cursor: grab;
} }
@@ -428,7 +447,7 @@
.title { .title {
font-weight: 600; font-weight: 600;
font-size: 14px; font-size: 13px;
white-space: nowrap; white-space: nowrap;
overflow: hidden; overflow: hidden;
text-overflow: ellipsis; text-overflow: ellipsis;
@@ -437,12 +456,12 @@
} }
.artist { .artist {
font-size: 12px; font-size: 11px;
color: rgba(255, 255, 255, 0.6); color: rgba(255, 255, 255, 0.5);
white-space: nowrap; white-space: nowrap;
overflow: hidden; overflow: hidden;
text-overflow: ellipsis; text-overflow: ellipsis;
margin-top: 2px; margin-top: 1px;
} }
.window-controls { .window-controls {
@@ -456,24 +475,24 @@
display: flex; display: flex;
align-items: center; align-items: center;
justify-content: center; justify-content: center;
width: 24px; width: 22px;
height: 24px; height: 22px;
background: rgba(255, 255, 255, 0.08); background: rgba(255, 255, 255, 0.06);
border: none; border: none;
color: rgba(255, 255, 255, 0.6); color: rgba(255, 255, 255, 0.5);
cursor: pointer; cursor: pointer;
border-radius: 6px; border-radius: 4px;
transition: all 0.15s ease; transition: all 0.15s ease;
} }
.window-btn:hover { .window-btn:hover {
background: rgba(255, 255, 255, 0.15); background: rgba(255, 255, 255, 0.12);
color: rgba(255, 255, 255, 0.9); color: rgba(255, 255, 255, 0.9);
} }
.window-btn.restore:hover { .window-btn.restore:hover {
background: rgba(99, 102, 241, 0.3); background: rgba(99, 102, 241, 0.25);
color: #818cf8; color: #a5b4fc;
} }
/* Progress Section */ /* Progress Section */
@@ -481,15 +500,15 @@
display: flex; display: flex;
align-items: center; align-items: center;
gap: 8px; gap: 8px;
margin-bottom: 10px; margin-bottom: 8px;
} }
.time { .time {
font-size: 10px; font-size: 10px;
font-family: var(--font-mono, monospace); font-family: var(--font-mono, monospace);
font-variant-numeric: tabular-nums; font-variant-numeric: tabular-nums;
color: rgba(255, 255, 255, 0.5); color: rgba(255, 255, 255, 0.4);
min-width: 32px; min-width: 30px;
} }
.time.remaining { .time.remaining {
@@ -498,7 +517,7 @@
.progress-bar { .progress-bar {
flex: 1; flex: 1;
height: 20px; height: 16px;
display: flex; display: flex;
align-items: center; align-items: center;
cursor: pointer; cursor: pointer;
@@ -508,14 +527,14 @@
.progress-track { .progress-track {
width: 100%; width: 100%;
height: 3px; height: 3px;
background: rgba(255, 255, 255, 0.15); background: rgba(255, 255, 255, 0.1);
border-radius: 2px; border-radius: 2px;
overflow: hidden; overflow: hidden;
} }
.progress-fill { .progress-fill {
height: 100%; height: 100%;
background: linear-gradient(90deg, #6366f1 0%, #818cf8 100%); background: #6366f1;
border-radius: 2px; border-radius: 2px;
transition: width 100ms linear; transition: width 100ms linear;
} }
@@ -530,17 +549,13 @@
transform: translate(-50%, -50%); transform: translate(-50%, -50%);
opacity: 0; opacity: 0;
transition: opacity 150ms ease; transition: opacity 150ms ease;
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3); box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
} }
.progress-bar:hover .progress-thumb { .progress-bar:hover .progress-thumb {
opacity: 1; opacity: 1;
} }
.progress-bar:hover .progress-track {
height: 4px;
}
/* Controls Row */ /* Controls Row */
.controls-row { .controls-row {
display: flex; display: flex;
@@ -549,6 +564,12 @@
} }
.playback-controls { .playback-controls {
display: flex;
align-items: center;
gap: 2px;
}
.right-controls {
display: flex; display: flex;
align-items: center; align-items: center;
gap: 4px; gap: 4px;
@@ -558,18 +579,19 @@
display: flex; display: flex;
align-items: center; align-items: center;
justify-content: center; justify-content: center;
width: 32px; width: 30px;
height: 32px; height: 30px;
background: transparent; background: transparent;
border: none; border: none;
color: rgba(255, 255, 255, 0.8); color: rgba(255, 255, 255, 0.7);
cursor: pointer; cursor: pointer;
border-radius: 50%; border-radius: 50%;
transition: all 0.15s ease; transition: all 0.15s ease;
position: relative;
} }
.control-btn:hover { .control-btn:hover {
background: rgba(255, 255, 255, 0.1); background: rgba(255, 255, 255, 0.08);
color: #fff; color: #fff;
} }
@@ -587,27 +609,37 @@
} }
.control-btn.play { .control-btn.play {
width: 38px; width: 36px;
height: 38px; height: 36px;
background: rgba(255, 255, 255, 0.12); background: rgba(255, 255, 255, 0.1);
margin: 0 4px; margin: 0 2px;
} }
.control-btn.play:hover { .control-btn.play:hover {
background: rgba(255, 255, 255, 0.2); background: rgba(255, 255, 255, 0.18);
transform: scale(1.05); }
.queue-badge {
position: absolute;
top: 0;
right: 0;
min-width: 14px;
height: 14px;
padding: 0 3px;
font-size: 9px;
font-weight: 600;
background: #6366f1;
color: white;
border-radius: 7px;
display: flex;
align-items: center;
justify-content: center;
} }
/* Volume Control */ /* Volume Control */
.volume-control {
display: flex;
align-items: center;
gap: 6px;
}
.volume-slider { .volume-slider {
width: 60px; width: 50px;
height: 20px; height: 16px;
display: flex; display: flex;
align-items: center; align-items: center;
cursor: pointer; cursor: pointer;
@@ -617,14 +649,14 @@
.volume-track { .volume-track {
width: 100%; width: 100%;
height: 3px; height: 3px;
background: rgba(255, 255, 255, 0.15); background: rgba(255, 255, 255, 0.1);
border-radius: 2px; border-radius: 2px;
overflow: hidden; overflow: hidden;
} }
.volume-fill { .volume-fill {
height: 100%; height: 100%;
background: rgba(255, 255, 255, 0.6); background: rgba(255, 255, 255, 0.5);
border-radius: 2px; border-radius: 2px;
} }