Skip to content

Incorrect signature for MediaDevices.get_user_media() #1887

Open
@astepanov256

Description

@astepanov256

Describe the Bug

As per MDN (https://developer.mozilla.org/en-US/docs/Web/API/MediaDevices/getUserMedia), MediaDevices.getUserMedia call requires one parameter (a map of device constraints). Attempt to call the method w/o the constraint map results in exception.

Current web-sys implementation does not allow for passing in the constraint map. Any attempt to access media device(s) from Rust returns Err(TypeError)

Steps to Reproduce

Sample code:

let cameras: MediaDevices = navigator.media_devices().expect("No available Media Devices found");
  let promise: js_sys::Promise = cameras.get_user_media().unwrap();
  let user_media = JsFuture::from(promise).await.expect("Unable to access user media");

Results in panic: panicked at 'Unable to access user media: JsValue(TypeError: audio and/or video is required )', src/libcore/result.rs:1165:5

Expected Behavior

get_user_media(...) definition should declare a JsValue parameter for the constraint map, and the generated shim should pass that value to the JS call

Additional Context

I am running the latest stable web-sys (at the moment, 0.3.32) and latest wasm-bindgen (0.2.55)

Metadata

Metadata

Assignees

No one assigned

    Labels

    breaking-changeTracking breaking changes for the next major version bump (if ever)web-sysIssues related to the `web-sys` crate

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions