dom/base/test/file_webaudioLoop.html
author Nicholas Nethercote <nnethercote@mozilla.com>
Mon, 05 Oct 2015 16:59:32 -0700
changeset 301715 3897da20e42dec0bcf73987af1eaac4f8ce950b8
parent 300282 c6dfe20cbb8acd87f7f5a27d14e22fbf8731aa78
child 414454 9c54a60123e946f75ba00610130ee0dc63f3d39d
child 421448 cd615bff6069fe4072c67364f2dbb8266a2708c6
permissions -rw-r--r--
Bug 1211324 (part 3) - Remove GraphicsFilter::FILTER_FAST and replace it with FILTER_BEST. r=mattwoodrow. This may sound like an odd change but it's what the current code effectively already does due to the way ToFilter() and ThebesFilter() are defined.

<!DOCTYPE html>
<script>
var ac = new AudioContext();
var runningPromise = new Promise(resolve => {
  ac.onstatechange = event => {
    if (ac.state == "running") {
      resolve();
    }
  };
});
fetch("audio.ogg").then(response => {
  return response.arrayBuffer();
}).then(ab => {
  return ac.decodeAudioData(ab);
}).then(ab => {
  var src = ac.createBufferSource();
  src.buffer = ab;
  src.loop = true;
  src.loopStart = 0;
  src.loopEnd = ab.duration;
  src.start();
  src.connect(ac.destination);
});

var suspendPromise;
function suspendAC() {
  runningPromise.then(() => {
    suspendPromise = ac.suspend();
  });
}

var resumePromise;
function resumeAC() {
  suspendPromise.then(() => {
    resumePromise = ac.resume();
  });
}

function closeAC() {
  resumePromise.then(() => {
    ac.close();
  });
}
</script>