在文件中途开始音频下载. [英] Start audio download half way through file.

查看:248
本文介绍了在文件中途开始音频下载.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道是否有一种方法可以根据字节或时间从一个起点开始下载音频文件.现在,在我的网站上,如果我想在中途开始播放音轨,则必须等待其中途下载,然后跳至该部分.谢谢!

I was wondering if there is a way to start downloads of audio files from a start point depending on bytes or time. Right now on my website if I want to start a audio track at the half way point I have to wait for it to download past halfway and then skip to that part. Thanks!

推荐答案

是的,服务器必须支持字节范围请求,而客户端必须提出适当的请求才能获取所需的字节.大多数浏览器已经本地支持此功能. Flash没有.

Yes, the server has to support byte range requests and the client would have to make the appropriate request to get the bytes it needs. Most browsers support this already natively; Flash does not.

如果您正在使用本机<audio>元素,并且无法在下载整首歌曲之前设置播放位置,则意味着服务器不接受字节范围请求.

If you're using the native <audio> element and are unable to set the playback position before the entire song has downloaded then that means the server does not accept byte range requests.

使用SoundManager2,您可以在创建声音时传递一个from值,该声音将从 表示的偏移量开始播放(使用Flash时,仍将下载整个文件):

Using SoundManager2 you can pass a from value when creating the sound which will start the playback from said offset (when using Flash, the entire file will still be downloaded):

soundManager.createSound({
  url: 'http://www.podtrac.com/pts/redirect.mp3/traffic.libsyn.com/theadamcarollashow/2013.08.07ACS.mp3',
  from: 10*60*1000 // position to start playback within a sound (msec): 10 minutes
});

这篇关于在文件中途开始音频下载.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