我们注意到,我们的播客通过iTunes进行stream式传输时,无法“正确查找”。 任何时候你点击时间轴,都会从头开始重新开始。
我很确定我们正在交付部分内容。 以下是响应标题:
$ curl --head -H "Range: bytes=5708077-" http://site.com/podcast.mp3 HTTP/1.1 206 Partial Content Server: nginx/1.2.0 Date: Mon, 19 Nov 2012 06:13:05 GMT Content-Type: audio/mpeg Content-Length: 13403738 Connection: keep-alive X-Powered-By: Express Cache-Control: no-cache Accept-Ranges: bytes Content-Range: bytes 5708077-19111814/19111815 Access-Control-Allow-Origin: *
这看起来正确吗? 有什么我错过了,可能会导致这个问题?
让我知道是否需要更多的信息。 谢谢!
问题是,当我们返回正确的头文件时,我们仍然没有实际提供请求的字节范围。 使用节点应用程序(提供播客audio)来传递正确的字节范围的正确方法是向可读stream对象添加“开始”和“结束”选项:
fs.createReadStream("podcast.mp3", { start: 0, end: 999 });