Changed the paths to utils for free access across the project

This commit is contained in:
Core 2022-02-02 10:28:26 +00:00
parent de5d41ef36
commit b972a0e40a
No known key found for this signature in database
GPG key ID: FE9BF1B547F8F3C6
2 changed files with 60 additions and 25 deletions

View file

@ -3,9 +3,30 @@ import * as path from "path";
import {jsonc} from "jsonc";
import {Store} from "./store";
import {BrowserWindow as bw} from "./browserwindow";
import {app} from "electron";
export class utils {
/**
* Paths for the application to use
*/
private static paths: any = {
srcPath: path.join(__dirname, "../../src"),
resourcePath: path.join(__dirname, "../../resources"),
ciderCache: path.resolve(app.getPath("userData"), "CiderCache"),
themes: path.resolve(app.getPath("userData"), "Themes"),
plugins: path.resolve(app.getPath("userData"), "Plugins"),
};
/**
* Get the path
* @returns {string}
* @param name
*/
static getPath(name: string): string {
return this.paths[name];
}
/**
* Fetches the i18n locale for the given language.
* @param language {string} The language to fetch the locale for.
@ -58,4 +79,25 @@ export class utils {
static getWindow(): Electron.BrowserWindow {
return bw.win
}
/**
* Playback Functions
*/
static playback = {
pause: () => {
bw.win.webContents.send("MusicKitInterop.pause()")
},
play: () => {
bw.win.webContents.send("MusicKitInterop.play()")
},
playPause: () => {
bw.win.webContents.send("MusicKitInterop.playPause()")
},
next: () => {
bw.win.webContents.send("MusicKitInterop.next()")
},
previous: () => {
bw.win.webContents.send("MusicKitInterop.previous()")
}
}
}