# NobexStreamer Agent — Windows Setup

Desktop streaming agent for the Nobex Radio Platform. Runs your station's
automation (Liquidsoap) locally and connects it to the Nobex backend and your
station's Icecast mount.

## 1. Requirements

| Component | Why | Where |
|---|---|---|
| NobexStreamer.exe | The agent (this folder) | — |
| Liquidsoap **2.2.5 win64** | Streaming engine | https://github.com/savonet/liquidsoap/releases/download/v2.2.5/liquidsoap-2.2.5-win64.zip |
| FFmpeg (essentials build) | Mic capture + device listing | https://www.gyan.dev/ffmpeg/builds/ffmpeg-release-essentials.zip |

Any Liquidsoap 2.1+ works — the agent's generated config is validated against
2.1.4, 2.2.5, and 2.3.1. 2.2.5 is the recommended Windows build.

## 2. Install

1. Create a folder, e.g. `C:\NobexStreamer`, and put `NobexStreamer.exe` in it.
2. Extract the Liquidsoap zip **into the same folder** (so you end up with
   `C:\NobexStreamer\liquidsoap-2.2.5-win64\liquidsoap.exe`).
   The agent auto-detects Liquidsoap next to its exe, in `C:\`,
   `Program Files`, `%LOCALAPPDATA%`, or PATH.
3. Extract FFmpeg and either:
   - copy `bin\ffmpeg.exe` next to `NobexStreamer.exe`, **or**
   - extract the whole `ffmpeg-*` folder into `C:\` (agent finds
     `C:\ffmpeg*\bin\ffmpeg.exe`), **or**
   - add FFmpeg's `bin` to PATH.

## 3. Connect to your station

1. Double-click `NobexStreamer.exe` (first run: `NobexStreamer.exe --setup` from
   a terminal, or use the Settings dialog).
2. The API endpoint defaults to `https://streaming-api.nobexpartners.com`
   (Nobex production). Keep it unless you're testing against another backend.
3. In the Nobex dashboard, open your station → **Connection** page and copy:
   - Station ID
   - API Key (`nbx_...`)
   - API Secret
4. Enter them in the agent's setup/settings and save. The agent authenticates,
   opens a WebSocket to the backend (wss), and reports Online in the dashboard.

Config is stored at `%USERPROFILE%\.nobex-streamer\config.json`,
logs at `%USERPROFILE%\.nobex-streamer\logs\`.

## 4. First-run checks

- **Windows Defender Firewall** will prompt on first launch — click **Allow**
  (private networks is enough). The agent listens on port **8001** (Liquidsoap
  harbor for live input) and makes outbound HTTPS/WSS connections.
- SmartScreen may warn because the exe is unsigned — choose
  *More info → Run anyway*.
- In the agent window, press **Start** — Liquidsoap should launch and the
  dashboard should show the station streaming (auto mode).

## 5. Going live from DJ software

Point Mixxx / VirtualDJ / BUTT at:

- Server: `localhost`, Port: `8001`, Mount: `/live`
- Username: `source`, Password: your **API Secret**
- Format: MP3

When a live source connects, the agent switches from autoDJ to live with a
crossfade, and back when it disconnects.

## 6. Troubleshooting

- **"Liquidsoap binary not found"** — check the Liquidsoap folder sits next to
  `NobexStreamer.exe`, or set the full path in Settings → Advanced.
- **"ffmpeg not found"** — place `ffmpeg.exe` next to the agent exe or add it
  to PATH (needed only for microphone capture from the agent itself).
- **Agent shows offline in dashboard** — verify credentials, and that
  `https://streaming-api.nobexpartners.com/health` opens in a browser.
- **No audio devices listed** — install FFmpeg (device listing uses FFmpeg's
  DirectShow enumeration).
- Logs: `%USERPROFILE%\.nobex-streamer\logs\nobex-streamer-YYYY-MM-DD.log` and
  `liquidsoap.log`.

## Run as a Windows service (optional)

Use [NSSM](https://nssm.cc/):

```
nssm install NobexStreamer "C:\NobexStreamer\NobexStreamer.exe"
nssm start NobexStreamer
```
