I'm trying to stream music to play it afterwards.
This is not a download but a direct stream of mp3 files from the source file to an <audio>
tag on another page.
- Things I've tried so far:
- Use the Web audio API to stream directly from URL (audio.src=url->audio.load())
-->"text/html is not supported".
-->Adding the MP3 type to the .htaccess file didn't help (yes I alredy tried to move it to the directory where my MP3s are.)
-->I have to do it manually with PHP, so I can use the content type header. - Using JQuery, AJAX and a PHP-file to stream the data from a blob on a MySQL database.
-->It does not buffer the file, but loads it comletely which takes min. 30 secs.
--> too slow and maybe a bit too complicated for a simple audio stream where security isn't that important - Using JQuery, AJAX and a PHP-file to stream the data from the directory on my Server
--> same as 2. (besides, that ist isn't that secure anymore)
The code I've used in the .htaccess file is
AddType audio/mpeg3 .mp3
AddType audio/mp3 .mp3
AddType audio/x-mpeg3 .mp3
I have 2 ways to solve my problem, so I have 2 questions
1. How can I tell my server to stream an MP3-File as audio/mpeg3 and not as text/html (in case 1) ?
2. How can I buffer the audio stream (in case 2 or 3) so the visitor hasn't to wait 30+ seconds for it?
corrections are welcome.