More rich metadata with NowPlaying
This commit is contained in:
@@ -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();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user