feat: show last played songs in web ui

This commit is contained in:
Felipe M 2025-05-13 12:49:59 +02:00
parent 7f16452a99
commit bcc1bce743
Signed by: fmartingr
GPG key ID: CCFBC5637D4000A8
6 changed files with 206 additions and 7 deletions

View file

@ -149,9 +149,10 @@ func (s *Server) handleStatic(w http.ResponseWriter, r *http.Request) {
// StatusResponse contains the jukebox status
type StatusResponse struct {
IsPlaying bool `json:"isPlaying"`
CurrentSong *subsonic.Song `json:"currentSong"`
UpdateTime string `json:"updateTime"`
IsPlaying bool `json:"isPlaying"`
CurrentSong *subsonic.Song `json:"currentSong"`
SongHistory []*subsonic.Song `json:"songHistory"`
UpdateTime string `json:"updateTime"`
}
// handleStatus returns the current jukebox status as JSON
@ -165,11 +166,13 @@ func (s *Server) handleStatus(w http.ResponseWriter, r *http.Request) {
// getStatus returns the current status
func (s *Server) getStatus() StatusResponse {
currentSong := s.jukebox.GetCurrentSong()
songHistory := s.jukebox.GetSongHistory()
isPlaying := s.bot.IsPlaying()
return StatusResponse{
IsPlaying: isPlaying,
CurrentSong: currentSong,
SongHistory: songHistory,
UpdateTime: time.Now().Format(time.RFC3339),
}
}