demo/events-demo.js
function () {
    var duration = 50;

    // Check if there is any data in the queue
    if (audioDataQueue.length > 0) {

        // Concatenate up to concatenateMaxChunks data arrays from the queue
        var concatenatedData = [];
        for (var i = 0; i < concatenateMaxChunks; i++) {
            if (audioDataQueue.length === 0) {
                break;
            }
            concatenatedData = concatenatedData.concat(audioDataQueue.shift());
        }

        // Play the audio
        duration = playAudio(concatenatedData) * 1000;
    }

    // Still capturing? Then call myself to continue consuming incoming data.
    if (window.audioinput && audioinput.isCapturing()) {
        timerGetNextAudio = setTimeout(getNextToPlay, duration);
    }
}
function () {
    var duration = 50;

    // Check if there is any data in the queue
    if (audioDataQueue.length > 0) {

        // Concatenate up to concatenateMaxChunks data arrays from the queue
        var concatenatedData = [];
        for (var i = 0; i < concatenateMaxChunks; i++) {
            if (audioDataQueue.length === 0) {
                break;
            }
            concatenatedData = concatenatedData.concat(audioDataQueue.shift());
        }

        // Play the audio
        duration = playAudio(concatenatedData) * 1000;
    }

    // Still capturing? Then call myself to continue consuming incoming data.
    if (window.audioinput && audioinput.isCapturing()) {
        timerGetNextAudio = setTimeout(getNextToPlay, duration);
    }
}
function ( ) { var duration = 50 ; // Check if there is any data in the queue if ( audioDataQueue . length > 0 ) { // Concatenate up to concatenateMaxChunks data arrays from the queue var concatenatedData = [ ] ; for ( var i = 0 ; i < concatenateMaxChunks ; i ++ ) { if ( audioDataQueue . length === 0 ) { break ; } concatenatedData = concatenatedData . concat ( audioDataQueue . shift ( ) ) ; } // Play the audio duration = playAudio ( concatenatedData ) * 1000 ; } // Still capturing? Then call myself to continue consuming incoming data. if ( window . audioinput && audioinput . isCapturing ( ) ) { timerGetNextAudio = setTimeout ( getNextToPlay , duration ) ; } }
Consume data from the audioinput queue and calls the playAudio method
Consume data from the audioinput queue and calls the playAudio method