mirror of
https://github.com/Mastermindzh/tidal-hifi.git
synced 2025-07-28 00:22:26 +02:00
Merge pull request #392 from TheRockYT/MediaSessionService
Media session service
This commit is contained in:
@@ -9,7 +9,6 @@ import { Logger } from "../logger";
|
||||
*/
|
||||
export function setDefaultFlags(app: App) {
|
||||
setFlag(app, "disable-seccomp-filter-sandbox");
|
||||
setFlag(app, "disable-features", "MediaSessionService");
|
||||
}
|
||||
|
||||
/**
|
||||
|
11
src/main.ts
11
src/main.ts
@@ -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 {
|
||||
@@ -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.
|
||||
@@ -206,7 +196,6 @@ app.on("ready", async () => {
|
||||
createWindow();
|
||||
addMenu(mainWindow);
|
||||
createSettingsWindow();
|
||||
addGlobalShortcuts();
|
||||
if (settingsStore.get(settings.trayIcon)) {
|
||||
addTray(mainWindow, { icon });
|
||||
refreshTray(mainWindow);
|
||||
|
@@ -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
|
||||
*/
|
||||
@@ -574,9 +557,6 @@ setInterval(function () {
|
||||
}
|
||||
}).then(() => {
|
||||
updateMediaInfo(options, titleOrArtistsChanged);
|
||||
if (titleOrArtistsChanged) {
|
||||
updateMediaSession(options);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
// just update the time
|
||||
|
Reference in New Issue
Block a user