question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

VueJS 3, Wavesurfer.js + microphone

See original GitHub issue

Hello! I tried to create an app based on VueJS3 and Wavesurfer.js that would visualize microphone input. Unfortunately, microphone plugin does not work. I can load audio using this.waveRecorder.load('https://wavesurfer-js.org/example/media/demo.wav'), and in this case, wavesurfer will work. But, if I use microphone plugin, I can’t see visualization of microphone input.

I have codepen.

And there is another thing. If I load audio using this.waveRecorder.load('https://wavesurfer-js.org/example/media/demo.wav'), and change stop_recording method to

stop_recording() {
      this.isRecording = false;
      this.waveRecorder.playPause();
}

microphone plugin will work, after the second attempt to turn on (The loaded file will reset). And this also will reduce canvas refresh time.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:1
  • Comments:8

github_iconTop GitHub Comments

2reactions
markitantovcommented, May 31, 2021

The microphone plugin doesn’t work anyway.

That’s a bold statement, it works fine for me.

change waveRecorder.microphone.stop();

I have no idea what waveRecorder is or looks like.

I uploaded code to codepen in the post upper. If you don’t see this, I will attach code here.

var MicrophonePlugin = window.WaveSurfer.microphone;

var startBtn = document.querySelector('.start');
var stopBtn = document.querySelector('.stop');

var waveRecorder = WaveSurfer.create({
  container: '#waveform',
  waveColor: '#000000',
  barWidth: 2,
  barHeight: 1,
  barGap: null,
  plugins: [MicrophonePlugin.create()]
});

startBtn.addEventListener("click", function() {
  waveRecorder.microphone.start();
});


stopBtn.addEventListener("click", function() {
  waveRecorder.microphone.stop();
});

I use this code and I don’t know, why microphone plugin doesn’t work. Any suggestions?

0reactions
fareeshcommented, Jun 6, 2021

Perhaps a browser restriction that requires user input before accessing the microphone is cascading down into the way the plugin captures the audio, and thus preventing it from capturing unless the code executes in the context of a click.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Vue+Wavesurfer.js - CodePen
1. <!-- Use preprocessors via the lang attribute! e.g. <template lang="pug"> --> ; 2. <template> ; 3. <div id="app"> ; 4. <div v-if="isRecording"...
Read more >
Vue Wrapper for wavesurfer.js
Vue Wrapper for wavesurfer.js ; Dynamic island Player using Vue.js and Howler.js · 27 October 2022 ; A simple keyboard synthesizer built with...
Read more >
Microphone plugin - wavesurfer.js
Microphone plugin. Visualizes audio input from a microphone in wavesurfer.js instances. Quick start. Microphone: Start / Stop.
Read more >
wavesurfer.js
wavesurfer.js is an HTML 5 audio player and waveform visualizer, made with JavaScript and Web Audio.
Read more >
WaveSurfer Methods
wavesurfer.js is an HTML 5 audio player and waveform visualizer, made with JavaScript and Web Audio.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found