Feature Request: Media Session API support for inline audio
thanks for the extension updates — it’s a really clean and lightweight solution for embedding audio and it already became a favorite feature in my forum community!
I noticed that when playing audio, system media controls (macOS/iOS Control Center, Android lock screen, Windows media overlay) display the Flarum discussion title instead of the actual audio track info. This is expected since no Media Session metadata is currently set.
Would you consider adding optional support for the Media Session API?
Proposed approach (kept minimal):
- When an
<audio> element starts playing, set navigator.mediaSession.metadata
- Only run if
mediaSession is available (no polyfills needed)
- Keep it lightweight and non-invasive
Example:
if ('mediaSession' in navigator) {
navigator.mediaSession.metadata = new MediaMetadata({
title: audio.dataset.title || audio.currentSrc.split('/').pop(),
artist: audio.dataset.artist || '',
});
}
Metadata sources (simple fallback chain):
data-title / data-artist (if provided in markup)
- Fallback to filename from
currentSrc
This avoids adding dependencies or complex parsing (e.g., ID3), while still improving UX significantly.
Why this helps:
- Correct track info shown on lock screens, Bluetooth devices, and OS media overlays
- Consistent behavior across platforms (Android, iOS, Windows, macOS)
- No impact on users who don’t need it
Again – thank you for this great extension!