【发布时间】:2012-11-01 03:10:27
【问题描述】:
我有一个带有如下控件的 <audio> 元素:
<audio controls="controls" id="audio-sample" preload="auto">
<source src="../../music-sample.php?type=ogg&id=<?php echo $item->custom_5; ?>" type="audio/ogg" />
<source src="../../music-sample.php?type=mp3&id=<?php echo $item->custom_5; ?>" type="audio/mp3" />
</audio>
播放器出现,声音播放正常,但轨迹条没有移动以反映经过的时间,也无法拖动它进行搜索。为什么不?我需要发送某种额外的标题吗?这是所有相关的 PHP,没什么特别的:
header('Content-Type: ' . $mimetype[$type]);
$file = fopen($filename, 'rb');
fpassthru($file);
fclose($file);
exit();
【问题讨论】:
-
与
readfile()相比,显式发送文件内容有什么好处? -
@alex:没有,我不知道
readfile存在。谢谢! (我现在就试试Content-Length的东西。我不认为它曾经奏效过,但谁知道呢!) -
@alex:
Content-Length工作得很好。啊,对不起!请将其发布为答案:)
标签: php html audio html5-audio