Files
spotify-gui-electron/index.html
2025-07-25 16:11:37 -07:00

229 lines
8.1 KiB
HTML
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Now Playing</title>
<style>
body {
margin: 0;
padding: 0;
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
background: #181c24;
color: #fff;
height: 100vh;
width: 100vw;
display: flex;
align-items: center;
justify-content: center;
overflow: hidden;
}
.main-container {
display: flex;
flex-direction: row;
align-items: center;
/* Remove background, border-radius, box-shadow, and padding */
/* min-width: 1600px;
max-width: 1600px; */
min-height: 400px;
gap: 80px;
position: relative;
z-index: 1;
}
.album-art {
width: 320px;
height: 320px;
border-radius: 24px;
object-fit: cover;
background: #333;
box-shadow: 0 8px 32px rgba(0,0,0,0.25);
transition: background 1s;
}
.info-section {
display: flex;
flex-direction: column;
justify-content: center;
align-items: center; /* Center content horizontally */
width: 800px; /* Fixed width for info-section */
min-width: 800px;
max-width: 800px;
word-break: break-word;
/* Remove min-width and max-width to allow full width usage */
}
.song-title {
font-size: 3.2rem;
font-weight: 700;
margin-bottom: 2px;
color: #fff;
letter-spacing: 1px;
text-shadow: 0 4px 16px rgba(0,0,0,0.18);
text-align: center; /* Center text */
}
.artist-name {
font-size: 2.2rem;
color: #b0b8c1;
margin-bottom: 96px;
font-weight: 500;
text-align: center; /* Center text */
}
.controls {
display: flex;
flex-direction: row;
gap: 56px;
margin-top: 16px;
justify-content: space-between; /* Spread controls out horizontally */
width: 100%; /* Take full width of info-section */
max-width: 500px; /* Optional: limit max width for better spacing */
}
.controls button {
background: none;
border: none;
color: #fff;
font-size: 5rem;
border-radius: 0;
width: auto;
height: auto;
cursor: pointer;
box-shadow: none;
padding: 0 16px;
transition: color 0.2s, transform 0.1s;
}
.controls button img {
filter: invert(1) brightness(2);
transition: filter 0.2s;
}
.controls button:hover {
color: #b0b8c1;
background: none;
transform: scale(1.15);
}
.controls button:hover img {
filter: invert(0.8) brightness(2.5) drop-shadow(0 0 8px #fff2);
}
/* Top right window controls */
.window-controls {
position: fixed;
top: 12px;
right: 12px;
z-index: 100;
display: flex;
gap: 8px;
}
.window-controls button {
background: none;
border: none;
color: #fff;
font-size: 1.2rem;
cursor: pointer;
opacity: 0.7;
transition: opacity 0.2s;
width: 32px;
height: 32px;
display: flex;
align-items: center;
justify-content: center;
padding: 0;
}
.window-controls button:hover {
opacity: 1;
}
/* Hide window controls by default */
.window-controls {
opacity: 0;
pointer-events: none;
transition: opacity 0.3s;
}
body.hovering .window-controls {
opacity: 1;
pointer-events: auto;
}
.background-blur {
position: fixed;
top: 0;
left: 0;
width: 100vw;
height: 100vh;
z-index: 0;
background-size: cover;
background-position: center;
filter: blur(36px) brightness(0.25) saturate(1.2);
transition: background-image 1s;
}
</style>
</head>
<body>
<div class="background-blur" id="backgroundBlur"></div>
<div class="window-controls">
<button onclick="minimizeApp()" title="Minimize"></button>
<button onclick="closeApp()" title="Close"></button>
</div>
<div class="main-container">
<img class="album-art" id="albumArt" src="https://via.placeholder.com/320" alt="Album Art">
<div class="info-section">
<div class="song-title" id="songTitle">Loading...</div>
<div class="artist-name" id="songArtist">&nbsp;</div>
<div class="controls">
<button onclick="sendControl('previous')" title="Previous">
<img src="previous.svg" alt="Previous" style="width: 56px; height: 56px; vertical-align: middle;">
</button>
<button id="playPauseButton" onclick="sendControl('playpause')" title="Play/Pause">
<img id="playPauseIcon" src="play.svg" alt="Play/Pause" style="width: 64px; height: 64px; vertical-align: middle;">
</button>
<button onclick="sendControl('next')" title="Next">
<img src="skip.svg" alt="Next" style="width: 56px; height: 56px; vertical-align: middle;">
</button>
</div>
</div>
</div>
<script>
const { ipcRenderer } = require('electron');
ipcRenderer.on('song-update', (event, data) => {
const songTitleElem = document.getElementById('songTitle');
const songArtistElem = document.getElementById('songArtist');
const albumArtElem = document.getElementById('albumArt');
const playPauseButton = document.getElementById('playPauseButton');
const playPauseIcon = document.getElementById('playPauseIcon');
const backgroundBlur = document.getElementById('backgroundBlur');
if (data.paused) {
playPauseIcon.src = "play.svg";
} else {
playPauseIcon.src = "pause.svg";
songTitleElem.innerText = data.title ?? "Unknown Title";
songArtistElem.innerText = data.artist ?? "Unknown Artist";
albumArtElem.src = data.albumArt ?? "https://via.placeholder.com/320";
if (backgroundBlur && data.albumArt) {
backgroundBlur.style.backgroundImage = `url('${data.albumArt}')`;
}
}
});
function sendControl(command) {
ipcRenderer.send('media-control', command);
}
function closeApp() {
ipcRenderer.send('close-app');
}
function minimizeApp() {
ipcRenderer.send('minimize-app');
}
// Show window controls only when mouse is over the window
document.body.addEventListener('mouseenter', () => {
document.body.classList.add('hovering');
});
document.body.addEventListener('mouseleave', () => {
document.body.classList.remove('hovering');
});
// Add touch event listeners to controls so touch does not move the Windows mouse
function addTouchListeners() {
const controls = document.querySelectorAll('.controls button');
controls.forEach(btn => {
btn.addEventListener('touchstart', (e) => {
e.preventDefault(); // Prevent mouse event emulation
btn.click(); // Trigger the same logic as a mouse click
}, { passive: false });
});
}
window.addEventListener('DOMContentLoaded', addTouchListeners);
</script>
</body>
</html>