Skip to content

Commit

Permalink
Merge pull request Mastermindzh#392 from TheRockYT/MediaSessionService
Browse files Browse the repository at this point in the history
Media session service
  • Loading branch information
Mastermindzh authored May 5, 2024
2 parents 25afd05 + 04ec850 commit 53603c4
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 57 deletions.
42 changes: 21 additions & 21 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,14 @@
"license": "MIT",
"dependencies": {
"@electron/remote": "^2.1.2",
"axios": "^1.6.5",
"axios": "^1.6.8",
"discord-rpc": "^4.0.1",
"electron-store": "^8.1.0",
"express": "^4.18.3",
"electron-store": "^8.2.0",
"express": "^4.19.2",
"hotkeys-js": "^3.13.7",
"mpris-service": "^2.1.2",
"request": "^2.88.2",
"sass": "^1.71.1"
"sass": "^1.74.1"
},
"devDependencies": {
"@mastermindzh/prettier-config": "^1.0.0",
Expand Down
1 change: 0 additions & 1 deletion src/features/flags/flags.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import { Logger } from "../logger";
*/
export function setDefaultFlags(app: App) {
setFlag(app, "disable-seccomp-filter-sandbox");
setFlag(app, "disable-features", "MediaSessionService");
}

/**
Expand Down
11 changes: 0 additions & 11 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,11 @@ import {
app,
BrowserWindow,
components,
globalShortcut,
ipcMain,
session,
} from "electron";
import path from "path";
import { globalEvents } from "./constants/globalEvents";
import { mediaKeys } from "./constants/mediaKeys";
import { settings } from "./constants/settings";
import { setDefaultFlags, setManagedFlagsFromSettings } from "./features/flags/flags";
import {
Expand Down Expand Up @@ -162,14 +160,6 @@ function registerHttpProtocols() {
}
}

function addGlobalShortcuts() {
Object.keys(mediaKeys).forEach((key) => {
globalShortcut.register(`${key}`, () => {
mainWindow.webContents.send("globalEvent", `${(mediaKeys as any)[key]}`);
});
});
}

// This method will be called when Electron has finished
// initialization and is ready to create browser windows.
// Some APIs can only be used after this event occurs.
Expand Down Expand Up @@ -206,7 +196,6 @@ app.on("ready", async () => {
createWindow();
addMenu(mainWindow);
createSettingsWindow();
addGlobalShortcuts();
if (settingsStore.get(settings.trayIcon)) {
addTray(mainWindow, { icon });
refreshTray(mainWindow);
Expand Down
20 changes: 0 additions & 20 deletions src/preload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -493,23 +493,6 @@ function getTrackID() {
return window.location;
}

function updateMediaSession(options: Options) {
if ("mediaSession" in navigator) {
navigator.mediaSession.metadata = new MediaMetadata({
title: options.title,
artist: options.artists,
album: options.album,
artwork: [
{
src: options.icon,
sizes: "640x640",
type: "image/png",
},
],
});
}
}

/**
* Watch for song changes and update title + notify
*/
Expand Down Expand Up @@ -574,9 +557,6 @@ setInterval(function () {
}
}).then(() => {
updateMediaInfo(options, titleOrArtistsChanged);
if (titleOrArtistsChanged) {
updateMediaSession(options);
}
});
} else {
// just update the time
Expand Down

0 comments on commit 53603c4

Please sign in to comment.