-
Notifications
You must be signed in to change notification settings - Fork 185
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
Consider devicechange event for when a new granted bluetooth device is made available, #257
Comments
@beaufortfrancois what is your use case, please clarify? I guess it is for other UA to be notified ? When you say
do you mean device is discovered and granted though requestDevice ? Shall we also discriminate Thanks. |
Yes. Instead of using BroadcastChannel, it would be nice to have this kind of info baked in the API to allow several tabs to sync their states. I guess the |
@jyasskin thanks for the clarification, I'd like having it implemented too then. |
|
For the sake of completeness, is this how it would work? navigator.permissions.query({
name: "bluetooth",
deviceId: sessionStorage.lastDevice /* because we've stored it previously */
}).then(result => {
result.addEventListener('change', function(event) {
// Permission status has changed for this device
console.log(event.target);
})
}) If Is this how do I access a newly paired navigator.permissions.query({
name: "bluetooth",
optionalServices: [ 'battery_service' ],
}).then(result => {
result.addEventListener('change', function(event) {
console.log(event.target); /* Is this BluetoothDevice?
})
}) @jyasskin Sorry for this, I'm still having hard time getting the full |
Close. To detect that you've lost access to the device, use: navigator.permissions.query({
name: "bluetooth",
deviceId: sessionStorage.lastDevice /* because we've stored it previously */
}).then(result => {
if (result.devices.length == 0) {
console.log("Already lost access");
} else {
assert(result.devices[0].id == sessionStorage.lastDevice);
result.addEventListener('change', function(event) {
assert(result == event.target);
if (result.devices.length == 0)
console.log("Lost access");
});
}
}) To learn about newly-paired devices, use: navigator.permissions.query({
name: "bluetooth",
services: [ 'battery_service' ],
}).then(result => {
result.addEventListener('change', function(event) {
for (let device in result.devices) {
if (!(device.id in knownDeviceIds)) {
console.log("New device!", device);
}
}
});
})
There would be an event for each time |
Based on @jyasskin code samples, I believe |
In the same way,
devicechange
event is triggered when a new media input or output device is made available, it would be nice to add a similar event for when a new granted bluetooth device is made available.Source: https://groups.google.com/a/chromium.org/forum/#!topic/blink-dev/wdSV0zUuvJQ
The text was updated successfully, but these errors were encountered: