mirror of
https://github.com/roytam1/palemoon27.git
synced 2026-06-09 09:58:57 +00:00
34 lines
914 B
HTML
34 lines
914 B
HTML
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">
|
|
<meta charset="utf-8">
|
|
<title>Test for mozinterruptbegin/end in AudioContext</title>
|
|
|
|
<script type="application/javascript">
|
|
|
|
var ac = new AudioContext();
|
|
|
|
function createEvent(msg) {
|
|
var event = document.createEvent('CustomEvent');
|
|
event.initCustomEvent('testmozchannel', true, true, { msg: msg });
|
|
dispatchEvent(event);
|
|
}
|
|
|
|
ac.onmozinterruptbegin = function(evt) {
|
|
createEvent('mozinterruptbegin');
|
|
}
|
|
|
|
ac.addEventListener('mozinterruptend', function() {
|
|
createEvent('mozinterruptend');
|
|
}, false);
|
|
|
|
var buffer = ac.createBuffer(1, 2048, ac.sampleRate);
|
|
for (var i = 0; i < 2048; ++i) {
|
|
buffer.getChannelData(0)[i] = Math.sin(440 * 2 * Math.PI * i / ac.sampleRate);
|
|
}
|
|
|
|
var source = ac.createBufferSource();
|
|
source.buffer = buffer;
|
|
source.connect(ac.destination);
|
|
source.loop = true;
|
|
source.start(0);
|
|
</script>
|