I am building a website locally and I have a crazy problem. If I enter a path to the file in my browser like:

file:///home/jcrider/public_html/site/assets/5182/sound/r_Fantasia_Chopin_44.mp3

It will play the mp3, but when I try to run it through localhost like:

http://localhost/site/assets/5182/sound/r_Fantasia_Chopin_44.mp3

It does nothing. It did work once, but I haven't been able to get it to work again. I tried restarting apache and still nothing. I am really stumped on this one and pretty new to Linux (running Ubuntu 9.10) so it could be something dumb that I am overlooking.

Dani AI

Generated

Note: later confirmed this was a Firefox-on-Linux problem (same file worked via file:// and in Opera/other OS). For readers who hit the same symptom — first play OK, subsequent loads stuck on "loading" — the cause can be client-side (browser/plugin) or server-side (headers, byte-range handling, sendfile/mmap). The checklist below helps distinguish and fix both classes of causes.

Quick server-side checks (inspect headers and range support):

curl -I http://localhost/site/assets/5182/sound/r_Fantasia_Chopin_44.mp3

# check how the server handles range requests:
curl -v -H "Range: bytes=0-" http://localhost/site/assets/5182/sound/r_Fantasia_Chopin_44.mp3

Expected: a Content-Type: audio/mpeg, Accept-Ranges: bytes, and a 206 Partial Content response when a Range header is sent. If the server answers 200 to a range request or serves the wrong MIME type, some players stall. Ensure Apache knows .mp3 as audio/mpeg (for example via AddType audio/mpeg .mp3 in site config or .htaccess).

If headers look odd or transfers are truncated, try disabling kernel sendfile/mmap in Apache (common fix for strange static-file behavior on VMs or network filesystems):

# add to apache2.conf or the VirtualHost
EnableSendfile Off
EnableMMAP Off

# then reload Apache
sudo service apache2 reload

Client-side notes (consistent with and observations): when only one browser exhibits the problem, focus on that browser’s plugins/extensions and how it handles streaming/byte-range requests. Launching Firefox in safe mode or updating/disabling audio plugins can reveal or fix NPAPI/GStreamer/Flash-related hangs. Use the browser Network inspector to watch the request/response sequence to see whether the browser stops waiting for a 206/Content-Range or stalls after an initial connection.

Summary: reproduce the HTTP request with curl/wget to verify server behavior, check MIME and range handling, try disabling sendfile/mmap if file serving is flaky, and isolate the browser (safe mode / update) when only one client misbehaves. This separates server bugs from client/plugin issues quickly.

Dang, nevermind. Just was having some weird issue when I booted up. Logged out and back in and everything is cool now.

Edit: Actually it's not cool. It only seems to want to play the file once through localhost. After that it just keeps saying 'loading' but nothing ever happens.

Hi xylude,
What about the browser ? Did you try closing and reopening the browser ? There must be some media plugin which was playing the mp3 earlier. What if the media plugin got stuck playing the mp3 the first time and subsequent requests were queued by the plugin ?

Hello,

The best advice is "Look at the logs". Check and see what your httpd access and error logs show for the request. That will point you in the right direction to solve it.

Thanks guys, I found the problem - it was Firefox for Linux acting wierd. Tried it in Opera and on some other OS's and everything was fine. Sorry for the trouble.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.