Search code examples
javascriptalgorithmhtmlsoundmanager2

Implementing canplaythrough in SoundManager2


I need help making an algorithm to detect that all the conditions for HAVE_ENOUGH_DATA are met (and continuously checking until they are met) and I am stumped as to how to calculate all the necessary variables using SoundManager2's whileloading option. I don't need code, just a general algorithm that would work (even pseudo-code is fine).


Solution

  • It turns out that setting the whileplaying option is a more optimal and simple solution. This is my whileplaying solution:

    function () {
     aSound.options.whileplaying = null;
     if (paused) {
      aSound.stop();
     }
     onCanPlayThrough_callback_here();
    }