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

Need more attributes in MediaDeviceInfo #447

Closed
ibc opened this issue Apr 14, 2017 · 4 comments
Closed

Need more attributes in MediaDeviceInfo #447

ibc opened this issue Apr 14, 2017 · 4 comments
Assignees

Comments

@ibc
Copy link

ibc commented Apr 14, 2017

Let assume an app in which the user can choose the webcam device in a drop list and get a preview of it. If he selects a front camera, the preview <video> element must enable CSS transform: scaleX(-1); (mirror effect). If he selects a back/rear camera, no mirror effect must be applied.

This seems to be a very common scenario. But AFAIK it's unfeasible with the current API.

The drop list is filled with enumerateDevices() by filtering device.kind === 'videoinput', and (assuming a previous permissions prompt) it can display the device.label of the video devices. But from the API point of view, the app has no way to know whether a device in the list is a front or a back camera.

So, the user chooses one, the app gets its device.deviceId and calls getUserMedia() with video: { exact: device.deviceId }. At that point, the app has no way to know whether it must apply the "mirror effect" to the local video or not.

I know about some developers (including me) matching /(back|rear)/i to the device.label. Hope the API can provide something much better than that. Things would be much easier (or just feasible) if DeviceMediaInfo includes more fields such as facingMode.

I may understand that the proper way to go is by calling getUserMedia() with the choosen deviceId (as above) and then inspect the retrieved video MediaStreamTrack.getConstraints(), which seems to include facingMode. However (at least in Firefox which is closer to the spec) track.getConstraints().facingMode is an empty object. Is that because getUserMedia() was NOT called with a facingMode constrain?

If so, the same problem as the above described applies.

@stefhak
Copy link
Contributor

stefhak commented Apr 21, 2017

I think you should call track.getSettings() if you want to read out e.g. the facingMode.

@ibc
Copy link
Author

ibc commented Apr 21, 2017

Certainly I missed track.getSettings(). Hope browsers properly implement it soon, as no one of them provide the facingMode setting.

The spec is ok then. It's just lack of implementation in browsers. Closing the issue. Thanks.

@ibc ibc closed this as completed Apr 21, 2017
@stefhak
Copy link
Contributor

stefhak commented Apr 21, 2017

Do you plan to file issues on Chrome & Firefox? Would be interesting to know their implementation plan.

@ibc
Copy link
Author

ibc commented Apr 21, 2017

Yes, I'll do eventually and update here when done.

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

No branches or pull requests

3 participants