Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle for device permission before start record #468

Closed
freedytag opened this issue May 8, 2020 · 5 comments · Fixed by #474
Closed

Handle for device permission before start record #468

freedytag opened this issue May 8, 2020 · 5 comments · Fixed by #474
Labels

Comments

@freedytag
Copy link

Description

When starting the record, better add a handle for device permission is author not.

Steps to reproduce

For audio-only case, when I click start record middle button.
And press the record, and then stop record.
Now it was finished record audio success.
Now If I cancel the permission from browser address bar(Firefox)
(That is also same as video case if the user warry the personal privacy issue)
And then press the start record button.
And stop the record button.
Now try to play the record result (It was empty audio)

Results

Expected

If permission was cancel, when press record, better ask permission again.

Actual

It did not ask permission again. and record an empty audio

Error output

Not error output.

Additional Information

That was better stop the device after the user click "stop record", special for video record, as user will warry it about the personal privacy.

versions

videojs

VideoJS 7.7.5
VideoJS record 3.11.0

browsers

Firefox 76.0

OSes

Mac/Windows

@thijstriemstra
Copy link
Member

thijstriemstra commented May 8, 2020

Your question looks similar to this: https://stackoverflow.com/questions/15993581/reprompt-for-permissions-with-getusermedia-after-initial-denial

Apparently Chrome provides a Permissions API that allows you to query device permissions:

navigator.permissions.query({name: 'microphone'})
 .then((permissionObj) => {
  console.log(permissionObj.state);
 })
 .catch((error) => {
  console.log('Got error :', error);
 })

 navigator.permissions.query({name: 'camera'})
 .then((permissionObj) => {
  console.log(permissionObj.state);
 })
 .catch((error) => {
  console.log('Got error :', error);
 })

There is also a polyfill for the navigator.permissions.request() API (because the camera and microphone permissions are not supported in Firefox yet for example): https://github.com/chromium/permissions.request

And this should be called before getUserMedia is called. Can you try this permissions API and see how it works @freedytag so we can discuss how to implement it in videojs-record?

@freedytag
Copy link
Author

freedytag commented May 11, 2020

The current flow I used is
When the "finishRecord" event.
player.recard().stopDevice();

For prevent, the end-user think their microphone was still getting recorded

And user click play to playback the recorded audio to check is ok to submit

If the recorded audio was not good, the end-user may use the "⬤" to record again.

In this case, I try to use
navigator.mediaDevices.getUserMedia in the "startRecord" event.
But seem the callback "stream" needed config to pass to videojs.record? it seemed can get permission and suddenly stop device.

ref code:

		navigator.mediaDevices.getUserMedia({ audio: true })
			.then(function(stream) {
				console.log('You let me use your mic!')
			})
			.catch(function(err) {
				console.log('No mic for you!')
			});

@thijstriemstra
Copy link
Member

I misunderstood. I re-read your original report and was able to reproduce the "empty audio" situation. Will call this a bug instead of an enhancement.

@thijstriemstra
Copy link
Member

In Firefox (76 on Ubuntu 18) I see this error message:

 VIDEOJS: ERROR: DOMException: "MediaRecorder.start: The MediaStream is inactive" video.min.js:12:750
    e http://localhost:8080/node_modules/video.js/dist/video.min.js:12
    error http://localhost:8080/node_modules/video.js/dist/video.min.js:12
    dispatcher http://localhost:8080/node_modules/video.js/dist/video.min.js:12

In Chrome 81 it's not possible to revoke the permissions after allowing them (unless the page is reloaded).

@thijstriemstra
Copy link
Member

And flat out denying permissions at startup results in this error for Firefox 76:

Screenshot from 2020-05-19 20-20-23

And this error for Chrome 81:

Screenshot from 2020-05-19 20-20-04

So that could use some improvement as well.

@thijstriemstra thijstriemstra mentioned this issue May 19, 2020
thijstriemstra added a commit that referenced this issue May 19, 2020
* bump required version for video.js (7.0.5) and videojs-wavesurfer (3.2.0)

* update examples for videojs-wavesurfer 3.x

* update tests config for videojs-wavesurfer 3.x

* update changelog

* build: adjust config for copy-webpack-plugin update

* bump required version for recordrtc to 5.6.1

* fix milliseconds in formatTime (#443)

* replace msDisplayMax with displayMilliseconds option

* add exportImage

* add mime module

* fix mime-type for lamejs plugin

* doc: add multi example

* ci: disable firefox for now

* ask again for device permissions in Firefox when user cleared them manually (#468)

* audio+screen: add missing error handler

* add optional fileExtension param

* update dev dependencies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants