Adding music took two navigation items that each did half the job. The new Import page has both sources as tabs and one shared list of what was added in this session, with the reason for every failure and a link to the library. From computer: drop several MP3 or WAV files or pick them with a multi-select dialog. Files are imported one by one on a background thread with a progress bar, and a failing file does not stop the rest. Openverse: search and download show a progress ring with a status text. Results that are already in the library or have no duration are marked in their row and cannot be imported; a double-click imports. To detect duplicates, songs now store the Openverse result id. The repository adds the column to existing databases and a unique index keeps one song per Openverse result. Refs #13 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
199 lines
11 KiB
XML
199 lines
11 KiB
XML
<Page x:Class="Radiosender.Views.Pages.ImportPage"
|
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
|
xmlns:ui="http://schemas.lepo.co/wpfui/2022/xaml"
|
|
Title="Import"
|
|
Unloaded="OnUnloaded">
|
|
<Grid Margin="24">
|
|
<Grid.RowDefinitions>
|
|
<RowDefinition Height="Auto" />
|
|
<RowDefinition Height="3*" MinHeight="260" />
|
|
<RowDefinition Height="Auto" />
|
|
<RowDefinition Height="2*" MinHeight="120" />
|
|
</Grid.RowDefinitions>
|
|
|
|
<ui:TextBlock Grid.Row="0" FontTypography="Title" Text="Import" />
|
|
|
|
<TabControl x:Name="Sources" Grid.Row="1" Margin="0,12,0,0">
|
|
<!-- From computer -->
|
|
<TabItem Header="From computer">
|
|
<Grid Margin="0,12,0,0">
|
|
<Grid.RowDefinitions>
|
|
<RowDefinition Height="*" />
|
|
<RowDefinition Height="Auto" />
|
|
</Grid.RowDefinitions>
|
|
|
|
<Grid x:Name="DropZone"
|
|
Background="Transparent"
|
|
AllowDrop="True"
|
|
AutomationProperties.Name="Drop zone for MP3 and WAV files"
|
|
DragEnter="OnDragOver"
|
|
DragOver="OnDragOver"
|
|
DragLeave="OnDragLeave"
|
|
Drop="OnDrop">
|
|
<Rectangle x:Name="DropBorder"
|
|
RadiusX="8"
|
|
RadiusY="8"
|
|
StrokeThickness="2"
|
|
StrokeDashArray="4 3"
|
|
Stroke="{DynamicResource TextFillColorTertiaryBrush}" />
|
|
<StackPanel HorizontalAlignment="Center" VerticalAlignment="Center">
|
|
<ui:SymbolIcon HorizontalAlignment="Center" FontSize="40" Symbol="ArrowUpload24" />
|
|
<ui:TextBlock Margin="0,8,0,0"
|
|
HorizontalAlignment="Center"
|
|
FontTypography="BodyStrong"
|
|
Text="Drop MP3 or WAV files here" />
|
|
<ui:TextBlock Margin="0,4,0,12"
|
|
HorizontalAlignment="Center"
|
|
Foreground="{DynamicResource TextFillColorSecondaryBrush}"
|
|
Text="You can add several files at once." />
|
|
<ui:Button x:Name="ChooseFilesButton"
|
|
HorizontalAlignment="Center"
|
|
Appearance="Primary"
|
|
Content="Choose files..."
|
|
Icon="{ui:SymbolIcon FolderOpen24}"
|
|
Click="OnChooseFiles" />
|
|
</StackPanel>
|
|
</Grid>
|
|
|
|
<StackPanel x:Name="UploadProgressPanel" Grid.Row="1" Margin="0,12,0,0" Visibility="Collapsed">
|
|
<ui:TextBlock x:Name="UploadProgressText" />
|
|
<ProgressBar x:Name="UploadProgress"
|
|
Margin="0,6,0,0"
|
|
AutomationProperties.Name="Upload progress" />
|
|
</StackPanel>
|
|
</Grid>
|
|
</TabItem>
|
|
|
|
<!-- Openverse -->
|
|
<TabItem Header="Openverse">
|
|
<Grid Margin="0,12,0,0">
|
|
<Grid.RowDefinitions>
|
|
<RowDefinition Height="Auto" />
|
|
<RowDefinition Height="Auto" />
|
|
<RowDefinition Height="*" />
|
|
<RowDefinition Height="Auto" />
|
|
</Grid.RowDefinitions>
|
|
|
|
<Grid Grid.Row="0">
|
|
<Grid.ColumnDefinitions>
|
|
<ColumnDefinition Width="*" />
|
|
<ColumnDefinition Width="Auto" />
|
|
</Grid.ColumnDefinitions>
|
|
<ui:TextBox x:Name="QueryBox"
|
|
PlaceholderText="Search free audio, for example "jazz piano""
|
|
AutomationProperties.Name="Search term"
|
|
KeyDown="OnQueryKeyDown" />
|
|
<ui:Button x:Name="SearchButton"
|
|
Grid.Column="1"
|
|
Margin="8,0,0,0"
|
|
Appearance="Primary"
|
|
Content="Search"
|
|
Icon="{ui:SymbolIcon Search24}"
|
|
Click="OnSearch" />
|
|
</Grid>
|
|
|
|
<ui:InfoBar x:Name="Message" Grid.Row="1" Margin="0,12,0,0" IsClosable="True" />
|
|
|
|
<ui:ListView x:Name="Results"
|
|
Grid.Row="2"
|
|
Margin="0,12,0,0"
|
|
SelectionMode="Single"
|
|
AutomationProperties.Name="Search results"
|
|
SelectionChanged="OnSelectionChanged"
|
|
MouseDoubleClick="OnResultDoubleClick">
|
|
<ui:ListView.View>
|
|
<ui:GridView>
|
|
<ui:GridViewColumn Width="300" Header="Title" DisplayMemberBinding="{Binding Track.Title}" />
|
|
<ui:GridViewColumn Width="180" Header="Creator" DisplayMemberBinding="{Binding Track.Creator}" />
|
|
<ui:GridViewColumn Width="80" Header="Duration" DisplayMemberBinding="{Binding Track.DurationText}" />
|
|
<ui:GridViewColumn Width="130" Header="License" DisplayMemberBinding="{Binding Track.LicenseName}" />
|
|
<ui:GridViewColumn Width="150" Header="Status">
|
|
<ui:GridViewColumn.CellTemplate>
|
|
<DataTemplate>
|
|
<ui:TextBlock Text="{Binding Status}" Foreground="{DynamicResource TextFillColorSecondaryBrush}" />
|
|
</DataTemplate>
|
|
</ui:GridViewColumn.CellTemplate>
|
|
</ui:GridViewColumn>
|
|
</ui:GridView>
|
|
</ui:ListView.View>
|
|
</ui:ListView>
|
|
|
|
<StackPanel Grid.Row="3" Margin="0,12,0,0" Orientation="Horizontal">
|
|
<ui:Button x:Name="PreviewButton" Content="Preview" Icon="{ui:SymbolIcon Play24}"
|
|
IsEnabled="False" Click="OnPreview" />
|
|
<ui:Button x:Name="StopButton" Margin="8,0,0,0" Content="Stop" Icon="{ui:SymbolIcon Stop24}"
|
|
IsEnabled="False" Click="OnStop" />
|
|
<ui:Button x:Name="ImportButton" Margin="8,0,0,0" Appearance="Primary"
|
|
Content="Import to library" Icon="{ui:SymbolIcon ArrowDownload24}"
|
|
IsEnabled="False" Click="OnImport" />
|
|
<ui:ProgressRing x:Name="Busy"
|
|
Width="20"
|
|
Height="20"
|
|
Margin="12,0,0,0"
|
|
IsIndeterminate="True"
|
|
Visibility="Collapsed" />
|
|
<ui:TextBlock x:Name="BusyText"
|
|
Margin="8,0,0,0"
|
|
VerticalAlignment="Center"
|
|
Foreground="{DynamicResource TextFillColorSecondaryBrush}" />
|
|
</StackPanel>
|
|
</Grid>
|
|
</TabItem>
|
|
</TabControl>
|
|
|
|
<!-- Added in this session, from both sources -->
|
|
<Grid Grid.Row="2" Margin="0,16,0,0">
|
|
<ui:TextBlock VerticalAlignment="Center" FontTypography="Subtitle" Text="Added in this session" />
|
|
<ui:Button HorizontalAlignment="Right"
|
|
Appearance="Transparent"
|
|
Content="Open library"
|
|
Icon="{ui:SymbolIcon MusicNote224}"
|
|
Click="OnOpenLibrary" />
|
|
</Grid>
|
|
|
|
<ui:ListView x:Name="Session"
|
|
Grid.Row="3"
|
|
Margin="0,8,0,0"
|
|
AutomationProperties.Name="Songs added in this session">
|
|
<ui:ListView.View>
|
|
<ui:GridView>
|
|
<ui:GridViewColumn Width="110" Header="Status">
|
|
<ui:GridViewColumn.CellTemplate>
|
|
<DataTemplate>
|
|
<StackPanel Orientation="Horizontal">
|
|
<ui:SymbolIcon x:Name="Icon"
|
|
Symbol="CheckmarkCircle24"
|
|
Filled="True"
|
|
Foreground="{DynamicResource SystemFillColorSuccessBrush}" />
|
|
<ui:TextBlock x:Name="Label" Margin="6,0,0,0" Text="Added" />
|
|
</StackPanel>
|
|
<DataTemplate.Triggers>
|
|
<DataTrigger Binding="{Binding Success}" Value="False">
|
|
<Setter TargetName="Icon" Property="Symbol" Value="ErrorCircle24" />
|
|
<Setter TargetName="Icon" Property="Foreground" Value="{DynamicResource SystemFillColorCriticalBrush}" />
|
|
<Setter TargetName="Label" Property="Text" Value="Failed" />
|
|
</DataTrigger>
|
|
</DataTemplate.Triggers>
|
|
</DataTemplate>
|
|
</ui:GridViewColumn.CellTemplate>
|
|
</ui:GridViewColumn>
|
|
<ui:GridViewColumn Width="240" Header="Title" DisplayMemberBinding="{Binding Title}" />
|
|
<ui:GridViewColumn Width="160" Header="Artist" DisplayMemberBinding="{Binding Artist}" />
|
|
<ui:GridViewColumn Width="80" Header="Duration" DisplayMemberBinding="{Binding Duration}" />
|
|
<ui:GridViewColumn Width="100" Header="Source" DisplayMemberBinding="{Binding Source}" />
|
|
<ui:GridViewColumn Width="320" Header="Details" DisplayMemberBinding="{Binding Details}" />
|
|
</ui:GridView>
|
|
</ui:ListView.View>
|
|
</ui:ListView>
|
|
|
|
<ui:TextBlock x:Name="SessionEmpty"
|
|
Grid.Row="3"
|
|
Margin="0,32,0,0"
|
|
HorizontalAlignment="Center"
|
|
VerticalAlignment="Top"
|
|
Foreground="{DynamicResource TextFillColorSecondaryBrush}"
|
|
Text="Songs you import appear here." />
|
|
</Grid>
|
|
</Page>
|