Fix autoplay for audio experiment

This commit is contained in:
Jordan Eldredge 2017-10-19 16:40:20 -07:00
parent 56c4578835
commit e55fcaf36e
4 changed files with 17 additions and 2 deletions

View file

@ -8,6 +8,7 @@ const loadUrl = document.getElementById("loadUrl");
const info = document.getElementById("info");
const position = document.getElementById("position");
const sourceType = document.getElementById("sourceType");
const autoplay = document.getElementById("autoplay");
const context = new (window.AudioContext || window.webkitAudioContext)();
@ -48,6 +49,10 @@ position.addEventListener("change", () => {
source.seekToTime(newTime);
});
autoplay.addEventListener("change", () => {
source.setAutoPlay(autoplay.checked);
});
const updateInfo = () => {
const data = {
numberOfChannels: source.getNumberOfChannels(),
@ -55,7 +60,8 @@ const updateInfo = () => {
duration: source.getDuration(),
timeElapsed: source.getTimeElapsed(),
sampleRate: source.getSampleRate(),
loop: source.getLoop()
loop: source.getLoop(),
autoplay: source.getAutoPlay()
};
info.value = JSON.stringify(data, null, 2);

View file

@ -181,6 +181,10 @@
}
}
getAutoPlay() {
return this._autoPlay;
}
setAutoPlay(shouldAutoPlay) {
this._autoPlay = shouldAutoPlay;
}

View file

@ -105,6 +105,9 @@
this._loop = shouldLoop;
}
getAutoPlay() {
return this._autoPlay;
}
setAutoPlay(shouldAutoPlay) {
this._autoPlay = shouldAutoPlay;
}

View file

@ -23,7 +23,9 @@
<button id='loadUrl'>Load URL</button>
<br />
<input type='range' id='position' min="0" max="100" />
<br />
<br /> Autoplay:
<input type='checkbox' id='autoplay' checked />
<br>
<textarea id='info' cols="50" rows="20"></textarea>
<script src="./emitter.js"></script>
<script src="./bufferSource.js"></script>