0

I'm using SoundJS 0.5.2 to play audio in a music player that I'm designing for a client.

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.

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? Can this be accomplished using 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.

But it does not mention how to do that. When using HTMLAudioPlugin, do I still have to register the sound using registerSound ?

Also, when using FlashPlugin as a fallback, will the buffering still be supported by FlashPlugin?

Abhishek Goyal
  • 867
  • 1
  • 7
  • 21
  • I recommend closing the duplicate post: http://stackoverflow.com/questions/26335746/buffered-audio-in-soundjs – Lanny Oct 14 '14 at 15:28
  • @Lanny Apologies, I was hoping that the duplicate will not be posted, as I experienced a temporary network error while posting the question. – Abhishek Goyal Oct 14 '14 at 15:50

1 Answers1

3

HTMLAudioPlugin fires the ready event when it receives the canplaythrough event from the audio tag, so it supports buffering by default (no setup required). You have to register sounds for them to start loading, either with PreloadJS or internal SoundJS methods. Buffering will work the same regardless.

Buffering is not supported by the FlashPlugin as far as I know.

Hope that helps.

OJay
  • 1,249
  • 7
  • 14
  • I see. Too bad, I was hoping to fall back to FlashPlugin for Firefox, as it does not support MP3 files, but it seems like I will have to load an OGG as well. Thanks for the help! – Abhishek Goyal Oct 14 '14 at 15:55
  • 1
    Firefox does support MP3 playback these days – OJay Oct 14 '14 at 16:11
  • But I can not be sure that the person using my web application has all the required codecs installed. In which case, I think falling back on Flash would be the most reliable method, or is there some other workaround? – Abhishek Goyal Oct 14 '14 at 16:14
  • ogg tends to be how we handle it – OJay Oct 14 '14 at 16:41