Skip to content

Commit

Permalink
v1.0.1 (#1)
Browse files Browse the repository at this point in the history
* v1.0.1

- Implemented taskbar media controls
- Fixed taskbar icon
- Cleaned code
- Fixes when building windows dist
  • Loading branch information
DorvakOff authored Jan 9, 2024
1 parent 2b1fcd8 commit 645f697
Show file tree
Hide file tree
Showing 39 changed files with 146 additions and 417 deletions.
5 changes: 3 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -159,5 +159,6 @@ $RECYCLE.BIN/
# End of https://www.gitignore.io/api/node,linux,macos,windows

# Custom
dist/*
build/*
dist/
build/
.idea/
9 changes: 0 additions & 9 deletions .idea/DeezerRPC.iml

This file was deleted.

7 changes: 0 additions & 7 deletions .idea/discord.xml

This file was deleted.

8 changes: 0 additions & 8 deletions .idea/modules.xml

This file was deleted.

6 changes: 0 additions & 6 deletions .idea/vcs.xml

This file was deleted.

112 changes: 0 additions & 112 deletions .idea/workspace.xml

This file was deleted.

3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@
## Installation
1. Download the latest release from [here](https://github.com/DorvakOff/DeezerRPC/releases/latest).
2. Extract the archive.
3. Run `DeezerRPC.exe`.
4. Enjoy!
3. On Windows, run `DeezerRPC.exe`. On Linux, run `DeezerRPC`. And on macOS, run `DeezerRPC.app`.

# Shortcuts (keyboard)
- Play/Pause : Pause/Resume the current song.
Expand Down
File renamed without changes
Binary file removed assets/rpc/listening.png
Binary file not shown.
Binary file removed assets/rpc/paused.png
Binary file not shown.
Binary file removed assets/rpc/streaming.png
Binary file not shown.
2 changes: 1 addition & 1 deletion package-assets.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const shell = require('shelljs');

shell.cp('-R', './src/web', './build/');
shell.cp('-R', './src/assets', './build/');

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "deezer-rpc",
"version": "1.0.0",
"version": "1.0.1",
"description": "Deezer integrated with the Discord Rich Presence.",
"main": "build/main.js",
"scripts": {
Expand All @@ -18,7 +18,7 @@
"appId": "com.dorvak.deezerrpc",
"asar": "true",
"productName": "DeezerRPC",
"icon": "./assets/deezer.png",
"icon": "./assets/images/deezer.png",
"files": [
"build/**/*"
],
Expand Down
Binary file added src/assets/images/deezer.ico
Binary file not shown.
Binary file added src/assets/images/deezer.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/assets/images/next.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/assets/images/pause.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/assets/images/play.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/assets/images/previous.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 0 additions & 1 deletion src/web/titlebar.html → src/assets/titlebar.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,5 @@
<head>
<meta charset="UTF-8">
<title>Deezer</title>
<link rel="icon" href="./images/deezer.png" type="image/x-icon">
</head>
</html>
127 changes: 69 additions & 58 deletions src/main.ts
Original file line number Diff line number Diff line change
@@ -1,89 +1,100 @@
import * as path from 'path';
import { APP, RPC } from './app/app';
import {APP, RPC} from './app/app';
import * as Tray from './manager/tray';
import * as Update from './util/update';
import * as Update from './utils/update';
import * as Player from './player/player';
import * as Window from './manager/window';
import * as Titlebar from './manager/titlebar';
import * as Preferences from './util/preferences';
import { app, BrowserWindow, dialog } from 'electron';
import * as Window from './utils/http-utils';
import * as TitleBar from './manager/title-bar';
import * as Preferences from './utils/preferences';
import {app, BrowserWindow, dialog} from 'electron';
import path from "path";
import {nativeImage} from "electron";

// Entry
function main() {
createMainWindow();
}

