I am working on an mp3 streaming web application. I am using an external API to get the mp3 url, the problem is that all mp3's are bounded to the IP requesting the file (in this case my server) and it can be streamed/downloaded only by the server, any other IP will result in a 404.
What I am looking for is the best option for my server to act as a relay/proxy between the mp3 and the user wanting to listen to it.
This is somehow a problem for my bandwidth, but I see no alternative.
This is the code I am using, but as it broadcasts at the same time it downloads, the web app can't get the mp3 tags and it somehow broke the web app player.
if (isset($_GET['name']) AND isset($_GET['url'])){
$url = urldecode($_GET['url']);
if ((strpos($url,'xxxxxx') !== false) || (strpos($url,'xxxxxx') !== false)) {
header('Content-type: application/octet-stream');
header('Content-Disposition: attachment; filename="' . $_GET['name'] . ' - xxxxxx.mp3"');
readfile(urldecode($_GET['url']));
}
else {
header("HTTP/1.0 404 Not Found");
}
}
else {
header("HTTP/1.0 404 Not Found");
}