More rich metadata with NowPlaying

This commit is contained in:
2025-02-15 22:15:59 -08:00
parent d465dbf6fb
commit a3801f6698
7 changed files with 72 additions and 26 deletions

View File

@@ -2,7 +2,7 @@ import React, { useState, useEffect, useCallback } from 'react';
import SongTable from './SongTable';
import NowPlaying from './NowPlaying';
import AddSongPanel from './AddSongPanel';
import { API, PlaylistItem } from '../api/player';
import { API, getDisplayTitle, PlaylistItem } from '../api/player';
const App: React.FC = () => {
const [isPlaying, setIsPlaying] = useState(false);
@@ -20,8 +20,8 @@ const App: React.FC = () => {
const fetchNowPlaying = useCallback(async () => {
const nowPlaying = await API.getNowPlaying();
setNowPlayingSong(nowPlaying.nowPlaying);
setNowPlayingFileName(nowPlaying.currentFile);
setNowPlayingSong(getDisplayTitle(nowPlaying.playingItem));
setNowPlayingFileName(nowPlaying.playingItem.filename);
setIsPlaying(!nowPlaying.isPaused);
if (!volumeSettingIsLocked) {
@@ -29,11 +29,15 @@ const App: React.FC = () => {
}
}, [volumeSettingIsLocked]);
const handleAddURL = (url: string) => {
const handleAddURL = async (url: string) => {
const urlToAdd = url.trim();
if (urlToAdd) {
API.addToPlaylist(urlToAdd);
await API.addToPlaylist(urlToAdd);
fetchPlaylist();
if (!isPlaying) {
await API.play();
}
}
};