function createMainWindow() {
// SplashWindow
let splashWindow: BrowserWindow;

// Create MainWindow
global.__mainWindow = Window.createWindow(
false, {
titleBarStyle: 'hidden',
webPreferences: {
preload: path.join(__dirname, 'preload/deezer.js')
}
}
);
global.__mainWindow = new BrowserWindow({
width: APP.settings.windowWidth,
height: APP.settings.windowHeight,
show: false,
title: APP.name,
titleBarStyle: 'hidden',
icon: path.join(__dirname, 'assets/images/deezer.ico'),
});

// Load URL
__mainWindow.loadURL(APP.settings.deezerUrl, { userAgent: Window.userAgent() });
__mainWindow.loadURL(APP.settings.deezerUrl, {userAgent: Window.userAgent()});

// Events
__mainWindow.webContents.once('did-finish-load', () => {
__mainWindow.show();
__mainWindow.webContents.once('did-finish-load', () => handleLoadComplete());
__mainWindow.on('show', () => TitleBar.register());
__mainWindow.on('hide', () => TitleBar.unregister())

__mainWindow.on('minimize', () => {
if (Preferences.getPreference<boolean>(APP.preferences.minimizeToTray)) {
__mainWindow.hide();
}
});
__mainWindow.on('close', (event) => {
event.preventDefault();
if (Preferences.getPreference<boolean>(APP.preferences.closeToTray)) {
__mainWindow.hide();
} else {
app.exit();
}
});
}

function handleLoadComplete() {
__mainWindow.show();

let css = `
let css = `
.page-topbar, .css-efpag6, .tempo-topbar, #dzr-app {
margin-top: 30px !important;
}
`;

__mainWindow.webContents.insertCSS(css);

setInterval(() => {
__mainWindow.webContents.insertCSS(css);
}, 1000);
__mainWindow.webContents.insertCSS(css);

splashWindow.close();

Tray.register();
Player.registerShortcuts();

if (Preferences.getPreference<boolean>(APP.preferences.checkUpdates)) Update.checkVersion(false);

// Initialize RPC
initializeRPC();
});
setInterval(() => {
__mainWindow.webContents.insertCSS(css);
}, 1000);

__mainWindow.on('show', () => {
Titlebar.register();
});
Tray.register();
Player.registerShortcuts();
loadThumbnailButtons()

__mainWindow.on('hide', () => {
Titlebar.unregister();
})
if (Preferences.getPreference<boolean>(APP.preferences.checkUpdates)) Update.checkVersion(false);

__mainWindow.on('minimize', () => {
if (Preferences.getPreference<boolean>(APP.preferences.minimizeToTray)) __mainWindow.hide();
});

__mainWindow.on('close', (event) => {
event.preventDefault();

if (Preferences.getPreference<boolean>(APP.preferences.closeToTray)) __mainWindow.hide(); else app.exit();
});
// Initialize RPC
initializeRPC();
}

// Create SplashWindow
splashWindow = Window.createWindow(true);
splashWindow.setResizable(false);
splashWindow.setMaximizable(false);
splashWindow.loadFile(path.join(__dirname, './web/deezer.png'));
export function loadThumbnailButtons(playing: boolean = false) {
__mainWindow.setThumbarButtons([
{
tooltip: 'Previous',
icon: nativeImage.createFromPath(path.join(__dirname, 'assets/images/previous.png')),
click: () => Player.previousSong()
},
{
tooltip: 'Play/Pause',
icon: nativeImage.createFromPath(path.join(__dirname, `assets/images/${playing ? 'pause' : 'play'}.png`)),
click: () => Player.togglePause()
},
{
tooltip: 'Next',
icon: nativeImage.createFromPath(path.join(__dirname, 'assets/images/next.png')),
click: () => Player.nextSong()
}
])
}

function initializeRPC() {
RPC.login({ clientId: APP.settings.discordClientID }).then(() => {
RPC.login({clientId: APP.settings.discordClientID}).then(() => {
setTimeout(Player.registerRPC, 3000);
}).catch(() => {
dialog.showErrorBox("Rich Presence Login Failed", "Please, verify if your discord app is opened/working and relaunch this application.");
Expand Down
Loading

0 comments on commit 645f697

Please sign in to comment.