mirror of
https://github.com/captbaritone/webamp.git
synced 2026-07-25 19:13:54 +00:00
Fix autoplay for audio experiment
This commit is contained in:
parent
56c4578835
commit
e55fcaf36e
4 changed files with 17 additions and 2 deletions
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -181,6 +181,10 @@
|
|||
}
|
||||
}
|
||||
|
||||
getAutoPlay() {
|
||||
return this._autoPlay;
|
||||
}
|
||||
|
||||
setAutoPlay(shouldAutoPlay) {
|
||||
this._autoPlay = shouldAutoPlay;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -105,6 +105,9 @@
|
|||
this._loop = shouldLoop;
|
||||
}
|
||||
|
||||
getAutoPlay() {
|
||||
return this._autoPlay;
|
||||
}
|
||||
setAutoPlay(shouldAutoPlay) {
|
||||
this._autoPlay = shouldAutoPlay;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue