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

Is it possible to be notified if devices have changed? #121

Closed
cuinjune opened this issue Aug 14, 2020 · 4 comments
Closed

Is it possible to be notified if devices have changed? #121

cuinjune opened this issue Aug 14, 2020 · 4 comments
Assignees
Labels
Type: support Question regarding usage

Comments

@cuinjune
Copy link

Hi, Is there any supported method that can notify me as soon as the list of input/output devices has changed?

Thanks in advance!

@djipco djipco self-assigned this Aug 14, 2020
@djipco
Copy link
Owner

djipco commented Aug 14, 2020

The WebMidi object dispatches connected and disconnected events when devices are connected or disconnected. There is a little more info in the docs.

P.S. When you have a question regarding usage, I invite you to submit it to the brand new WebMidi.js forum. Cheers!

@djipco djipco added the Type: support Question regarding usage label Aug 14, 2020
@cuinjune
Copy link
Author

@djipco Thank you for your answer. But I don't understand how to use it.
I tried the following but doesn't work.

WebMidi.connected().then(function(e) {
            console.log("CONEECTED!!!");
    });

@djipco
Copy link
Owner

djipco commented Aug 14, 2020

This is not how events work. To add a listener function to an event dispatched by the WebMidi object, you would use something like this:

WebMidi.addListener("connected", function(e) {
  console.log(e);
});

I added this example to the More Code Examples section of the GitHub README page.

@djipco djipco closed this as completed Aug 14, 2020
@cuinjune
Copy link
Author

@djipco Thank you so much! I just asked another question in the forum so please check.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: support Question regarding usage
Projects
None yet
Development

No branches or pull requests

2 participants