getUserMedia constraints throws error for deviceId

246 views
Skip to first unread message

William Bittner

unread,
Jan 11, 2016, 3:55:06 PM1/11/16
to Chromium-dev
Hi,
  I am trying to select a specific device by a device Id. My constraints are as follows ( I tried all three ):
        function getUserMediaConstraints() {
          var constraints = {};
          constraints.audio = false;
          constraints.video = {};
          constraints.video.deviceId = "someterribleid";
          return constraints;
        }
        function getUserMediaConstraints() {
          var constraints = {};
          constraints.audio = false;
          constraints.video = {};
          constraints.video.deviceId = {};
          constraints.video.deviceId.exact = "someterribleid";
          return constraints;
        }

Both error out with: 
TypeError: Failed to execute 'webkitGetUserMedia' on 'Navigator': Malformed constraints

If I set:
        function getUserMediaConstraints() {
          var constraints = {};
          constraints.audio = false;
          constraints.video.deviceId = "somewrongId" ; 
          return constraints;
        }

 It will succeed, not throw exception, and give me the wrong device. It is Chrome 
Version 47.0.2526.106 (64-bit)

Thanks

PhistucK

unread,
Jan 11, 2016, 4:46:20 PM1/11/16
to noqlm...@gmail.com, Chromium-dev
This group discusses building the browser. Have you tried stackoverflow.com?
If you do find that it is an actual bug in the browser and not your code (does it work using Firefox, for example?), you can file an issue (if you cannot find an existing one) at crbug.com.


PhistucK

--
--
Chromium Developers mailing list: chromi...@chromium.org
View archives, change email options, or unsubscribe:
http://groups.google.com/a/chromium.org/group/chromium-dev
---
You received this message because you are subscribed to the Google Groups "Chromium-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to chromium-dev...@chromium.org.

Richard

unread,
Jan 11, 2016, 5:00:47 PM1/11/16
to chromi...@chromium.org
I am on leave and out of the office this week from Monday to Friday.

Richard Baldwin
air2there.com
0800 777 000
0274430566


Richard

unread,
Jan 11, 2016, 5:06:31 PM1/11/16
to chromi...@chromium.org

Gokul vellingiri

unread,
Oct 28, 2018, 5:03:47 AM10/28/18
to Chromium-dev
The below constraint worked for me. 

 const video_constraints ={};

      //Create the following keys for Constraint
      video_constraints.video = {};

      //set camera name
      video_constraints.video.deviceId = {};
      video_constraints.video.deviceId.exact = <device_id_comes_here>

      //set resolution Width
      video_constraints.video.width = {};
      video_constraints.video.width.exact = 640;

      //set resolution height
      video_constraints.video.height = 480;
      video_constraints.video.height.exact = streamHeight;

      //set fps
      video_constraints.video.frameRate = 60;
      video_constraints.video.frameRate.exact = streamFps;

      console.log("Selected Contraints is :", video_constraints);
Give a try once.
Reply all
Reply to author
Forward
0 new messages