Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't get loudness on Firefox #67

Closed
towerofnix opened this issue Dec 6, 2017 · 0 comments · Fixed by #70
Closed

Can't get loudness on Firefox #67

towerofnix opened this issue Dec 6, 2017 · 0 comments · Fixed by #70

Comments

@towerofnix
Copy link
Contributor

towerofnix commented Dec 6, 2017

Expected behavior

When the loudness block is called and the microphone is connected, a value is returned.

Actual behavior

Nothing is returned, and an error is thrown: TypeError: this.mic.mediaStream is undefined

It looks like the error is coming from here:

Steps to reproduce

It looks like this error is spawning from this line:

// If the microphone is set up and active, measure the loudness
if (this.mic && this.mic.mediaStream.active) {

The microphone itself is set shortly before:

navigator.mediaDevices.getUserMedia({audio: true}).then(stream => {
    this.mic = this.audioContext.createMediaStreamSource(stream);

This is definitely weird, since mediaStream is defined in the WebAudio spec. Apparently a bug in Firefox. (I tested a comparable demo which uses createMediaStreamSource to take a look - yep, the mediaStream property is actually missing.)

So, browser specific. But worth looking into. I think you could just store the media stream in a separate property from this.mic:

+ this.audioStream = stream;
  this.mic = this.audioContext.createMediaStreamSource(stream);

~ if (this.mic && this.audioStream.active) {}

Operating system and browser

Firefox 58, 59. Debian (Testing).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants