PlaybackEngine plays a generated schedule from start to end without
user input. Songs play through the MusicPlayer singleton and the next
item starts on TrackFinished. News, ads and moderator placeholders are
held for their duration.
A song that cannot be started, or that does not finish within its
length plus 10 seconds, raises ItemFailed and the engine moves on, so
one broken file or a device error does not stop the broadcast.
Start replaces a running schedule and Stop ends playback.
MusicPlayer now implements a small IAudioPlayer interface so the
engine can be tested with a fake player and a fake delay.
Refs #9
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
ScheduleGenerator plans X full hours in half-hour slots. Each slot
starts with 5 minutes of news at :00 or :30, then random songs from
the library. Ads and moderator placeholders fill the remaining gap so
the last song of the slot ends exactly when the next news starts, and
no song is cut.
Each half hour gets 2 to 10 minutes of ads and moderator talk, which
keeps every hour within the 20 minute limit. Ads alternate with
moderator segments and are capped by a configurable MaxAdBlock, so no
ad block comes close to 20 minutes. If the library cannot fill a slot,
the generator throws a ScheduleException with a hint to add songs.
Unit tests cover every rule over several random seeds.
Refs #8
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Add an Openverse page that searches free audio through the anonymous
Openverse API, previews a result by streaming its URL with MediaPlayer
and imports it into the library.
OpenverseClient uses HttpClient with a timeout and a generic User-Agent.
It downloads only the result's https URL, limits files to 50 MB, never
overwrites an existing file and deletes partial files on failure.
Timeouts, HTTP 429 and other errors become readable messages. Imported
songs get Source = Openverse plus license and attribution from the API.
Results without a duration cannot be imported, because songs need one.
Refs #5
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Add an Upload page where the user picks an MP3 or WAV file. The new
SongImportService copies it into %LOCALAPPDATA%\Radiosender\Music under
a unique name, reads the duration with NAudio and title/artist from tags
with TagLibSharp (falling back to the file name), and saves the song
with Source = Upload. Wrong extensions, unreadable files, garbage data
and files without audio are rejected; the copied file is deleted again
so nothing is left behind. The page shows the result in a Snackbar.
The music folder is injected so the service is testable without UI.
Tests cover a generated WAV, duplicate names, wrong extension, garbage
files, empty audio and missing files.
Refs #4
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Add MusicPlayer, a thread-safe lazy singleton that plays one audio
file at a time through NAudio 3.3.0 (WaveOut and AudioFileReader).
It offers Play, Pause, Resume, Stop, Position, Duration, Volume and
IsPlaying, plus TrackFinished and PositionChanged events. The station
needs one shared playback point that later schedule and UI code can
drive.
TrackFinished fires only when a track ends on its own. Stop and Play
unsubscribe from the old output before releasing it, so they never
raise it. Both events run on a thread-pool thread, so WPF callers
must marshal to the dispatcher. Reader and output are disposed on
stop, on replacement and on process exit. A missing file throws
FileNotFoundException and an unreadable one InvalidDataException;
in both cases the player stays stopped.
Tests cover the singleton, error cases and events. Tests that need an
audio device skip when none is present.
Refs #6
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Add a Library page reachable from the navigation. It lists all songs
from the SQLite database, filters them by title or artist, edits title,
artist, license and attribution in a dialog, and deletes a song after a
confirmation prompt. File path, duration and source stay read-only.
LibraryController wraps SongRepository so the view only forwards user
actions. Changes are written to the database immediately, and the list
reloads every time the page is shown.
Refs #3
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Add AdSpot and ModeratorSegment models with Title and Duration and a
read-only in-memory seed list for each in PlaceholderContent. Ads and
moderator talk are placeholders without audio, so no database table is
needed. Lengths vary (ads 30 s to 2 min, moderator 30 s to 3 min) so the
schedule generator can size these segments to end songs exactly before
the news. Tests check the lists are non-empty with titles and positive
durations.
Refs #7
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Store the music library in SQLite through Microsoft.Data.Sqlite.
SongRepository creates the database file and the Songs table if they
are missing and offers GetAll, GetById, Add, Update and Delete with
parameterized queries. The app opens the database on startup at
%LOCALAPPDATA%\Radiosender\radiosender.db.
Add an xUnit test project that covers CRUD, persistence across
instances, SQL characters in values and the duration check.
Refs #2
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Add the Radiosender solution on .NET 10 with the WPF-UI 4.3.0 package.
The main window is a FluentWindow with a title bar and a NavigationView
that opens a home page. Models, Controllers and Services folders hold
the MVC structure for the next issues. Replace the GitLab template
README with build instructions.
Refs #1
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>