mirror of
https://github.com/Mastermindzh/tidal-hifi.git
synced 2025-08-03 19:41:28 +02:00
chore: giving up on state, reverted to MediaSessionController
This commit is contained in:
@@ -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 () {
|
||||
|
@@ -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.");
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user