Skip to content

Commit 3d77127

Browse files
committed
Remove extra code
1 parent d2d3c3b commit 3d77127

4 files changed

Lines changed: 62 additions & 468 deletions

File tree

HomeSpeaker.WebAssembly/Components/Music/Player/LocalAudioPlayerSimple.razor

Lines changed: 0 additions & 226 deletions
This file was deleted.

HomeSpeaker.WebAssembly/Components/Music/Player/PlayButtonWithDropdown.razor

Lines changed: 50 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
@using HomeSpeaker.WebAssembly.Services
2+
@using HomeSpeaker.WebAssembly.Models
23
@using Microsoft.JSInterop
4+
@using System.Linq
35
@inject IPlaybackModeService playbackModeService
46
@inject HomeSpeakerService homeSpeakerService
57
@inject ILocalQueueService localQueueService
@@ -138,18 +140,57 @@
138140
{
139141
if (string.IsNullOrEmpty(FolderName)) return;
140142

141-
// For now, show a message that this feature is not yet implemented
142-
// TODO: Get folder songs from server and add to local queue
143-
await JsRuntime.InvokeVoidAsync("alert", "Local folder playback not yet fully implemented. Please play individual songs instead.");
144-
}
145-
146-
private async Task PlayPlaylistLocallyAsync()
143+
try
144+
{
145+
// Get folder songs from server
146+
var folderSongs = await homeSpeakerService.GetSongsInFolder(FolderName);
147+
var songViewModels = folderSongs.ToList();
148+
149+
if (songViewModels.Any())
150+
{
151+
await localQueueService.PlaySongsAsync(songViewModels);
152+
}
153+
else
154+
{
155+
await JsRuntime.InvokeVoidAsync("alert", $"Folder '{FolderName}' contains no songs.");
156+
}
157+
}
158+
catch (Exception ex)
159+
{
160+
await JsRuntime.InvokeVoidAsync("alert", $"Error playing folder locally: {ex.Message}");
161+
}
162+
}private async Task PlayPlaylistLocallyAsync()
147163
{
148164
if (string.IsNullOrEmpty(PlaylistName)) return;
149165

150-
// For now, show a message that this feature is not yet implemented
151-
// TODO: Get playlist songs from server and add to local queue
152-
await JsRuntime.InvokeVoidAsync("alert", "Local playlist playback not yet fully implemented. Please play individual songs instead.");
166+
try
167+
{
168+
// Get playlist data from server
169+
var playlists = await homeSpeakerService.GetPlaylistsAsync();
170+
var playlist = playlists.FirstOrDefault(p => p.Name == PlaylistName);
171+
172+
if (playlist == null)
173+
{
174+
await JsRuntime.InvokeVoidAsync("alert", $"Playlist '{PlaylistName}' not found.");
175+
return;
176+
}
177+
178+
// Convert playlist songs to SongViewModels and play them locally
179+
var songViewModels = playlist.Songs.Select(s => s.ToSongViewModel()).ToList();
180+
181+
if (songViewModels.Any())
182+
{
183+
await localQueueService.PlaySongsAsync(songViewModels);
184+
}
185+
else
186+
{
187+
await JsRuntime.InvokeVoidAsync("alert", $"Playlist '{PlaylistName}' is empty.");
188+
}
189+
}
190+
catch (Exception ex)
191+
{
192+
await JsRuntime.InvokeVoidAsync("alert", $"Error playing playlist locally: {ex.Message}");
193+
}
153194
}
154195

155196
protected override async Task OnAfterRenderAsync(bool firstRender)

HomeSpeaker.WebAssembly/Models/SongViewModel.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,18 @@ public static SongViewModel ToSongViewModel(this SongMessage song)
4848
Path = song?.Path?.Trim()
4949
};
5050
}
51+
52+
public static SongViewModel ToSongViewModel(this HomeSpeaker.Shared.Song song)
53+
{
54+
return new SongViewModel
55+
{
56+
SongId = song?.SongId ?? -1,
57+
Name = song?.Name?.Trim() ?? "[ Null Song Response ??? ]",
58+
Album = song?.Album?.Trim() ?? "[ No Album ]",
59+
Artist = song?.Artist?.Trim() ?? "[ No Artist ]",
60+
Path = song?.Path?.Trim()
61+
};
62+
}
5163
//public async static IAsyncEnumerable<T> ReadAllAsync<T>(this IAsyncStreamReader<T> streamReader, CancellationToken cancellationToken = default)
5264
//{
5365
// if (streamReader == null)

0 commit comments

Comments
 (0)