Search Support

Avoid support scams. We will never ask you to call or text a phone number or share personal information. Please report suspicious activity using the “Report Abuse” option.

Learn More

Mulongo oyo etiyamaki na archive. Tuna motuna mosusu soki osengeli na lisalisi

Firefox crashing when programming Audio element with Javascript

  • Eyano ata moko te
  • 1 eza na nkokoso oyo
  • 5 views
more options

I'm programming a game, using setTimeout to iterate the game loop at a rate of 50 calls a second.

I'm using this sound code:


function createAudioStation (slots) {

var station = { slots: new Array(slots), slotsLimit: slots };

for (var index = 0; index < station.slotsLimit; index++) { station.slots[index] = { }; station.slots[index].element = document.createElement("audio"); document.body.appendChild(station.slots[index].element); }

return station; }


function loadAudio (station, file, volume, loop) {

file = file.substring(1, file.length - 1);

for (var index in station.slots) {

if (station.slots[index].element.src == "") { station.slots[index].element.autoplay = true; station.slots[index].element.src = file; station.slots[index].element.volume = 1; if (loop == 1) station.slots[index].element.loop = true; station.slots[index].element.index = index;

if (loop == 0) station.slots[index].element.onended = unloadAudio;

return; } } }


function killAudio (station) {


for (var index in station.slots) { document.body.removeChild(station.slots[index].element); station.slots[index].element = document.createElement("audio"); document.body.appendChild(station.slots[index].element); } }


function unloadAudio () {

this.src = ""; }

I'm programming a game, using setTimeout to iterate the game loop at a rate of 50 calls a second. I'm using this sound code: '''function createAudioStation (slots) { var station = { slots: new Array(slots), slotsLimit: slots }; for (var index = 0; index < station.slotsLimit; index++) { station.slots[index] = { }; station.slots[index].element = document.createElement("audio"); document.body.appendChild(station.slots[index].element); } return station; } function loadAudio (station, file, volume, loop) { file = file.substring(1, file.length - 1); for (var index in station.slots) { if (station.slots[index].element.src == "") { station.slots[index].element.autoplay = true; station.slots[index].element.src = file; station.slots[index].element.volume = 1; if (loop == 1) station.slots[index].element.loop = true; station.slots[index].element.index = index; if (loop == 0) station.slots[index].element.onended = unloadAudio; return; } } } function killAudio (station) { for (var index in station.slots) { document.body.removeChild(station.slots[index].element); station.slots[index].element = document.createElement("audio"); document.body.appendChild(station.slots[index].element); } } function unloadAudio () { this.src = ""; } '''