chore: giving up on state, reverted to MediaSessionController

This commit is contained in:
2025-04-20 14:25:09 +02:00
parent 4330994b32
commit 53e7f42c59
7 changed files with 271 additions and 294 deletions

View File

@@ -92,34 +92,40 @@ export class DomTidalController implements TidalController<DomControllerOptions>
},
getAlbumName: function () {
//If listening to an album, get its name from the header title
if (globalThis.location.href.includes("/album/")) {
const albumName = globalThis.document.querySelector(this.album_header_title);
if (albumName) {
return albumName.textContent;
}
//If listening to a playlist or a mix, get album name from the list
} else if (
globalThis.location.href.includes("/playlist/") ||
globalThis.location.href.includes("/mix/")
) {
if (this.currentlyPlaying === MediaStatus.playing) {
// find the currently playing element from the list (which might be in an album icon), traverse back up to the mediaItem (row) and select the album cell.
// document.querySelector("[class^='isPlayingIcon'], [data-test-is-playing='true']").closest('[data-type="mediaItem"]').querySelector('[class^="album"]').textContent
const row = window.document.querySelector(this.currentlyPlaying).closest(this.mediaItem);
if (row) {
return row.querySelector(this.album_name_cell).textContent;
try {
//If listening to an album, get its name from the header title
if (globalThis.location.href.includes("/album/")) {
const albumName = globalThis.document.querySelector(this.album_header_title);
if (albumName) {
return albumName.textContent;
}
//If listening to a playlist or a mix, get album name from the list
} else if (
globalThis.location.href.includes("/playlist/") ||
globalThis.location.href.includes("/mix/")
) {
if (this.currentlyPlaying === MediaStatus.playing) {
// find the currently playing element from the list (which might be in an album icon), traverse back up to the mediaItem (row) and select the album cell.
// document.querySelector("[class^='isPlayingIcon'], [data-test-is-playing='true']").closest('[data-type="mediaItem"]').querySelector('[class^="album"]').textContent
const row = window.document
.querySelector(this.currentlyPlaying)
.closest(this.mediaItem);
if (row) {
return row.querySelector(this.album_name_cell).textContent;
}
}
}
}
// see whether we're on the queue page and get it from there
const queueAlbumName = this.getText("queue_album");
if (queueAlbumName) {
return queueAlbumName;
}
// see whether we're on the queue page and get it from there
const queueAlbumName = this.getText("queue_album");
if (queueAlbumName) {
return queueAlbumName;
}
return "";
return "";
} catch {
return "";
}
},
isMuted: function () {

View File

@@ -5,7 +5,7 @@ import { RepeatState } from "../../models/repeatState";
import { DomTidalController } from "../DomController/DomTidalController";
import { TidalController } from "../TidalController";
export class StateController implements TidalController {
export class MediaSessionController implements TidalController {
public domMediaController: TidalController;
constructor() {
@@ -135,8 +135,4 @@ export class StateController implements TidalController {
globalThis.alert("Method not implemented");
throw new Error("Method not implemented.");
}
hookup(): void {
globalThis.alert("Method not implemented");
throw new Error("Method not implemented.");
}
}

View File

@@ -1,4 +1,4 @@
export const tidalControllers = {
domController: "domController",
stateController: "stateController",
mediaSessionController: "mediaSessionController",
};

View File

@@ -388,7 +388,7 @@
<p>Select the type of controller to use.</p>
<select id="controllerType" class="select-input">
<option value="domController">DOM Controller</option>
<option value="stateController">State Controller</option>
<option value="mediaSessionController">Media Session Controller</option>
</select>
</div>
</div>

View File

@@ -40,8 +40,8 @@ let controllerOptions = {};
let currentMediaInfo = getEmptyMediaInfo();
switch (settingsStore.get(settings.advanced.controllerType)) {
case tidalControllers.stateController: {
Logger.log("stateController initialized");
case tidalControllers.mediaSessionController: {
Logger.log("mediaSessionController initialized");
break;
}