I need to generate audio from an mp3 file. So I use curl library to get the file, then set required headers, and echo
the audio content.
The problem is that it does not work correctly in Chrome and Safari browsers. The audio files being loaded, and starts playing, but you can't change the time(can't set .currentTime
in javascript, also in browser the timing slider does not work). (In Firefox works fine).
The code: php
$agent = 'stagefright/1.2 (Linux;Android 5.0)';
$url = 'http://www.jplayer.org/audio/mp3/Miaow-07-Bubble.mp3';
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1) ;
curl_setopt($ch, CURLOPT_REFERER, 'http://www.jplayer.org/');
curl_setopt($ch, CURLOPT_USERAGENT, $agent);
$media = curl_exec($ch);
curl_close($ch);
$content_length = strlen($media);
$type = "audio/mpeg";
header("Content-type: ".$type);
header("Content-length: ".$content_length);
echo $media;
exit;
Any ideas?
Maybe I miss some php headers?
Thanks.