wavesurfer.js icon indicating copy to clipboard operation
wavesurfer.js copied to clipboard

record microphone example

Open davidtorroija opened this issue 6 years ago • 3 comments

Hey, please I just need a quick and basic working example to record microphone and save to file or buffer, but to show in the screen and play the recorded audio, the examples about this in wavesurfer does not show loading the recorded audio. Thanks!

davidtorroija avatar Nov 27 '18 17:11 davidtorroija

See #1030 (or https://collab-project.github.io/videojs-record/examples/audio-only.html for full solution).

thijstriemstra avatar Nov 30 '18 16:11 thijstriemstra

Hi, Please check code snippet file. check above mentioned ticket and just modify code there. Change Device Ready Event like this and you will get how to record or play audio

        `const mediaRecorder;
        const audioChunks = [];`
        `wavesurfer.microphone.on('deviceReady', function(stream) {
            console.info('Device ready!');
            mediaRecorder = new MediaRecorder(stream);
            mediaRecorder.start();
            mediaRecorder.addEventListener('dataavailable', event=>{
                audioChunks.push(event.data);              
            })

            mediaRecorder.addEventListener("stop", () => {
                const audioBlob = new Blob(audioChunks);
                const audioUrl = URL.createObjectURL(audioBlob);
                const audio = new Audio(audioUrl);
                audio.play();
            });
        });

`

nilesh121196 avatar Feb 25 '20 06:02 nilesh121196

@nilesh121196 do u have a full working example?

vinikatyal avatar Feb 23 '22 16:02 vinikatyal

Would also like a full working version

usbme avatar Feb 18 '23 05:02 usbme