mirror of
https://github.com/sehugg/8bitworkshop.git
synced 2025-02-27 13:29:32 +00:00
audio: clear buffers when stopping in case browser keeps playing anyway
This commit is contained in:
parent
773f9a4a91
commit
59da2990b1
@ -175,7 +175,6 @@ TODO:
|
|||||||
- can't step back twice?
|
- can't step back twice?
|
||||||
- compiler bug in chase
|
- compiler bug in chase
|
||||||
- "shared" in URL doesn't work, leave in URL? (also importURL)
|
- "shared" in URL doesn't work, leave in URL? (also importURL)
|
||||||
- alert when skeleton file loaded or file not found
|
|
||||||
|
|
||||||
WEB WORKER FORMAT
|
WEB WORKER FORMAT
|
||||||
|
|
||||||
|
@ -385,6 +385,12 @@ export var SampleAudio = function(clockfreq) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function clearBuffers() {
|
||||||
|
if (bufferlist)
|
||||||
|
for (var buf of bufferlist)
|
||||||
|
buf.fill(0);
|
||||||
|
}
|
||||||
|
|
||||||
function createContext() {
|
function createContext() {
|
||||||
var AudioContext = window['AudioContext'] || window['webkitAudioContext'] || window['mozAudioContext'];
|
var AudioContext = window['AudioContext'] || window['webkitAudioContext'] || window['mozAudioContext'];
|
||||||
if (! AudioContext) {
|
if (! AudioContext) {
|
||||||
@ -425,7 +431,6 @@ export var SampleAudio = function(clockfreq) {
|
|||||||
// Chrome autoplay (https://goo.gl/7K7WLu)
|
// Chrome autoplay (https://goo.gl/7K7WLu)
|
||||||
if (this.context.state == 'suspended') {
|
if (this.context.state == 'suspended') {
|
||||||
this.context.resume();
|
this.context.resume();
|
||||||
console.log('AudioContext should resume');
|
|
||||||
}
|
}
|
||||||
return; // already created
|
return; // already created
|
||||||
}
|
}
|
||||||
@ -447,6 +452,7 @@ export var SampleAudio = function(clockfreq) {
|
|||||||
|
|
||||||
this.stop = function() {
|
this.stop = function() {
|
||||||
this.context && this.context.suspend();
|
this.context && this.context.suspend();
|
||||||
|
clearBuffers(); // just in case it doesn't stop immediately
|
||||||
}
|
}
|
||||||
|
|
||||||
this.close = function() {
|
this.close = function() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user