CreateJS / SoundJS

A Javascript library for working with Audio. It provides a consistent API for loading and playing audio on different browsers and devices. Currently supports WebAudio, HTML5 Audio, Cordova / PhoneGap, and a Flash fallback.
http://createjs.com/
MIT License
4.42k stars 838 forks source link

InvalidStateError Safari 10 on El Capitan #287

Open GeoTimber opened 6 years ago

GeoTimber commented 6 years ago

Hi and thanks for the great library

InvalidStateError (DOM Exception 11): The object is in an invalid state.

is the error I get on Safari 10, El Capitan, on soundsjs version 1.0.0 (below and above), at the moment Safari 11 does not seem to generate the error, but I am not sure I may have seen it there too.

I created an example here https://knowledgeisland.org/?tmpl=createjstest

I think I traced it back to audioNode.startTime being NaN, but was not able to solve it

    p._createAndPlayAudioNode = function(startTime, offset) {
        var audioNode = s.context.createBufferSource();
        audioNode.buffer = this.playbackResource;
        audioNode.connect(this.panNode);
        var dur = this._duration * 0.001;
        audioNode.startTime = startTime + dur;
        audioNode.start(audioNode.startTime, offset+(this._startTime*0.001), dur - offset);
        return audioNode;
    };

Can anybody help please, I like to get this project working on Safari 10 too as it is still very recent?

thanks Joris

GeoTimber commented 6 years ago

Ok I added a fix for myself so the above link no longer generated the error but obviously it is not a great solution

        if (isNaN(audioNode.startTime)) audioNode.startTime=0;
        audioNode.start(audioNode.startTime, offset+(this._startTime*0.001), dur - offset);