Use ponyfill for get user media promise

This commit is contained in:
Paul Kaplan committed 2018-01-11 10:09:55 -05:00
1 parent c1b1703fb8
commit 15fdab9099
2 files changed
+15 -11

No files matched your search

+1
View File
@@ -50,6 +50,7 @@
"eslint-plugin-react": "^7.5.1",
"file-loader": "1.1.6",
"get-float-time-domain-data": "0.1.0",
"get-user-media-promise": "1.1.1",
"gh-pages": "github:rschamp/gh-pages#publish-branch-to-subfolder",
"html-webpack-plugin": "^2.30.0",
"immutable": "3.8.1",
+14 -11
View File
@@ -1,4 +1,5 @@
import 'get-float-time-domain-data';
import getUserMedia from 'get-user-media-promise';
import SharedAudioContext from './shared-audio-context.js';
import {computeRMS} from './audio-util.js';
@@ -22,17 +23,19 @@ class AudioRecorder {
startListening (onStarted, onUpdate, onError) {
try {
navigator.getUserMedia({audio: true}, userMediaStream => {
if (!this.disposed) {
this.started = true;
onStarted();
this.attachUserMediaStream(userMediaStream, onUpdate);
}
}, e => {
if (!this.disposed) {
onError(e);
}
});
getUserMedia({audio: true})
.then(userMediaStream => {
if (!this.disposed) {
this.started = true;
onStarted();
this.attachUserMediaStream(userMediaStream, onUpdate);
}
})
.catch(e => {
if (!this.disposed) {
onError(e);
}
});
} catch (e) {
if (!this.disposed) {
onError(e);