Skip to content

Commit d1c1973

Browse files
authored
Merge pull request #16 from wlor0623/master
修复ios端navigator.getUserMedia方法调用失败的问题 #15
2 parents 137a673 + be8c9fc commit d1c1973

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

src/lib/recorder/index.js

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ class IatRecorder {
4141
this.appId = config.appId
4242
this.apiKey = config.apiKey
4343
this.apiSecret = config.apiSecret
44-
this.isAudioAvailable = !!(navigator.getUserMedia && AudioContext && recorderWorker)
44+
this.isAudioAvailable = !!((navigator.getUserMedia||navigator.mediaDevices.getUserMedia) && AudioContext && recorderWorker)
4545
this.pd = config.pd
4646
this.rlang = config.rlang
4747
this.ptt = config.ptt
@@ -131,6 +131,19 @@ class IatRecorder {
131131
}
132132
this.connectWebsocket()
133133
}
134+
} else if (navigator.mediaDevices.getUserMedia && AudioContext) {
135+
this.state = 'init'
136+
if (!this.recorder) {
137+
setTimeout(() => {
138+
this.initRecorder()
139+
}, 100)
140+
} else {
141+
if (this.state === 'end') {
142+
this.closeTrack()
143+
return
144+
}
145+
this.connectWebsocket()
146+
}
134147
} else {
135148
alert(locales[this.language].not_supported)
136149
}

0 commit comments

Comments
 (0)