The function defining the moment when the user gives the go-ahead to the recording can be placed in gotStream (see the main.js file for links). But the user can take, but reject his confirmation of the permission to write and break it all. How to catch this moment?

http://webaudiodemos.appspot.com/AudioRecorder/index.html

http://webaudiodemos.appspot.com/AudioRecorder/js/main.js

I don’t want to use the timer, because it’s too heavy, and until it has time to work, who knows what will happen to the script during recording (when access stops abruptly)

  • And errorCallback is not caused at this moment? - VladD pm
  • No, it is not called, the function continues to record emptiness - Fangog

1 answer 1

Option 1 : Use ssl - this prevents a second write request.

If your app is running from SSL (https: //), this permission will be persistent. Grant / deny access every time. Information .

Option 2: catch error.

We have the function: navigator.getUserMedia(constraints, successCallback, errorCallback); Consequently:

 navigator.getUserMedia ( // constraints { video: true, audio: true }, // successCallback function(localMediaStream) { var video = document.querySelector('video'); video.src = window.URL.createObjectURL(localMediaStream); video.onloadedmetadata = function(e) { // Do something with the video here. }; }, // errorCallback function(err) { if(err === PERMISSION_DENIED) { // Explain why you need permission and how to update the permission setting } } ); 

Option 3: use Option 1 + Option 2

PS: A similar question has already been considered here .

  • Yes, but when the user first opens access, and then takes it and closes it - functions are not called again - Fangog
  • But not everywhere like that, in the moss he does it on the fly - Fangog
  • Yes, I already encountered this when I began to solve the problem of converting to mp3, no one can even help with the conversion of the incoming array into a blob - Oct
  • This is exactly what I would like to avoid - Fangog