简体   繁体   English

SoundJS中的缓冲音频

[英]Buffered audio in SoundJS

I'm using SoundJS 0.5.2 to play audio in a music player that I'm designing for a client. 我正在使用SoundJS 0.5.2在我为客户端设计的音乐播放器中播放音频。

According to the documentation, I have to register or preload an audio file before I can use it, by using the registerSound method of the Sound Class and the audio cannot be played before it is fully loaded. 根据文档,我必须先使用Sound Class的registerSound方法registerpreload音频文件,然后才能使用它,并且在完全加载音频之前无法播放音频。

But how I do I go about buffering the audio while it is being played? 但是,如何在播放音频时缓冲音频呢? Like wait till 10% of the audio is buffered, then play the song? 像等待10%的音频被缓冲,然后播放歌曲? Can this be accomplished using PreloadJS ? 可以使用PreloadJS完成此操作吗?

After Googling about it, I found this thread. 谷歌搜索之后,我找到了这个线程。 It says that the WebAudioPlugin does not support buffering because of the underlying technology, but the HTMLAudioPlugin can play the audio before it is fully loaded. 它说WebAudioPlugin由于底层技术而不支持缓冲,但是HTMLAudioPlugin可以在音频完全加载之前播放音频。

But it does not mention how to do that. 但是它没有提到如何做到这一点。 When using HTMLAudioPlugin, do I still have to register the sound using registerSound ? 使用HTMLAudioPlugin时,是否仍需要使用registerSound注册声音?

Also, when using FlashPlugin as a fallback, will the buffering still be supported by FlashPlugin? 另外,当使用FlashPlugin作为后备时,FlashPlugin是否仍支持缓冲?

HTMLAudioPlugin fires the ready event when it receives the canplaythrough event from the audio tag, so it supports buffering by default (no setup required). HTMLAudioPlugin收到来自音频标签的canplaythrough事件时会触发ready事件,因此默认情况下它支持缓冲(无需设置)。 You have to register sounds for them to start loading, either with PreloadJS or internal SoundJS methods. 您必须使用PreloadJS或内部SoundJS方法注册声音才能开始加载。 Buffering will work the same regardless. 无论如何,缓冲都将相同。

Buffering is not supported by the FlashPlugin as far as I know. 据我所知,FlashPlugin不支持缓冲。

Hope that helps. 希望能有所帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM