Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #35747
| Newsgroups | comp.lang.javascript |
|---|---|
| Date | 2018-10-07 22:58 -0700 |
| References | <6a7727a4-fc96-4366-94aa-4f2b502b64a4@googlegroups.com> <17wmx6hu6z8kn.lq8ggse14t2a$.dlg@40tude.net> |
| Message-ID | <cbd614d4-8ace-4c8d-ab3a-c14e09cc52f3@googlegroups.com> (permalink) |
| Subject | Re: Catching event from message alert box, and wait until resolved? |
| From | Jonas Thörnvall <jonas.thornvall@gmail.com> |
Den måndag 8 oktober 2018 kl. 06:45:35 UTC+2 skrev JJ:
> On Sun, 7 Oct 2018 10:06:51 -0700 (PDT), Jonas Thörnvall wrote:
> > I am trying to get my sequenser to handle sysex messages. The procedure is
> > pretty simple
> > if (navigator.requestMIDIAccess) {
> > navigator.requestMIDIAccess(
> > {sysex: true} //Yeah it is just to set sysex : true
> > )
> > .then(success, failure);
> > }
> >
> > Problem is that the sysex : true generate a message box event. that have
> > to be answered.
> >
> > file: /// wants to use your midi device
>
> That message box is part of the web browser security system. It can't be
> bypassed unless the site in added into the allow list.
>
> > But the program runs on so it gets success and try to read in ports, but
> > apparently the midiobject is not accessible until the alert box event
> > answered.
>
> `requestMIDIAccess()` is an asynchronous method. If the script tries to
> access the resource without waiting for the resourse to be available, then
> it's guaranteed to fail.
Well that is my question JJ how do i build the "structure" accesspath so that it wait for user input to get ready.
Right now i load "the main script" like list ports, via HTML function body onLoad. The access part midiaccess.js is loaded in HTML file.
But of course when i read in the HTML file it first import midiaccess.js, but right after it start to load main, before the user have the chance to answer the alert box. So how can i have the HTML body onLoad main.js wait for user input?
> > How can i sidestep that problem or somehow wait for the alert box to be
> > closed, because i guess that is the problem with the ports within
> > midiobjects not accessible. Works fine when sysex false.
>
> You're asking about hacking a security system. The answer would obviously be
> no.
No i just want to wait for the user to handle the alert box, i want to wait for user input before loading the "main program that call listports" that use the midiaccess object that is not ready.
Lets say this is my midiaccess file, how can i list ports after, the alert box been resolved. So how do i know when the alert box resolved, where do i call the listports(); or alternatively how do i wait until alert box resolved?
Thanks JJ
if (navigator.requestMIDIAccess) {
navigator.requestMIDIAccess(
{sysex: false}
)
.then(success,failure );
}
function failure() {
console.error('No access to your midi devices.' + +msg)
}
function success(midi) {
mid = midi;
inputs = midi.inputs.values();
// inputs outputs are Iterators
for (input = inputs.next(); input && !input.done; input = inputs.next()) {
// each time there is a midi message call the onMIDIMessage function
console.log(input);
input.value.onmidimessage = onMIDIMessage;
}
}
function listPorts() {
// Grab an array of all available devices
var iter = mid.outputs.values();
for (var i = iter.next(); i && !i.done; i = iter.next()) {
outportarr.push(i.value);
}
PORTout = outportarr[outportindex];
//List ports in and out
Lportout = mid.outputs.values();
Lportin = mid.inputs.values();
for (listinput = Lportin.next(); listinput && !listinput.done; listinput = Lportin.next()) {
var deviceIn = listinput.value.name;
var optin = document.createElement("option");
optin.text = deviceIn;
document.getElementById("in_portsel").add(optin);
}
for (listoutput = Lportout.next(); listoutput && !listoutput.done; listoutput = Lportout.next()) {
var deviceOut = listoutput.value.name;
var optout = document.createElement("option");
optout.text = deviceOut;
document.getElementById("out_portsel").add(optout);
}
}
Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Catching event from message alert box, and wait until resolved? Jonas Thörnvall <jonas.thornvall@gmail.com> - 2018-10-07 10:06 -0700
Re: Catching event from message alert box, and wait until resolved? Jonas Thörnvall <jonas.thornvall@gmail.com> - 2018-10-07 16:12 -0700
Re: Catching event from message alert box, and wait until resolved? JJ <jj4public@vfemail.net> - 2018-10-08 11:45 +0700
Re: Catching event from message alert box, and wait until resolved? Jonas Thörnvall <jonas.thornvall@gmail.com> - 2018-10-07 22:58 -0700
Re: Catching event from message alert box, and wait until resolved? JJ <jj4public@vfemail.net> - 2018-10-10 05:39 +0700
Re: Catching event from message alert box, and wait until resolved? Jonas Thörnvall <jonas.thornvall@gmail.com> - 2018-10-09 21:50 -0700
Re: Catching event from message alert box, and wait until resolved? JJ <jj4public@vfemail.net> - 2018-10-11 20:40 +0700
Re: Catching event from message alert box, and wait until resolved? Jonas Thörnvall <jonas.thornvall@gmail.com> - 2018-10-11 15:11 -0700
Re: Catching event from message alert box, and wait until resolved? Jonas Thörnvall <jonas.thornvall@gmail.com> - 2018-10-14 20:56 -0700
Re: Catching event from message alert box, and wait until resolved? Jonas Thörnvall <jonas.thornvall@gmail.com> - 2018-10-07 23:13 -0700
Re: Catching event from message alert box, and wait until resolved? Jonas Thörnvall <jonas.thornvall@gmail.com> - 2018-10-08 08:09 -0700
csiph-web