mirror of
https://github.com/Mastermindzh/tidal-hifi.git
synced 2025-09-09 21:34:44 +02:00
changed mediaSessionController to API Controller
This commit is contained in:
@@ -5,13 +5,12 @@ import { RepeatState } from "../../models/repeatState";
|
|||||||
import { DomTidalController } from "../DomController/DomTidalController";
|
import { DomTidalController } from "../DomController/DomTidalController";
|
||||||
import { TidalController } from "../TidalController";
|
import { TidalController } from "../TidalController";
|
||||||
|
|
||||||
export class MediaSessionController implements TidalController {
|
export class TidalApiController implements TidalController {
|
||||||
public domMediaController: TidalController;
|
public domMediaController: TidalController;
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
this.domMediaController = new DomTidalController();
|
this.domMediaController = new DomTidalController();
|
||||||
|
Logger.log("[TidalApiController] - Initialized domController as a backup controller");
|
||||||
Logger.log("Initialized domController as a backup controller");
|
|
||||||
}
|
}
|
||||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||||
onMediaInfoUpdate(callback: (state: Partial<MediaInfo>) => void): void {
|
onMediaInfoUpdate(callback: (state: Partial<MediaInfo>) => void): void {
|
@@ -1,4 +1,4 @@
|
|||||||
export const tidalControllers = {
|
export const tidalControllers = {
|
||||||
domController: "domController",
|
domController: "domController",
|
||||||
mediaSessionController: "mediaSessionController",
|
tidalApiController: "tidalApiController",
|
||||||
};
|
};
|
||||||
|
@@ -21,7 +21,9 @@
|
|||||||
"/current": {
|
"/current": {
|
||||||
"get": {
|
"get": {
|
||||||
"summary": "Get current media info",
|
"summary": "Get current media info",
|
||||||
"tags": ["current"],
|
"tags": [
|
||||||
|
"current"
|
||||||
|
],
|
||||||
"responses": {
|
"responses": {
|
||||||
"200": {
|
"200": {
|
||||||
"description": "Current media info",
|
"description": "Current media info",
|
||||||
@@ -39,7 +41,9 @@
|
|||||||
"/current/image": {
|
"/current/image": {
|
||||||
"get": {
|
"get": {
|
||||||
"summary": "Get current media image",
|
"summary": "Get current media image",
|
||||||
"tags": ["current"],
|
"tags": [
|
||||||
|
"current"
|
||||||
|
],
|
||||||
"responses": {
|
"responses": {
|
||||||
"200": {
|
"200": {
|
||||||
"description": "Current media image",
|
"description": "Current media image",
|
||||||
@@ -61,7 +65,9 @@
|
|||||||
"/player/play": {
|
"/player/play": {
|
||||||
"post": {
|
"post": {
|
||||||
"summary": "Play the current media",
|
"summary": "Play the current media",
|
||||||
"tags": ["player"],
|
"tags": [
|
||||||
|
"player"
|
||||||
|
],
|
||||||
"responses": {
|
"responses": {
|
||||||
"200": {
|
"200": {
|
||||||
"description": "Ok",
|
"description": "Ok",
|
||||||
@@ -79,7 +85,9 @@
|
|||||||
"/player/favorite/toggle": {
|
"/player/favorite/toggle": {
|
||||||
"post": {
|
"post": {
|
||||||
"summary": "Add the current media to your favorites, or remove it if its already added to your favorites",
|
"summary": "Add the current media to your favorites, or remove it if its already added to your favorites",
|
||||||
"tags": ["player"],
|
"tags": [
|
||||||
|
"player"
|
||||||
|
],
|
||||||
"responses": {
|
"responses": {
|
||||||
"200": {
|
"200": {
|
||||||
"description": "Ok",
|
"description": "Ok",
|
||||||
@@ -97,7 +105,9 @@
|
|||||||
"/player/pause": {
|
"/player/pause": {
|
||||||
"post": {
|
"post": {
|
||||||
"summary": "Pause the current media",
|
"summary": "Pause the current media",
|
||||||
"tags": ["player"],
|
"tags": [
|
||||||
|
"player"
|
||||||
|
],
|
||||||
"responses": {
|
"responses": {
|
||||||
"200": {
|
"200": {
|
||||||
"description": "Ok",
|
"description": "Ok",
|
||||||
@@ -115,7 +125,9 @@
|
|||||||
"/player/next": {
|
"/player/next": {
|
||||||
"post": {
|
"post": {
|
||||||
"summary": "Play the next song",
|
"summary": "Play the next song",
|
||||||
"tags": ["player"],
|
"tags": [
|
||||||
|
"player"
|
||||||
|
],
|
||||||
"responses": {
|
"responses": {
|
||||||
"200": {
|
"200": {
|
||||||
"description": "Ok",
|
"description": "Ok",
|
||||||
@@ -133,7 +145,9 @@
|
|||||||
"/player/previous": {
|
"/player/previous": {
|
||||||
"post": {
|
"post": {
|
||||||
"summary": "Play the previous song",
|
"summary": "Play the previous song",
|
||||||
"tags": ["player"],
|
"tags": [
|
||||||
|
"player"
|
||||||
|
],
|
||||||
"responses": {
|
"responses": {
|
||||||
"200": {
|
"200": {
|
||||||
"description": "Ok",
|
"description": "Ok",
|
||||||
@@ -151,7 +165,9 @@
|
|||||||
"/player/shuffle/toggle": {
|
"/player/shuffle/toggle": {
|
||||||
"post": {
|
"post": {
|
||||||
"summary": "Play the previous song",
|
"summary": "Play the previous song",
|
||||||
"tags": ["player"],
|
"tags": [
|
||||||
|
"player"
|
||||||
|
],
|
||||||
"responses": {
|
"responses": {
|
||||||
"200": {
|
"200": {
|
||||||
"description": "Ok",
|
"description": "Ok",
|
||||||
@@ -169,7 +185,9 @@
|
|||||||
"/player/repeat/toggle": {
|
"/player/repeat/toggle": {
|
||||||
"post": {
|
"post": {
|
||||||
"summary": "Toggle the repeat status, toggles between \"off\" , \"single\" and \"all\"",
|
"summary": "Toggle the repeat status, toggles between \"off\" , \"single\" and \"all\"",
|
||||||
"tags": ["player"],
|
"tags": [
|
||||||
|
"player"
|
||||||
|
],
|
||||||
"responses": {
|
"responses": {
|
||||||
"200": {
|
"200": {
|
||||||
"description": "Ok",
|
"description": "Ok",
|
||||||
@@ -187,7 +205,9 @@
|
|||||||
"/player/playpause": {
|
"/player/playpause": {
|
||||||
"post": {
|
"post": {
|
||||||
"summary": "Start playing the media if paused, or pause the media if playing",
|
"summary": "Start playing the media if paused, or pause the media if playing",
|
||||||
"tags": ["player"],
|
"tags": [
|
||||||
|
"player"
|
||||||
|
],
|
||||||
"responses": {
|
"responses": {
|
||||||
"200": {
|
"200": {
|
||||||
"description": "Ok",
|
"description": "Ok",
|
||||||
@@ -205,7 +225,9 @@
|
|||||||
"/settings/skipped-artists": {
|
"/settings/skipped-artists": {
|
||||||
"get": {
|
"get": {
|
||||||
"summary": "get a list of artists that TIDAL Hi-Fi will skip if skipping is enabled",
|
"summary": "get a list of artists that TIDAL Hi-Fi will skip if skipping is enabled",
|
||||||
"tags": ["settings"],
|
"tags": [
|
||||||
|
"settings"
|
||||||
|
],
|
||||||
"responses": {
|
"responses": {
|
||||||
"200": {
|
"200": {
|
||||||
"description": "The list book.",
|
"description": "The list book.",
|
||||||
@@ -221,7 +243,9 @@
|
|||||||
},
|
},
|
||||||
"post": {
|
"post": {
|
||||||
"summary": "Add new artists to the list of skipped artists",
|
"summary": "Add new artists to the list of skipped artists",
|
||||||
"tags": ["settings"],
|
"tags": [
|
||||||
|
"settings"
|
||||||
|
],
|
||||||
"requestBody": {
|
"requestBody": {
|
||||||
"required": true,
|
"required": true,
|
||||||
"content": {
|
"content": {
|
||||||
@@ -242,7 +266,9 @@
|
|||||||
"/settings/skipped-artists/delete": {
|
"/settings/skipped-artists/delete": {
|
||||||
"post": {
|
"post": {
|
||||||
"summary": "Remove artists from the list of skipped artists",
|
"summary": "Remove artists from the list of skipped artists",
|
||||||
"tags": ["settings"],
|
"tags": [
|
||||||
|
"settings"
|
||||||
|
],
|
||||||
"requestBody": {
|
"requestBody": {
|
||||||
"required": true,
|
"required": true,
|
||||||
"content": {
|
"content": {
|
||||||
@@ -263,7 +289,9 @@
|
|||||||
"/settings/skipped-artists/current": {
|
"/settings/skipped-artists/current": {
|
||||||
"post": {
|
"post": {
|
||||||
"summary": "Add the current artist to the list of skipped artists",
|
"summary": "Add the current artist to the list of skipped artists",
|
||||||
"tags": ["settings"],
|
"tags": [
|
||||||
|
"settings"
|
||||||
|
],
|
||||||
"responses": {
|
"responses": {
|
||||||
"200": {
|
"200": {
|
||||||
"description": "Ok"
|
"description": "Ok"
|
||||||
@@ -272,7 +300,9 @@
|
|||||||
},
|
},
|
||||||
"delete": {
|
"delete": {
|
||||||
"summary": "Remove the current artist from the list of skipped artists",
|
"summary": "Remove the current artist from the list of skipped artists",
|
||||||
"tags": ["settings"],
|
"tags": [
|
||||||
|
"settings"
|
||||||
|
],
|
||||||
"responses": {
|
"responses": {
|
||||||
"200": {
|
"200": {
|
||||||
"description": "Ok"
|
"description": "Ok"
|
||||||
@@ -283,7 +313,9 @@
|
|||||||
"/image": {
|
"/image": {
|
||||||
"get": {
|
"get": {
|
||||||
"summary": "Get current image",
|
"summary": "Get current image",
|
||||||
"tags": ["legacy"],
|
"tags": [
|
||||||
|
"legacy"
|
||||||
|
],
|
||||||
"deprecated": true,
|
"deprecated": true,
|
||||||
"responses": {
|
"responses": {
|
||||||
"200": {
|
"200": {
|
||||||
@@ -306,7 +338,9 @@
|
|||||||
"/play": {
|
"/play": {
|
||||||
"get": {
|
"get": {
|
||||||
"summary": "Play the current media",
|
"summary": "Play the current media",
|
||||||
"tags": ["legacy"],
|
"tags": [
|
||||||
|
"legacy"
|
||||||
|
],
|
||||||
"deprecated": true,
|
"deprecated": true,
|
||||||
"responses": {
|
"responses": {
|
||||||
"200": {
|
"200": {
|
||||||
@@ -325,7 +359,9 @@
|
|||||||
"/favorite/toggle": {
|
"/favorite/toggle": {
|
||||||
"get": {
|
"get": {
|
||||||
"summary": "Add the current media to your favorites, or remove it if its already added to your favorites",
|
"summary": "Add the current media to your favorites, or remove it if its already added to your favorites",
|
||||||
"tags": ["legacy"],
|
"tags": [
|
||||||
|
"legacy"
|
||||||
|
],
|
||||||
"deprecated": true,
|
"deprecated": true,
|
||||||
"responses": {
|
"responses": {
|
||||||
"200": {
|
"200": {
|
||||||
@@ -344,7 +380,9 @@
|
|||||||
"/pause": {
|
"/pause": {
|
||||||
"get": {
|
"get": {
|
||||||
"summary": "Pause the current media",
|
"summary": "Pause the current media",
|
||||||
"tags": ["legacy"],
|
"tags": [
|
||||||
|
"legacy"
|
||||||
|
],
|
||||||
"deprecated": true,
|
"deprecated": true,
|
||||||
"responses": {
|
"responses": {
|
||||||
"200": {
|
"200": {
|
||||||
@@ -363,7 +401,9 @@
|
|||||||
"/next": {
|
"/next": {
|
||||||
"get": {
|
"get": {
|
||||||
"summary": "Play the next song",
|
"summary": "Play the next song",
|
||||||
"tags": ["legacy"],
|
"tags": [
|
||||||
|
"legacy"
|
||||||
|
],
|
||||||
"deprecated": true,
|
"deprecated": true,
|
||||||
"responses": {
|
"responses": {
|
||||||
"200": {
|
"200": {
|
||||||
@@ -382,7 +422,9 @@
|
|||||||
"/previous": {
|
"/previous": {
|
||||||
"get": {
|
"get": {
|
||||||
"summary": "Play the previous song",
|
"summary": "Play the previous song",
|
||||||
"tags": ["legacy"],
|
"tags": [
|
||||||
|
"legacy"
|
||||||
|
],
|
||||||
"deprecated": true,
|
"deprecated": true,
|
||||||
"responses": {
|
"responses": {
|
||||||
"200": {
|
"200": {
|
||||||
@@ -401,7 +443,9 @@
|
|||||||
"/playpause": {
|
"/playpause": {
|
||||||
"get": {
|
"get": {
|
||||||
"summary": "Toggle play/pause",
|
"summary": "Toggle play/pause",
|
||||||
"tags": ["legacy"],
|
"tags": [
|
||||||
|
"legacy"
|
||||||
|
],
|
||||||
"deprecated": true,
|
"deprecated": true,
|
||||||
"responses": {
|
"responses": {
|
||||||
"200": {
|
"200": {
|
||||||
@@ -514,7 +558,10 @@
|
|||||||
"items": {
|
"items": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
},
|
},
|
||||||
"example": ["Artist1", "Artist2"]
|
"example": [
|
||||||
|
"Artist1",
|
||||||
|
"Artist2"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -532,4 +579,4 @@
|
|||||||
"description": "The settings management API"
|
"description": "The settings management API"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
@@ -388,7 +388,7 @@
|
|||||||
<p>Select the type of controller to use.</p>
|
<p>Select the type of controller to use.</p>
|
||||||
<select id="controllerType" class="select-input">
|
<select id="controllerType" class="select-input">
|
||||||
<option value="domController">DOM Controller</option>
|
<option value="domController">DOM Controller</option>
|
||||||
<option value="mediaSessionController">Media Session Controller</option>
|
<option value="tidalApiController">Tidal Api Controller (beta)</option>
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@@ -1,6 +1,7 @@
|
|||||||
import { app, dialog, Notification } from "@electron/remote";
|
import { app, dialog, Notification } from "@electron/remote";
|
||||||
import { clipboard, ipcRenderer } from "electron";
|
import { clipboard, ipcRenderer } from "electron";
|
||||||
import Player from "mpris-service";
|
import Player from "mpris-service";
|
||||||
|
import { tidalControllers } from "./constants/controller";
|
||||||
import { globalEvents } from "./constants/globalEvents";
|
import { globalEvents } from "./constants/globalEvents";
|
||||||
import { settings } from "./constants/settings";
|
import { settings } from "./constants/settings";
|
||||||
import { downloadIcon } from "./features/icon/downloadIcon";
|
import { downloadIcon } from "./features/icon/downloadIcon";
|
||||||
@@ -20,10 +21,10 @@ import { addHotkey } from "./scripts/hotkeys";
|
|||||||
import { ObjectToDotNotation } from "./scripts/objectUtilities";
|
import { ObjectToDotNotation } from "./scripts/objectUtilities";
|
||||||
import { settingsStore } from "./scripts/settings";
|
import { settingsStore } from "./scripts/settings";
|
||||||
import { setTitle } from "./scripts/window-functions";
|
import { setTitle } from "./scripts/window-functions";
|
||||||
|
import { TidalApiController } from "./TidalControllers/apiController/TidalApiController";
|
||||||
import { DomControllerOptions } from "./TidalControllers/DomController/DomControllerOptions";
|
import { DomControllerOptions } from "./TidalControllers/DomController/DomControllerOptions";
|
||||||
import { DomTidalController } from "./TidalControllers/DomController/DomTidalController";
|
import { DomTidalController } from "./TidalControllers/DomController/DomTidalController";
|
||||||
import { TidalController } from "./TidalControllers/TidalController";
|
import { TidalController } from "./TidalControllers/TidalController";
|
||||||
import { tidalControllers } from "./constants/controller";
|
|
||||||
|
|
||||||
const notificationPath = `${app.getPath("userData")}/notification.jpg`;
|
const notificationPath = `${app.getPath("userData")}/notification.jpg`;
|
||||||
const staticTitle = "TIDAL Hi-Fi";
|
const staticTitle = "TIDAL Hi-Fi";
|
||||||
@@ -40,8 +41,9 @@ let controllerOptions = {};
|
|||||||
let currentMediaInfo = getEmptyMediaInfo();
|
let currentMediaInfo = getEmptyMediaInfo();
|
||||||
|
|
||||||
switch (settingsStore.get(settings.advanced.controllerType)) {
|
switch (settingsStore.get(settings.advanced.controllerType)) {
|
||||||
case tidalControllers.mediaSessionController: {
|
case tidalControllers.tidalApiController: {
|
||||||
Logger.log("mediaSessionController initialized");
|
tidalController = new TidalApiController();
|
||||||
|
Logger.log("TidalApiController initialized");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -348,11 +350,11 @@ function updateListenBrainz(mediaInfo: MediaInfo) {
|
|||||||
mediaInfo.title,
|
mediaInfo.title,
|
||||||
mediaInfo.artists,
|
mediaInfo.artists,
|
||||||
mediaInfo.status,
|
mediaInfo.status,
|
||||||
convertDurationToSeconds(mediaInfo.duration)
|
convertDurationToSeconds(mediaInfo.duration),
|
||||||
);
|
);
|
||||||
scrobbleWaitingForDelay = false;
|
scrobbleWaitingForDelay = false;
|
||||||
},
|
},
|
||||||
settingsStore.get(settings.ListenBrainz.delay) ?? 0
|
settingsStore.get(settings.ListenBrainz.delay) ?? 0,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user