EvandroLG/ts-audio

Creating an audioJS player and delaying playback doesn't play

Closed this issue · 2 comments

It appears there's a missing logic path for creating an audioJS object and delaying the playback. shouldPlay gets set to true, but nothing happens after that.

Seems like a solution could work like:

   this.callbackManager.register({
        callback: this._play,
        context: this
    });

    // if we want to play the sound again after stop //
    if (this.buffer && this.shouldPlay) {
        this.source = this.audioContext.createBufferSource();
        this.source.buffer = this.buffer;
        this.source.connect(this.audioContext.destination);
        this.source.gain.value = this.volume;
        this.source.loop = this.loop;
    }

    this.shouldPlay = true;

    if (!this.isStarted) {
        this._play();
    }

Hi @MrBendel I just released a new version of the library. This issue should be fixed.
In case you find any problem, just let me know :)