News:

Want to get involved in developing SMF, then why not lend a hand on our github!

Main Menu

Attaching Audio Files

Started by Senkusha, February 07, 2025, 02:57:27 PM

Previous topic - Next topic

Senkusha

So, I'm playing around with something new.  I'm wanting to add audio files to my forum, and have SMF display a player, like this:

You cannot view this attachment.

And I thought everything was good, this is what I want.  I'm not sure why the time is reading 0:00, but it does play, so maybe there's a setting somewhere that needs to be tweaked.  But anyway, I just tried to attach another music file to another new post, and this is what I get instead:

You cannot view this attachment.

Which is not what I want.  Clicking on this link will spawn a download.  I'm not sure what the difference is, I've tried with really short file names, that doesn't seem to be the issue.  I've double checked, the extension is .mp3 so I'm at a loss.

Maybe there's something configured in Apache?  But I think that's beyond my control.  Is SMF determining to use an audio player or is something else making this determination.  As a side note, I tried playing with the following, but that does nothing (for <audio></audio>).

[audio]filename.mp3[/audio]
-- Senkusha
The Kawaii Klub
The Creative Anime Role Playing Community.
(SMF v. 2.1.4, PHP v. 8.0)

Sesquipedalian

#1
When a file attachment is embedded into a post using the [attach] BBC, the way it is displayed is normally determined according to the file's MIME type. The file's MIME type is determined automatically using standard libraries on your server.

If the file attachment's MIME type was detected to be some sort of video or audio file (e.g. audio/mpeg for an MP3 audio file) when the file was uploaded, then it will be shown as a playable media file in the HTML document when the page is viewed in a web browser. If the file's MIME type was not detected as a video or audio file, then only a download link will be shown.

So in your second example, it appears that your server did not recognize the uploaded file as a valid audio file. That might be because the file is corrupted, or it might be that there is something wrong or outdated about the underlying MIME detection library on your server.

Unfortunately, there's not much that SMF itself can do about this either way. If the file is corrupted, the only solution is to upload an uncorrupted copy. If the problem is that your server's underlying MIME detection library failed to detect the file's MIME type correctly, then your server needs to be updated. SMF itself can only take the file it was given, ask the server to analyze it, and then accept whatever the system says.

It is worth noting that MP3 files in particular are fairly tolerant of small amounts of corruption, meaning that if the file only has a bit of corruption, most audio players will still be able to play it. But if the corruption happens in the right parts of the file, it might not be detected properly by the MIME type detection library. So if the MP3 file plays when you open it on your local computer, then the easiest solution might be to simply open it in your favourite audio editor, export a new copy of it, and then upload the new copy.
I promise you nothing.

Sesqu... Sesqui... what?
Sesquipedalian, the best word in the English language.

Senkusha

Thank you for explaining this!  I had no idea the internal guts of the file were examined by Apache to determine what type of file has been uploaded.  I'm learning stuff everyday! :)
-- Senkusha
The Kawaii Klub
The Creative Anime Role Playing Community.
(SMF v. 2.1.4, PHP v. 8.0)

Advertisement: