Update pcm-player.js

ios and safari support
pull/14/head
shaders 3 years ago committed by GitHub
parent d3db1d8c39
commit 29d56dc47c
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);

Loading…
Cancel
Save