Start audio download half way through file.

别说谁变了你拦得住时间么 提交于 2019-12-08 04:32:03

问题


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!


回答1:


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.

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.

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
});


来源:https://stackoverflow.com/questions/18045338/start-audio-download-half-way-through-file

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!