=== Simple Radio Forty Two ===

Contributors: tlloancy
Tags: radio, player, streaming, music, audio, vanilla-js, icecast, multi-station
Requires at least: 5.0
Tested up to: 7.1
Requires PHP: 7.4
Stable tag: 2.2.0
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

A shortcode and Gutenberg radio player for Icecast, SomaFM, and Radio Paradise streams, with lock-screen Media Session controls.

== Description ==

Simple Radio Forty Two is a small radio player for WordPress, inspired by Radio 42. It is written in vanilla JavaScript (no jQuery). You configure stations once, then drop the player on any page with `[sr42_radio]` or the **Simple Radio Forty Two** block.

**What it does**

- Plays Icecast / MPC, SomaFM, and Radio Paradise streams from a dropdown.
- Shows now-playing metadata (artist, title, next track when the source provides it) via the REST route `/wp-json/sr42/v1/meta`.
- On supporting mobile browsers, uses the **Media Session API**: lock-screen title, artwork, play/pause, and previous/next station.
- Remembers the last station and volume in `localStorage`. If you navigate to another page that also contains the player, it tries to resume playback. See the FAQ: browsers often block that autoplay.
- Optional custom title and button/background images under **Simple Radio → Styling**.
- Optional **Find stations** on Settings: the public [Radio Browser](https://www.radio-browser.info/) directory fetches real streams. If WordPress AI is enabled, it assembles a 3–6 station lineup **only from those results** (no invented URLs). Without AI, the first six hits fill the form. Nothing is saved until you click Save Changes.

This plugin does **not** keep audio playing across a full page load by itself (no background Service Worker). Media Session controls work while the tab that started playback stays open, including with the phone locked.

== Installation ==

1. Install from Plugins → Add New, or upload the plugin folder to `/wp-content/plugins/`.
2. Activate **Simple Radio Forty Two**.
3. Open **Simple Radio → Settings** and add or edit stations.
4. Insert `[sr42_radio]` in a page, or add the **Simple Radio Forty Two** block in the editor.

== Configuration ==

1. **Simple Radio** — copy the shortcode.
2. **Settings** — station name, stream URL, and server type (Icecast / SomaFM / Radio Paradise).
3. **Styling** — title and image URLs, with a live preview. Save to apply on the public player.

== Usage ==

- Shortcode: `[sr42_radio]`
- Block: **Simple Radio Forty Two** (Media category). Dynamic render: the same HTML as the shortcode. Stations always come from Settings (no per-block station list).

There is no separate classic widget. On a classic widget screen you can put the shortcode in a Shortcode or Custom HTML widget.

== FAQ ==

= Why is there a “Please wait” message at startup? =

On the default Radio 42 Icecast stream, the player briefly buffers (about five seconds) so the first play is less likely to stutter. Other stations skip that wait.

= Does it remember my station after a refresh? =

Yes. The last stream URL is stored in `localStorage`. Volume is stored the same way.

= Will music keep playing when I open another page? =

Only if that other page also embeds the player **and** the browser allows autoplay. After a full navigation, Chrome and Safari usually require a tap on Play. That is a browser rule, not a missing feature.

= What about the lock screen? =

While the player page stays in memory and audio is playing, supporting phones show title, artwork, and play/pause (and station skip) via Media Session. Closing the tab or killing the browser stops the stream.

= Does it support mobile devices? =

Yes. Play/pause are real buttons (keyboard and screen-reader accessible). Volume and station selects have labels.

= Can I add the player in the block editor? =

Yes. The block is registered with `block.json` and rendered in PHP. It does not replace the shortcode.

= Do I need AI to use this plugin? =

No. Add stations by hand, or use **Find stations** (Radio Browser). AI is optional: it only helps split a sentence into name / genre / country.

= Does Find stations save my settings? =

No. It fills the form. Review the URLs, then Save Changes.

= Where do the streams come from? =

The public Radio Browser directory (radio-browser.info). The search text is sent to their API. The plugin does not invent stream URLs.

== Changelog ==

= 2.2.0 =
* **Added:** Find stations on Simple Radio → Settings. Queries the Radio Browser directory and fills up to 6 working streams. Does not save until Save Changes.
* **Added:** Optional AI assembly (Connectors): plan searches, then pick 3–6 URLs from the fetched pool only. Without AI, first six hits.
* **Added:** Abilities list-stations and propose-stations (manage_options).
* **Design:** Native admin search box on Settings.
* **Docs:** Directory search, privacy (radio-browser.info), EN + FR guides.
* **Privacy:** Find stations sends your search text to radio-browser.info mirrors.

= 2.1.0 =
* **Compat:** Tested up to WordPress 7.1.
* **Added:** Media Session API — now-playing title/artist, artwork, play/pause, previous/next station on supporting lock screens.
* **Added:** After in-site navigation, the player tries to resume if `sessionStorage` says it was playing. Autoplay is often blocked; the FAQ explains why.
* **Added:** Gutenberg block `sr42/radio` is registered from `blocks/radio/block.json` with a dynamic PHP render (same output as the shortcode). The 2.0.0 JS-only registration is replaced, not duplicated.
* **Design:** Player and admin screens drop gold “laser” glow. Native admin layout (`.wrap`, `.form-table`, `.button`). Play/pause are `<button>`s with `aria-label` and visible focus.
* **Docs:** `readme.txt` plus `docs/USER-GUIDE.md` (English) and `docs/MODE-DEMPLOI.md` (French).

= 2.0.0 =
* **New:** Native Gutenberg block `sr42/radio` — drop the player anywhere in the block editor with zero shortcode knowledge required.
* **New:** Metadata now fetched via a proper REST API endpoint (`/wp-json/sr42/v1/meta`) instead of `admin-ajax.php` — faster, cacheable, and standards-compliant.
* **Fix:** Replaced deprecated `document.execCommand('copy')` with the modern Clipboard API in the admin shortcode tool.
* **Fix:** All hardcoded French error strings in the front-end JS are now fully translated via `wp_localize_script`.
* **Fix:** Aligned CSS asset version with plugin version (was 1.4.1, now 2.0.0).
* **Compat:** Tested and confirmed compatible with WordPress 7.0.
* **Compat:** Raised minimum PHP requirement to 7.4 (null coalescing assignment, named args).

= 1.3.1 =
* **Fix:** Corrected the Shortcode copy tool to support modern Clipboard API and added UI feedback.
* **Fix:** Implemented station persistence (F5) via localStorage.
* **Fix:** Added default "fallback" stations if the database is empty (Radio 42, SomaFM, Radio Paradise).
* **Fix:** Resolved a regression where the selected station was reset on initial load.

= 1.3.0 =
* Way cleaner UI and overall performance optimization.
* Final stable release for WordPress 6.9.
* Integrated Icecast/SomaFM metadata (Artist/Title) via AJAX.
* Added "Laser Glow" visual effect on the volume slider.
* Synchronized initial buffer with page load cycle.

= 1.2.3 =
* Switched to pure Vanilla JS (jQuery-free).
* Added 4 predefined radio stations.
* Added Click Lock mechanism to prevent UI spamming.

= 1.2.2 =
* Fixed shortcode detection bug.
* Updated compatibility for WordPress 6.7.

= 1.0 =
* First stable version.
* Added basic radio player and customization options.

== License ==

Simple Radio Forty Two is licensed under the GPLv2 or later. See LICENSE.txt for details.

== Acknowledgments ==

Thanks to the WordPress community and the Radio 42 developers for the inspiration.
