• Welcome to ASR. There are many reviews of audio hardware and expert members to help answer your questions. Click here to have your audio equipment measured for free!

FLAC audio in a forum post

Multicore

Master Contributor
Joined
Dec 6, 2021
Messages
5,033
Likes
6,740
If I open the URL https://fsbdoc.s3.amazonaws.com/aafsb040724-1.flac in Firefox the response headers include

Code:
HTTP/1.1 200 OK
Accept-Ranges: bytes
Content-Type: audio/x-flac
Content-Length: 50802620

and Firefox puts an audio player in the middle of the page and starts it playing.

MS Edge otoh just downloads the FLAC file. Same in dastardly Chrome.

What happens if I put that URL in a para on its own in this post?


And as destination for an inline link like this?

Answer: Firefox opens a new tab and plays the audio. Edge and Chrome download the FLAC file.

The Insert media
1787148282285.png
button does not accept the URL. Pity.
 
In firefox, set "media.play-stand-alone" to false in about:config. (and restart FF)
The file will then download instead of play.

Or just "save as" if the file is playing.
 
It's unclear what the desired behavior is here. Do you want it to simply download, or do you want it to play in-browser?
 
Seems worth noting the following here...

Chatbot output from Kagi follows.

-----

XenForo doesn't allow raw HTML in posts for security reasons. Create a custom BB Code that the system replaces with an <audio> tag 3.


Step 1: Go to the Custom BB Code manager​

In your Admin Control Panel, navigate to:

> Content → BB Code → Custom BB Codes → click Add custom BB code

Step 2: Fill in the BB Code settings​

Configure the fields as follows 2:

FieldValue
BB code tagAUDIO
TitleHTML5 Audio Player
DescriptionEmbeds a native HTML5 audio player for FLAC, MP3, OGG, WAV, etc.
Replacement modeSimple replacement
Supports option parameterNo

Step 3: Set the HTML replacement​

In the HTML replacement box, enter 3:

Code:
<audio controls preload="none" style="width:100%; max-width:400px;">
<source src="{text}" type="audio/flac">
  Your browser does not support the audio element.
</audio>
  • {text} will be replaced by whatever the user puts between the [AUDIO] tags (i.e., the file URL).
  • type="audio/flac" tells the browser it's a FLAC file. If you want to support multiple formats, you can omit the type attribute or add multiple <source> lines.
  • preload="none" prevents auto-loading (saves bandwidth). Remove it if you want auto-loading.
  • controls displays the native play/pause/seek bar.

Step 4: Optional — Add a button to the editor​

In the Editor icon field, enter a Font Awesome icon class (e.g., fa fa-music) so users get a clickable button in the message editor instead of having to type the BB Code manually 3.

Step 5: Save and test​

Save the BB Code. Now in any post, a user can write:

Code:
[AUDIO]https://example.com/files/song.flac[/AUDIO]

This will render a native HTML5 audio player in the post.


Supporting multiple audio formats​

If you want the player to handle FLAC and other formats, you can make a more flexible version. Set Supports option parameter to Yes, and use this HTML replacement:

Code:
<audio controls preload="none" style="width:100%; max-width:400px;">
  <source src="{text}" type="audio/{option}">
  Your browser does not support the audio element.
</audio>

Then usage would be:

Code:
[AUDIO=flac]https://example.com/files/song.flac[/AUDIO]
[AUDIO=mp3]https://example.com/files/song.mp3[/AUDIO]
[AUDIO=ogg]https://example.com/files/song.ogg[/AUDIO]

The {option} token captures the format type after the = sign 3.


Important notes​

  • Browser support for FLAC: The native HTML5 <audio> player supports FLAC in Chrome, Firefox, Edge, and Opera (desktop and mobile). Safari does not support FLAC — it will show "Your browser does not support the audio element" for Safari users.
  • File hosting: The audio file must be hosted somewhere accessible via a direct URL (your own server, a CDN, etc.). The BB Code doesn't handle file uploads — it just plays a URL.
  • Attachment files: If you want to play attached files (files uploaded directly to the post) rather than external URLs, you'd need a template modification instead. There are existing add-ons like the Simple HTML5 video and audio attachment player that handle this, though they may not list FLAC explicitly 3.

References​

 
Back
Top Bottom