Skip to content
This repository has been archived by the owner on May 21, 2019. It is now read-only.

Commit

Permalink
Attempt to detect HMD microphone #4
Browse files Browse the repository at this point in the history
doesn't work all the time, but it couldn't hurt
  • Loading branch information
brianchirls committed Mar 7, 2017
1 parent 3c42d5a commit f09149b
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions src/js/puppet-show-recorder.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import Recorder from 'recorderjs';
import eventEmitter from 'event-emitter';
import now from './now';

const hmdLabelRegex = /vive/i;

function PuppetShowRecorder(options) {
/*
todo:
Expand Down Expand Up @@ -104,16 +106,27 @@ function PuppetShowRecorder(options) {
}

navigator.mediaDevices.enumerateDevices().then(devices => {
audioInputDevices.length = 0;
const hmdGroupIds = {};
devices.forEach(dev => {
if (dev.kind === 'audioinput') {
audioInputDevices.push(dev);

// todo: prioritize Vive or Rift mic
// select default device
if (dev.deviceId === 'default' || !audioInputDevice) {
audioInputDevice = dev;
}
}

if (hmdLabelRegex.test(dev.label)) {
hmdGroupIds[dev.groupId] = true;
}
});

// if a microphone device is in the same group as a HMD output, use it
audioInputDevices.forEach(dev => {
if (hmdGroupIds[dev.groupId]) {
audioInputDevice = dev;
}
});

recordConstraints.audio.deviceId = audioInputDevice.deviceId;
Expand Down

0 comments on commit f09149b

Please sign in to comment.