meenie / band.js

Band.js - Music composer interface for the Web Audio API.
Other
1.18k stars 93 forks source link

Uncaught TypeError: undefined is not a function #11

Closed rjkip closed 10 years ago

rjkip commented 10 years ago

I'm getting said error after the changes introduced in commit d11a5e54be2cc6874181f95ec4195fb92e2c051b:

Uncaught TypeError: undefined is not a function.

If I unmangle the build, it's on lines 326 and 209.

Here:

        function updateTotalPlayTime() {
            totalPlayTime += ac.currentTime - currentPlayTime;
            var seconds = Math.round(totalPlayTime);
            if (seconds != currentSeconds) {
                setTimeout(function() {
                    tickerCallback(seconds); // Here.
                }, 1);
                currentSeconds = seconds;
            }
            currentPlayTime = ac.currentTime;
        }

And here:

        this.stop = function(fadeOut) {
        // .....
            } else {
                totalPlayTime = 0;
                reset();
                setTimeout(function() {
                    tickerCallback(currentSeconds); // And here.
                }, 1);
remotesynth commented 10 years ago

It seems that tickerCallback is something that was being added to provide the ability to add a callback for each second the song is playing (maybe to update a playback timer?). However, there is no default function defined.

I simply added:

if (tickerCallback) {
    tickerCallback(currentSeconds);
}

...in the three places it was defined and this solves the problem. However, I am not sure if this works with whatever Cody had in mind.

meenie commented 10 years ago

Hi @rjkip and @remotesynth - I've recently updated the library and this is fixed :).