HTML5 audio from PHP script -


i want play audio generated php script.

client side:

<audio controls autoplay src="audio.php"></audio> 

server side:

$path = 'somefile.mp3'; header('content-type: audio/mpeg'); header('cache-control: no-cache'); header("content-transfer-encoding: binary"); readfile($path); 

it plays, can't change current time in audio element. range slider not working.

result

it missing few things in header in order seekbar work. content-length , accept-ranges. html audio player needs them in order build player seekbar.

try this:

$path = 'somefile.mp3'; header('content-type: audio/mpeg'); header('cache-control: no-cache'); header('content-transfer-encoding: binary'); header('content-length: ' . filesize($path)); header('accept-ranges: bytes'); readfile($path); 

Comments

Popular posts from this blog

java - Date formats difference between yyyy-MM-dd'T'HH:mm:ss and yyyy-MM-dd'T'HH:mm:ssXXX -

c# - Get rid of xmlns attribute when adding node to existing xml -