feat: stream live to laut.fm and import from its library
The Settings page gets a laut.fm card: a switch, the live access data from Radioadmin (server, port, mountpoint, user, password) and the station id and Radioadmin token for the library. Password and token are written to settings.json encrypted with DPAPI for the Windows user. While laut.fm is on, the Schedule page shows a Live button next to "Jetzt starten". It logs in at the Icecast server with PUT and sends a copy of the broadcast mix as MP3 at 128 kbit/s, encoded by Windows Media Foundation. ProgramOutput hands that copy out through a live feed. Each item that starts sets the stream title; ad items send START_AD_BREAK at most once every 15 minutes. LautFmProvider searches the station's tracks through the Radioadmin API and the Import page lists it while laut.fm is on, so laut.fm tracks are imported into the same library as local songs. Providers can now hide themselves with IsAvailable. Nothing was tested against a real laut.fm account; the tests use a local fake server and fake HTTP answers. Refs #15 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
5d261717fe
commit
a94fb862d2
16 files changed
+999
-16
No files matched your search
@@ -29,7 +29,7 @@ The interface is in German. This section names the controls as they appear on sc
|
||||
|
||||
1. **Import**: one page for both ways of adding music. Every result, added or failed, is listed under "Importiert" as soon as there is one, with a link to the library.
|
||||
- **Vom Computer**: drop MP3 or WAV files on the page or click **Dateien auswählen...**; several files at once are fine. The app copies each file into the music folder, reads title and artist from the file tags and measures the duration. A file that fails is reported and the others still get imported.
|
||||
- **Online**: choose Openverse or the Internet Archive in the list next to the search box. Search the catalog, preview a result and import it with **In Bibliothek importieren** or a double-click. Select several results with Ctrl or Shift to import them in one go; they are downloaded one after the other. The app downloads the file and stores its license and attribution with the song. Results that are already in the library or have no duration cannot be imported; the tooltip of the disabled button says why.
|
||||
- **Online**: choose Openverse, the Internet Archive or, while laut.fm is switched on, laut.fm in the list next to the search box. Search the catalog, preview a result and import it with **In Bibliothek importieren** or a double-click. Select several results with Ctrl or Shift to import them in one go; they are downloaded one after the other. The app downloads the file and stores its license and attribution with the song. Results that are already in the library or have no duration cannot be imported; the tooltip of the disabled button says why.
|
||||
2. **Bibliothek**: lists and searches all songs. Edit title, artist, license and attribution, or delete a song.
|
||||
3. **Sendeplan** (the start page):
|
||||
1. Choose the start (one of the next 12 full hours) and the number of hours (1 to 24), then click **Plan erstellen**.
|
||||
@@ -42,8 +42,9 @@ The interface is in German. This section names the controls as they appear on sc
|
||||
6. **Microphone**: **Mikro ein** in the now-playing card puts the default microphone on air, also over running music; the button turns red and reads **Mikro aus**. It works with or without a broadcast and stays on while you visit other pages.
|
||||
7. **Mix levels**, below the now-playing row: **Musik für andere** and **Ich für andere** set how loud the music and the microphone are for the listeners, **Musik für mich** how loud the music is on your own device. **Sendung 1:1 hören** lets you hear exactly what the listeners hear. The slider next to the loudspeaker stays the overall music volume.
|
||||
8. **Songwunsch**: choose a song, select an upcoming row in the timeline and click **Auswahl ersetzen**. This also works while the broadcast is running.
|
||||
9. **Live** (only while laut.fm is switched on): sends everything on air, songs and microphone, live to your laut.fm station. It does not depend on the plan; the button turns red and reads **Live beenden**. See [laut.fm](#lautfm).
|
||||
|
||||
4. **Einstellungen** (bottom left): switch the speaking alert on or off for news and for moderator talk, set how many seconds before the start it appears and whether it plays a bing sound. Choose the playback device for the broadcast (for the listeners) and, if you have a second one such as headphones, the device for yourself. Set the minutes per hour for news, moderator talk and ads (defaults 10, 10 and 20); together they can take at most 60 minutes. **ZurĂĽcksetzen** puts the default values into the form, **Speichern** stores them in `settings.json` next to the database. Alerts change at once; minutes per hour apply to the next schedule.
|
||||
4. **Einstellungen** (bottom left): switch the speaking alert on or off for news and for moderator talk, set how many seconds before the start it appears and whether it plays a bing sound. Choose the playback device for the broadcast (for the listeners) and, if you have a second one such as headphones, the device for yourself. Set the minutes per hour for news, moderator talk and ads (defaults 10, 10 and 20); together they can take at most 60 minutes. **ZurĂĽcksetzen** puts the default values into the form, **Speichern** stores them in `settings.json` next to the database. Alerts change at once; minutes per hour apply to the next schedule. The **laut.fm** switch turns on live streaming and the station's library; its fields are described under [laut.fm](#lautfm).
|
||||
|
||||
News, ads and moderator talk are placeholders: the app shows them in the timeline and keeps silent for their duration, so the speaker can talk live.
|
||||
|
||||
@@ -68,7 +69,7 @@ The app follows the MVC pattern and uses [WPF UI](https://github.com/lepoco/wpfu
|
||||
| --- | --- | --- |
|
||||
| Model | `src/Radiosender/Models` | `Song`, `ScheduleItem`, `MusicTrack`, `OpenverseTrack` |
|
||||
| View | `src/Radiosender/Views` | `MainWindow` with navigation, one page per feature, `SongEditWindow` |
|
||||
| Controller | `src/Radiosender/Controllers` | `LibraryController`, `UploadController`, `OnlineImportController`, `ScheduleController` |
|
||||
| Controller | `src/Radiosender/Controllers` | `LibraryController`, `UploadController`, `OnlineImportController`, `ScheduleController`, `LiveController` |
|
||||
| Services | `src/Radiosender/Services` | database, audio, schedule logic and API access used by the controllers |
|
||||
|
||||
Views only handle input and display. They call a controller, and the controller works with the models and services. `App` is the composition root: it registers every service, controller and page in a `Microsoft.Extensions.DependencyInjection` container, and the navigation view asks that container for each page, so pages get their controllers through the constructor. The `SongRepository` and the `ScheduleController` are singletons. A running broadcast therefore keeps playing when the user switches pages.
|
||||
@@ -77,7 +78,7 @@ Main services:
|
||||
|
||||
- `SongRepository`: CRUD for songs in SQLite through Entity Framework Core, without SQL in the code
|
||||
- `SongImportService`: copies an uploaded file into the music folder, reads its tags with TagLibSharp and its duration with NAudio
|
||||
- `IMusicProvider`: an online catalog that can be searched. `OpenverseProvider` uses the anonymous Openverse API and `InternetArchiveProvider` the Internet Archive search, limited to Creative Commons licensed MP3 files.
|
||||
- `IMusicProvider`: an online catalog that can be searched. `OpenverseProvider` uses the anonymous Openverse API and `InternetArchiveProvider` the Internet Archive search, limited to Creative Commons licensed MP3 files. `LautFmProvider` searches the library of the user's laut.fm station.
|
||||
- `TrackDownloader`: downloads a search result into the music folder, the same way for every provider
|
||||
- `ProgramMixer`: mixes songs and the microphone twice in one pass, once for the listeners and once for the person at the desk, each with its own levels
|
||||
- `ProgramOutput`: the station's audio channel. It plays the broadcast mix on one device and, if a second device is chosen, the monitor mix on that one
|
||||
@@ -85,8 +86,9 @@ Main services:
|
||||
- `Microphone`: captures the default recording device and puts it on the `ProgramOutput`
|
||||
- `ScheduleGenerator`: builds the plan and handles song requests
|
||||
- `PlaybackEngine`: runs the plan item by item on a background thread and plays songs through `MusicPlayer`
|
||||
- `IcecastStream`: logs in at an Icecast server as a live source, encodes a copy of the broadcast mix to MP3 with Windows Media Foundation and sends it. `LiveController` starts and stops it and sets the stream title for each item through `StreamTitles`
|
||||
|
||||
Tests are in `tests/Radiosender.Tests` (xUnit). They cover the repository, import, Openverse parsing, the generator rules, the playback engine and the schedule controller.
|
||||
Tests are in `tests/Radiosender.Tests` (xUnit). They cover the repository, import, Openverse parsing, the generator rules, the playback engine, the schedule controller and laut.fm (settings, Icecast login, ad trigger, track parsing).
|
||||
|
||||
## Adding a music provider
|
||||
|
||||
@@ -95,6 +97,7 @@ Online sources sit behind `IMusicProvider`, so a new one needs no change to the
|
||||
1. Write a class that implements `IMusicProvider`: a `Name` for the interface and `SearchAsync`, which returns `MusicTrack` items (title, creator, https link to the audio file, license, attribution, duration).
|
||||
2. Give every track an `Id` that no other provider uses, for example prefixed with the provider name. Openverse ids are stored as they come.
|
||||
3. Register the class in `App.BuildServices` with `services.AddSingleton<IMusicProvider, YourProvider>()`.
|
||||
4. A provider that depends on a setting can return `false` from `IsAvailable`; the import page then leaves it out.
|
||||
|
||||
With one provider the import tab carries its name. With several, the tab is called "Online" and a list next to the search box chooses the provider.
|
||||
|
||||
@@ -124,6 +127,28 @@ For each downloaded track the app stores the license (for example `CC BY 4.0`) a
|
||||
| The player really plays music | `MusicPlayer` with NAudio | Done |
|
||||
| C#, WPF with MVC, WPF UI | .NET 10, folders above, WPF UI 4.3 | Done |
|
||||
|
||||
## laut.fm
|
||||
|
||||
With laut.fm switched on in the settings, the app streams live to a [laut.fm](https://laut.fm) station and offers the station's music on the Import page.
|
||||
|
||||
1. In Radioadmin, open **Live senden** and copy server, port, mountpoint, user and password into the laut.fm card on the Settings page. Save.
|
||||
2. For the library, enter the station id and the Radioadmin token. The token is the value of `laut.fm.api.token` in the browser's local storage after logging in to Radioadmin (developer tools).
|
||||
3. On the Sendeplan page, **Live** connects to laut.fm and sends the broadcast mix as MP3 at 128 kbit/s. laut.fm then plays the live stream instead of the station's regular program.
|
||||
|
||||
The app connects as an Icecast source (`PUT` to the mountpoint with the user and password). Each item that starts sets the stream title: `Artist - Title` for songs and the item title otherwise. Ad items send `START_AD_BREAK`, which laut.fm needs to start its ad break; the app sends it at most once every 15 minutes, as laut.fm requires.
|
||||
|
||||
Password and token are stored in `settings.json` encrypted with Windows DPAPI for the current Windows user. Another user or computer cannot read them and has to enter them again.
|
||||
|
||||
Risks:
|
||||
|
||||
- The library uses the API behind Radioadmin (`api.radioadmin.laut.fm`). laut.fm does not publish it for other programs, so it can change or stop working without notice, and the token expires when Radioadmin logs out.
|
||||
- The import downloads the prelisten link that Radioadmin uses. Whether that is the full track or a shorter preview has not been checked against a real station.
|
||||
- laut.fm licenses the station's music for broadcasting on laut.fm. Imported laut.fm tracks are marked with that license and must not be played anywhere else.
|
||||
- Nothing here has been tested against a real laut.fm account. The tests run against a local fake server. If laut.fm expects a different format or login method, the settings show the error but do not adapt.
|
||||
- The source connection and the title updates use plain HTTP, like every Icecast source client, so the live password crosses the network unencrypted.
|
||||
- The MP3 encoder comes with Windows. Windows "N" editions lack it until the Media Feature Pack is installed; **Live** then reports the missing encoder.
|
||||
- laut.fm wants the ad trigger at least once every half hour. With 0 ad minutes per hour the plan has no ad items and the app never sends it.
|
||||
|
||||
## Known limitations
|
||||
|
||||
- **Waiting for the start**: a plan made with **Plan erstellen** starts at a full hour, so after **Start** the app stays silent until then. **Jetzt starten** avoids the wait.
|
||||
|
||||
Reference in new issue
Block a user