@@ -43,7 +43,7 @@ const openVideoDevice = async options => {
4343 }
4444 }
4545
46- const { videoSelector , width, height } = options ;
46+ const { selector , width, height } = options ;
4747 if ( width ) {
4848 constrains . video . width = { ideal : width } ;
4949 }
@@ -57,8 +57,8 @@ const openVideoDevice = async options => {
5757 const media = registerBootstrapBlazorModule ( "MediaDevices" ) ;
5858 media . stream = stream ;
5959
60- if ( videoSelector ) {
61- const video = document . querySelector ( videoSelector ) ;
60+ if ( selector ) {
61+ const video = document . querySelector ( selector ) ;
6262 if ( video ) {
6363 video . srcObject = stream ;
6464 }
@@ -122,7 +122,6 @@ export async function apply(options) {
122122 ideal : options . facingMode ,
123123 }
124124 }
125- console . log ( settings ) ;
126125 await track . applyConstraints ( settings ) ;
127126 }
128127 }
@@ -171,7 +170,10 @@ export async function record(options) {
171170 const stream = await navigator . mediaDevices . getUserMedia ( constrains ) ;
172171 const media = registerBootstrapBlazorModule ( "MediaDevices" ) ;
173172 const mediaRecorder = new MediaRecorder ( stream ) ;
173+
174+ stop ( ) ;
174175 media . recorder = mediaRecorder ;
176+ media . audioSelector = options . selector ;
175177 media . chunks = [ ] ;
176178
177179 mediaRecorder . start ( ) ;
@@ -192,8 +194,8 @@ export async function record(options) {
192194 }
193195 }
194196 delete media . audioSelector ;
197+ delete media . recorder ;
195198 }
196-
197199 } ;
198200 ret = true ;
199201 }
@@ -210,7 +212,12 @@ export async function stop(selector) {
210212 media . audioSelector = selector ;
211213 }
212214 if ( media . recorder ) {
213- media . recorder . stop ( ) ;
215+ if ( media . recorder . state === "recording" ) {
216+ media . recorder . stop ( ) ;
217+ }
218+ else {
219+ delete media . recorder ;
220+ }
214221 ret = true ;
215222 }
216223 return ret ;
0 commit comments