Я пытаюсь настроить звуковой сигнал на 3 раза на одну секунду. Однако звук воспроизводится только один раз. Любые мысли о том, почему это может быть? (Он включен в большей JavaScript Funciton, объявляющий контекст и т.д...) Планирование веб-аудио. Воспроизведение Api, многопроцессорное воспроизведение.
var beepBuffer;
var loadBeep = function() { \t \t
\t var getSound = new XMLHttpRequest(); // Load the Sound with XMLHttpRequest
\t getSound.open("GET", "/static/music/chime.wav", true); // Path to Audio File
\t getSound.responseType = "arraybuffer"; // Read as Binary Data
\t getSound.onload = function() {
\t \t context.decodeAudioData(getSound.response, function(buffer){
\t \t \t beepBuffer = buffer; // Decode the Audio Data and Store it in a Variable
\t \t });
\t }
\t getSound.send(); // Send the Request and Load the File
}
var playBeep = function() {
\t for (var j = 0;j<3;j++) {
\t \t var beeper = context.createBufferSource(); // Declare a New Sound
\t \t beeper.buffer = beepBuffer; // Attatch our Audio Data as it's Buffer
\t \t beeper.connect(context.destination); // Link the Sound to the Output
\t \t console.log(j);
\t \t beeper.start(j); // Play the Sound Immediately
}
};
Спасибо за помощь! Это сработало – njz2104