mirror of
https://github.com/Mastermindzh/tidal-hifi.git
synced 2024-11-22 13:32:42 +01:00
Merge pull request #287 from Mastermindzh/bugfix/mpris-not-detected
fix: Fixed mpris not being set up correctly due to capitalization of …
This commit is contained in:
commit
0dadce4596
@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file.
|
|||||||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
||||||
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||||
|
|
||||||
|
## [5.7.1]
|
||||||
|
|
||||||
|
- Fixed mpris not being set up correctly due to capitalization of the instance name.
|
||||||
|
|
||||||
## [5.7.0]
|
## [5.7.0]
|
||||||
|
|
||||||
- Renamed app to TIDAL Hi-Fi.
|
- Renamed app to TIDAL Hi-Fi.
|
||||||
|
4
package-lock.json
generated
4
package-lock.json
generated
@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "TIDAL Hi-Fi",
|
"name": "TIDAL Hi-Fi",
|
||||||
"version": "5.6.0",
|
"version": "5.7.1",
|
||||||
"lockfileVersion": 3,
|
"lockfileVersion": 3,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "TIDAL Hi-Fi",
|
"name": "TIDAL Hi-Fi",
|
||||||
"version": "5.6.0",
|
"version": "5.7.1",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@electron/remote": "^2.0.10",
|
"@electron/remote": "^2.0.10",
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "tidal-hifi",
|
"name": "tidal-hifi",
|
||||||
"version": "5.7.0",
|
"version": "5.7.1",
|
||||||
"description": "Tidal on Electron with widevine(hifi) support",
|
"description": "Tidal on Electron with widevine(hifi) support",
|
||||||
"main": "ts-dist/main.js",
|
"main": "ts-dist/main.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
@ -4,7 +4,7 @@ import { settingsStore } from "../../scripts/settings";
|
|||||||
import { Logger } from "../logger";
|
import { Logger } from "../logger";
|
||||||
|
|
||||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
export function addCustomCss(app: any, logger: typeof Logger) {
|
export function addCustomCss(app: any) {
|
||||||
window.addEventListener("DOMContentLoaded", () => {
|
window.addEventListener("DOMContentLoaded", () => {
|
||||||
const selectedTheme = settingsStore.get<string, string>(settings.theme);
|
const selectedTheme = settingsStore.get<string, string>(settings.theme);
|
||||||
if (selectedTheme !== "none") {
|
if (selectedTheme !== "none") {
|
||||||
@ -13,7 +13,7 @@ export function addCustomCss(app: any, logger: typeof Logger) {
|
|||||||
const themeFile = fs.existsSync(userThemePath) ? userThemePath : resourcesThemePath;
|
const themeFile = fs.existsSync(userThemePath) ? userThemePath : resourcesThemePath;
|
||||||
fs.readFile(themeFile, "utf-8", (err, data) => {
|
fs.readFile(themeFile, "utf-8", (err, data) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
logger.alert("An error ocurred reading the theme file.", err, alert);
|
Logger.alert("An error ocurred reading the theme file.", err, alert);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -50,7 +50,7 @@ let adBlock: HTMLInputElement,
|
|||||||
discord_details_prefix: HTMLInputElement,
|
discord_details_prefix: HTMLInputElement,
|
||||||
discord_button_text: HTMLInputElement;
|
discord_button_text: HTMLInputElement;
|
||||||
|
|
||||||
addCustomCss(app, Logger.bind(this));
|
addCustomCss(app);
|
||||||
|
|
||||||
function getThemeFiles() {
|
function getThemeFiles() {
|
||||||
const selectElement = document.getElementById("themesList") as HTMLSelectElement;
|
const selectElement = document.getElementById("themesList") as HTMLSelectElement;
|
||||||
|
111
src/preload.ts
111
src/preload.ts
@ -354,6 +354,60 @@ function updateMediaInfo(options: Options, notify: boolean) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function addMPRIS() {
|
||||||
|
if (process.platform === "linux" && settingsStore.get(settings.mpris)) {
|
||||||
|
try {
|
||||||
|
player = Player({
|
||||||
|
name: "tidal-hifi",
|
||||||
|
identity: "tidal-hifi",
|
||||||
|
supportedUriSchemes: ["file"],
|
||||||
|
supportedMimeTypes: [
|
||||||
|
"audio/mpeg",
|
||||||
|
"audio/flac",
|
||||||
|
"audio/x-flac",
|
||||||
|
"application/ogg",
|
||||||
|
"audio/wav",
|
||||||
|
],
|
||||||
|
supportedInterfaces: ["player"],
|
||||||
|
desktopEntry: "tidal-hifi",
|
||||||
|
});
|
||||||
|
// Events
|
||||||
|
const events = {
|
||||||
|
next: "next",
|
||||||
|
previous: "previous",
|
||||||
|
pause: "pause",
|
||||||
|
playpause: "playpause",
|
||||||
|
stop: "stop",
|
||||||
|
play: "play",
|
||||||
|
loopStatus: "repeat",
|
||||||
|
shuffle: "shuffle",
|
||||||
|
seek: "seek",
|
||||||
|
} as { [key: string]: string };
|
||||||
|
Object.keys(events).forEach(function (eventName) {
|
||||||
|
player.on(eventName, function () {
|
||||||
|
const eventValue = events[eventName];
|
||||||
|
switch (events[eventValue]) {
|
||||||
|
case events.playpause:
|
||||||
|
playPause();
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
elements.click(eventValue);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
// Override get position function
|
||||||
|
player.getPosition = function () {
|
||||||
|
return convertDuration(elements.getText("current")) * 1000 * 1000;
|
||||||
|
};
|
||||||
|
player.on("quit", function () {
|
||||||
|
app.quit();
|
||||||
|
});
|
||||||
|
} catch (exception) {
|
||||||
|
Logger.log("MPRIS player api not working", exception);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function updateMpris(options: Options) {
|
function updateMpris(options: Options) {
|
||||||
if (player) {
|
if (player) {
|
||||||
player.metadata = {
|
player.metadata = {
|
||||||
@ -517,61 +571,8 @@ setInterval(function () {
|
|||||||
}
|
}
|
||||||
}, getUpdateFrequency());
|
}, getUpdateFrequency());
|
||||||
|
|
||||||
if (process.platform === "linux" && settingsStore.get(settings.mpris)) {
|
addMPRIS();
|
||||||
try {
|
addCustomCss(app);
|
||||||
player = Player({
|
|
||||||
name: "TIDAL Hi-Fi",
|
|
||||||
identity: "TIDAL Hi-Fi",
|
|
||||||
supportedUriSchemes: ["file"],
|
|
||||||
supportedMimeTypes: [
|
|
||||||
"audio/mpeg",
|
|
||||||
"audio/flac",
|
|
||||||
"audio/x-flac",
|
|
||||||
"application/ogg",
|
|
||||||
"audio/wav",
|
|
||||||
],
|
|
||||||
supportedInterfaces: ["player"],
|
|
||||||
desktopEntry: "tidal-hifi",
|
|
||||||
});
|
|
||||||
// Events
|
|
||||||
const events = {
|
|
||||||
next: "next",
|
|
||||||
previous: "previous",
|
|
||||||
pause: "pause",
|
|
||||||
playpause: "playpause",
|
|
||||||
stop: "stop",
|
|
||||||
play: "play",
|
|
||||||
loopStatus: "repeat",
|
|
||||||
shuffle: "shuffle",
|
|
||||||
seek: "seek",
|
|
||||||
} as { [key: string]: string };
|
|
||||||
Object.keys(events).forEach(function (eventName) {
|
|
||||||
player.on(eventName, function () {
|
|
||||||
const eventValue = events[eventName];
|
|
||||||
switch (events[eventValue]) {
|
|
||||||
case events.playpause:
|
|
||||||
playPause();
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
elements.click(eventValue);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
// Override get position function
|
|
||||||
player.getPosition = function () {
|
|
||||||
return convertDuration(elements.getText("current")) * 1000 * 1000;
|
|
||||||
};
|
|
||||||
|
|
||||||
player.on("quit", function () {
|
|
||||||
app.quit();
|
|
||||||
});
|
|
||||||
} catch (exception) {
|
|
||||||
console.log("player api not working");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
addCustomCss(app, Logger.bind(this));
|
|
||||||
addHotKeys();
|
addHotKeys();
|
||||||
addIPCEventListeners();
|
addIPCEventListeners();
|
||||||
addFullScreenListeners();
|
addFullScreenListeners();
|
||||||
|
Loading…
Reference in New Issue
Block a user