Skip to content

Commit a2b9b07

Browse files
testing updates
1 parent 1112e8a commit a2b9b07

File tree

3 files changed

+94
-2
lines changed

3 files changed

+94
-2
lines changed

public/album_art.html

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
6+
<link rel="stylesheet" href="tailwind.css">
7+
<title>Unbox Overlay</title>
8+
<script src="https://cdnjs.cloudflare.com/ajax/libs/animejs/3.2.1/anime.min.js"></script>
9+
<script>
10+
document.addEventListener('DOMContentLoaded', () => {
11+
const items = [{"id": 5, "contentType": "Album Art", "selector": ".sweep-text-artwork"}];
12+
items.forEach(item => {
13+
item.element = document.querySelector(item.selector);
14+
});
15+
16+
const applyAnimation = (element, animationName, duration) => {
17+
if (!element) return;
18+
const translateYValue = animationName === 'fadeIn' ? [100, 0] : [0, -100];
19+
const opacityValue = animationName === 'fadeIn' ? [0, 1] : [1, 0];
20+
return anime({
21+
targets: element,
22+
translateY: translateYValue,
23+
opacity: opacityValue,
24+
easing: 'easeOutExpo',
25+
duration: duration * 1000
26+
});
27+
}
28+
29+
const setupWebSocket = (elements) => {
30+
const socket = new WebSocket('ws://10.0.0.162:3000');
31+
32+
socket.addEventListener('message', (event) => {
33+
const trackDetails = JSON.parse(event.data);
34+
35+
elements.forEach((item) => {
36+
if (item.element.firstChild && item.contentType === 'Album Art') {
37+
let animation = applyAnimation(item.element.firstChild, 'fadeOut', 1 + item.id * 0.1);
38+
animation.finished.then(() => {
39+
item.element.removeChild(item.element.firstChild);
40+
if (trackDetails.artwork) {
41+
const img = document.createElement('img');
42+
img.src = trackDetails.artwork;
43+
img.className = 'sweep-text-artwork';
44+
item.element.appendChild(img);
45+
applyAnimation(img, 'fadeIn', 1 + item.id * 0.1);
46+
}
47+
});
48+
} else if (trackDetails.artwork) {
49+
const img = document.createElement('img');
50+
img.src = trackDetails.artwork;
51+
img.className = 'sweep-text-artwork';
52+
item.element.appendChild(img);
53+
applyAnimation(img, 'fadeIn', 1 + item.id * 0.1);
54+
}
55+
});
56+
});
57+
}
58+
59+
setupWebSocket(items);
60+
});
61+
</script>
62+
</head>
63+
<body>
64+
<div class="relative w-full h-full">
65+
<div class="overflow-hidden rounded-lg">
66+
<div class="px-4 py-5 sm:p-6">
67+
<div class="mx-auto max-w-fit min-w-fit">
68+
<div class="flex items-stretch">
69+
<div class="w-1/8 flex-shrink-0 self-center">
70+
<div class="mr-2 h-32 w-32 flex items-center sweep-text-artwork sweep-text-item"></div>
71+
</div>
72+
</div>
73+
</div>
74+
</div>
75+
</div>
76+
</div>
77+
</body>
78+
</html>

src/index.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
const { app, BrowserWindow } = require("electron");
22
const { createWindow } = require("./window");
3+
const { getLocalIP } = require("./localIP");
34
const { initializeIpcHandlers } = require("./ipcHandlers");
45
const { startExpressServer, closeExpressServer } = require("./expressServer");
56
const { Poller } = require("./poller");
@@ -8,7 +9,7 @@ const Store = require("electron-store");
89
const { resolve, join } = require("path");
910
const { copyFile, mkdirSync } = require("fs");
1011
const winston = require('winston');
11-
const updateElectronApp = require('update-electron-app');
12+
const fs = require('fs');
1213

1314
function copy(sourcePath, destPath) {
1415
return new Promise((resolve, reject) => {
@@ -48,11 +49,18 @@ app.on("ready", async () => {
4849
const store = new Store({ name: "unbox" });
4950
const userDataPath = app.getPath('userData');
5051
const sourceCssPath = resolve(__dirname, "..", "public", "tailwind.css");
52+
const sourceHtmlPath = resolve(__dirname, "..", "public", "album_art.html");
53+
const destHtmlPath = join(userDataPath, 'album_art.html');
5154
const destCssPath = join(userDataPath, 'tailwind.css');
5255

5356
try {
57+
const localIP = getLocalIP();
58+
let data = await fs.promises.readFile(sourceHtmlPath, 'utf8');
59+
data = data.replace('WEBSOCKET_IP', localIP);
60+
await fs.promises.writeFile(sourceHtmlPath, data, 'utf8');
5461
await Promise.all([
5562
copy(sourceCssPath, destCssPath),
63+
copy(sourceHtmlPath, destHtmlPath),
5664
]);
5765
} catch(err) {
5866
console.error(`Error occurred during file copy: ${err}`);

src/poller.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,13 @@ class Poller {
191191
track = `${track} (${remix})`;
192192
}
193193
if (artwork) {
194-
let rekordboxArtworkDir = path.join(os.homedir(), 'Library', 'Pioneer', 'rekordbox', 'share', artwork);
194+
let rekordboxArtworkDir = null;
195+
if (process.platform == 'darwin') {
196+
rekordboxArtworkDir = path.join(os.homedir(), 'Library', 'Pioneer', 'rekordbox', 'share', artwork);
197+
}
198+
else {
199+
rekordboxArtworkDir = path.join(process.env.APPDATA, 'Pioneer', 'rekordbox', 'share', artwork);
200+
}
195201
let data = await Jimp.read(rekordboxArtworkDir);
196202
data = await data
197203
.resize(300, 300)

0 commit comments

Comments
 (0)