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

MediaTrackSettings struct #2782

Closed
3xMike opened this issue Jan 30, 2022 · 3 comments
Closed

MediaTrackSettings struct #2782

3xMike opened this issue Jan 30, 2022 · 3 comments
Labels

Comments

@3xMike
Copy link

3xMike commented Jan 30, 2022

I'm not sure that it can be called a bug, but:
Due to MDN docs:
https://developer.mozilla.org/en-US/docs/Web/API/MediaTrackSettings
and
https://developer.mozilla.org/en-US/docs/Web/API/Media_Streams_API/Constraints#getting_the_current_settings_for_a_track
struct MediaTrackSettings must give me access to actual values of MediaStreamTrack's settings, but in web-sys only setter-methods are implemented. (I'm writing web-micro UI right now and I need to know the settings of client's micro. And I think MediaStreamTrack.getSettings is the only way, but it allows you only set, not get) Why is it write only, when it should be read only?

@3xMike 3xMike added the bug label Jan 30, 2022
@3xMike
Copy link
Author

3xMike commented Jan 30, 2022

Ok, I found that even not all the struct fields are implemented (sampleRate for example), but I found the solution (thanks to source code):
It's easy to write getter methods by yourself:

let settings = my_media_stream_track.get_settings();
let channel_count = ::js_sys::Reflect::get(&settings,  &JsValue::from("channelCount")); // channel_count is Result<JsValue, JsValue>
let sample_rate = ::js_sys::Reflect::get(&settings,  &JsValue::from("sampleRate"));
let sample_size = ::js_sys::Reflect::get(&settings,  &JsValue::from("sampleSize"));
...

The only step is to add it to the crate page i think

@3xMike 3xMike closed this as completed Jan 30, 2022
@stephanemagnenat
Copy link

As far as I have seen, with latest web_sys version (0.3.64), proper getter methods are still not implemented. The work-around you proposed is much better than nothing, but still quite cumbersome. So why closing the issue?

@daxpedda
Copy link
Collaborator

Duplicate of #1793.

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

No branches or pull requests

3 participants