Merge pull request #14 from shaders/master

Update pcm-player.js
master
Samir Das 3 years ago committed by GitHub
commit ab0c17a2ec
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -42,6 +42,11 @@ PCMPlayer.prototype.getTypedArray = function () {
PCMPlayer.prototype.createContext = function() {
this.audioCtx = new (window.AudioContext || window.webkitAudioContext)();
// context needs to be resumed on iOS and Safari (or it will stay in "suspended" state)
this.audioCtx.resume();
this.audioCtx.onstatechange = () => console.log(this.audioCtx.state); // if you want to see "Running" state in console and be happy about it
this.gainNode = this.audioCtx.createGain();
this.gainNode.gain.value = 1;
this.gainNode.connect(this.audioCtx.destination);
@ -123,4 +128,4 @@ PCMPlayer.prototype.flush = function() {
bufferSource.start(this.startTime);
this.startTime += audioBuffer.duration;
this.samples = new Float32Array();
};
};

Loading…
Cancel
Save