Merge branch 'master' of github.com:Mastermindzh/tidal-hifi

This commit is contained in:
Ottomated 2024-05-16 19:33:18 -07:00
commit da0893392a
9 changed files with 32 additions and 7 deletions

View File

@ -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/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [5.12.0]
- Added Shuffle and Repeat state to API response - By [ThatGravyBoat](https://github.com/ThatGravyBoat)
## [5.11.0]
- Re-implemented the API, added support for duration/current in seconds & shuffle+repeat

4
package-lock.json generated
View File

@ -1,12 +1,12 @@
{
"name": "tidal-hifi",
"version": "5.11.0",
"version": "5.12.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "tidal-hifi",
"version": "5.11.0",
"version": "5.12.0",
"license": "MIT",
"dependencies": {
"@electron/remote": "^2.1.2",

View File

@ -1,6 +1,6 @@
{
"name": "tidal-hifi",
"version": "5.11.0",
"version": "5.12.0",
"description": "Tidal on Electron with widevine(hifi) support",
"main": "ts-dist/main.js",
"scripts": {

View File

@ -2,6 +2,8 @@ import { TidalState } from "../models/tidalState";
export const mainTidalState: TidalState = {
status: "Stopped",
repeat: "Off",
shuffle: false,
};
export function getLegacyMediaInfo() {
@ -25,5 +27,10 @@ export function getLegacyMediaInfo() {
durationInSeconds: mainTidalState.currentTrack?.duration ?? 0,
image: "tidal-hifi-icon",
favorite: false,
player: {
status: mainTidalState.status.toLowerCase(),
shuffle: mainTidalState.shuffle,
repeat: mainTidalState.repeat,
},
};
}

View File

@ -1,5 +1,7 @@
export type TidalState = {
status: "Playing" | "Paused" | "Stopped";
repeat: "Off" | "All" | "Single";
shuffle: boolean;
currentTrack?: {
id: number;
title: string;

View File

@ -433,7 +433,7 @@
<h4>TIDAL Hi-Fi</h4>
<div class="about-section__version">
<a target="_blank" rel="noopener"
href="https://github.com/Mastermindzh/tidal-hifi/releases/tag/5.11.0">5.11.0</a>
href="https://github.com/Mastermindzh/tidal-hifi/releases/tag/5.12.0">5.12.0</a>
</div>
<div class="about-section__links">
<a target="_blank" rel="noopener" href="https://github.com/mastermindzh/tidal-hifi/"

View File

@ -85,7 +85,7 @@ export type ReduxState = {
};
};
const enum RepeatMode {
export const enum RepeatMode {
REPEAT_OFF = 0,
REPEAT_ALL = 1,
REPEAT_SINGLE = 2,

View File

@ -1,4 +1,4 @@
import { getTidalReduxStore, ReduxState, TidalReduxStore } from "./redux";
import { getTidalReduxStore, ReduxState, RepeatMode, TidalReduxStore } from "./redux";
import { createStore } from "zustand/vanilla";
import { ipcRenderer } from "electron";
import { globalEvents } from "../constants/globalEvents";
@ -7,6 +7,8 @@ import { TidalState } from "../models/tidalState";
export const $tidalState = createStore<TidalState>(() => ({
status: "Stopped",
repeat: "Off",
shuffle: false,
}));
export let reduxStore: TidalReduxStore | undefined;
@ -133,8 +135,10 @@ export const coverArtPaths = new Map<string, Promise<string>>();
};
}
const oldState = $tidalState.getState();
const newState = {
const newState: TidalState = {
status: playbackStatusMap[state.playbackControls.playbackState] ?? "Stopped",
repeat: repeatModeMap[state.playQueue.repeatMode] ?? "Off",
shuffle: state.playQueue.shuffleModeEnabled,
currentTrack: track,
};
if (!equal(oldState, newState)) {
@ -153,3 +157,9 @@ const playbackStatusMap = {
IDLE: "Stopped",
STALLED: "Stopped",
} as const;
const repeatModeMap = {
[RepeatMode.REPEAT_OFF]: "Off",
[RepeatMode.REPEAT_ALL]: "All",
[RepeatMode.REPEAT_SINGLE]: "Single",
} as const;

View File

@ -3,4 +3,6 @@ import { TidalState } from "../models/tidalState";
// This object is globally mutated
export const tidalState: TidalState = {
status: "Stopped",
repeat: "Off",
shuffle: false,
};