Running Chrome 56.0.2924.76 (64-bit) on Windows 10 PRO Version 1511 (OS Build 10586.753). Have enabled experimental-web-platform-features on chrome, running it with flag --disable-webusb-security and as administrator. I try to get USB device list on localhost (using https) with getDevices but I get empty list, although chrome://device-log is showing me plenty of devices. What could be the issue?
navigator.usb.getDevices().then(function(devices){
console.log(devices);
});
// console outputs []
You should use requestDevice() before in order to get access permissions on selected devices.
navigator.usb.requestDevice({filters:[]}).then(function(device){
console.log(device);
});
After that you'll be able to call getDevices().
Related
I have a weird case.
I use chrome 75 for Mac OS.
When I push code in console some page
if ('caches' in window) {
console.log(`cache is supported`)
}else{
console.log(`cache is not supported`)
}
as a result I see that this is supported but I have local server on 8080 from vue. When I call it there it return that cache doesn't exists.
When I export vue cli code as production still cache is not supported in window.
Any ideas why? Thanks in advance for any hints.
I'm using the following code in an application in order to retrieve the users location.
function getGeoCoords() {
var deferred = $.Deferred();
navigator.geolocation.getCurrentPosition(deferred.resolve, deferred.reject);
return deferred.promise();
}
This is used by the following:
return deferred.pipe(function() {
console.log('Getting user location. . .');
return getGeoCoords();
}).pipe(function (position)) {
. . .
This code has been tested and works well in all browsers, except Chrome.
It seems that it is also constrained to China. Other browsers tested there (even IE) worked without a hitch. But for some reason, I am unable to use the Geolocation API to retrieve the location of a user in China on Chrome.
Any thoughts?
take a look https://www.zhihu.com/question/20473051
in short, the reason is that the chrome needs to send the location infomation to a google server, but the server may be blocked in china
Six years later I still can't make this work in Chrome.
But there are working examples, so how do they do that?
Here's what my problem is in particular:
I'm in China and I need to make a website that displays a map with a "Get my location" button. To simplify, if I run the following code in debugger, in some environments it will not get my location. Can anyone tell me why?
navigator.geolocation.getCurrentPosition(success => console.log(success), err => console.error(err))
I can get the location in these environments:
My Macbook uses 4G from my phone (hotspot), Safari browser.
PC uses internet from LAN, Edge browser.
I CANNOT get the location in these environments:
My Macbook uses internet from LAN, Safari browser.
PC uses internet from LAN, Chrome version 68 as well as the Chinese QQ browser:
Error: {
code:2,
message:"Network location provider at 'https://www.googleapis.com/' : No response received."
}
PC uses internet from LAN, Chome 103 or Firefox: No success and no error received.
In all cases, location services are enabled and VPN is not used.
I know, googleapis.com is not available in China. But Baidu, Gaode Amap, or QQ Map should work on Chrome and they don't.
This is repeat of
Apache Cordova GeoLocation not providing data
Following code returns an empty object:
function onDeviceReady(){
$cordovaGeolocation.getCurrentPosition({}).then(function(resp) {
console.log(resp);
$scope.geo.get = resp;
});
}
No errors or anything, just empty {}
Update 1
Works fine Samsung S3, but doesnt work on Nexus 4.
Update 2
LogCat shows the following line:
Caught security exception registering for location updates from the system.
You need to make sure that you added the corresponding location permissions.
If you are using iOS, it might ask you if you want to allow the app to determine your location.
If you are not sure, check the settings on both devices (android/ios) to check the requested permissions.
Recently, I started getting errors when trying to access the client's mic through my website. When Chrome asks whether to allow the site to access the user's microphone, [object NavigatorUserMediaError] is produced whether they click "allow" or "deny." This has been happening regardless of whether or not a microphone is actually plugged into the computer (which is running Ubuntu 12.04).
Further testing through Firefox showed that this is not specific to Chrome. The problem only started after I had done a live-input demo and then logged out of the computer. I tried making a bare bones demo of accessing the microphone, and it ran into the same problem.
var getVideo = false, getAudio = true;
navigator.getUserMedia || (navigator.getUserMedia = navigator.mozGetUserMedia ||
navigator.webkitGetUserMedia || navigator.msGetUserMedia);
function init() {
if(navigator.getUserMedia) {
navigator.getUserMedia({video:getVideo, audio:getAudio}, onSuccess, onError);
} else {
alert('getUserMedia failed.');
}
}
function onSuccess() {
console.log("Yay");
}
function onError(err) {
console.log("Noo " + err);
}
This is rather puzzling as it had worked perfectly up until the point where I logged out and then logged back in and tried to test it again.
I am hosting the web code locally, through Jetty and Eclipse. I am accessing it by typing localhost:8080/my-program into the web browser.
Edit:
After the error occurs, the icon of a camera shows up in the chrome address bar, saying that Chrome is accessing my microphone and listing two possible microphones, "Default" and "Built-in Audio Analog Stereo."
Edit 2:
This error is also occurring on other websites that try to access my microphone through webrtc. Traditional Flash implementation still works.
Chrome seems to be throwing out an error message at regular intervals while open.
[361:362:0725/095320:ERROR:audio_output_device.cc(186)]
Not implemented reached in virtual void
media::AudioOutputDevice::OnStateChanged(media::AudioOutputIPCDelegate::State)
Edit 3:
I was able to clarify the error message a bit more
NavigatorUserMediaError {code: 1, PERMISSION_DENIED: 1}
** One Browser at a Time **
I've encountered this situation when I am testing with multiple browsers open. It would appear that only one browser can access the media at a time.
ie When I've got my page open in Chrome, and the video/audio is working, then Firefox won't work, and when I've got it working in Firefox, then Chrome doesn't work.
This can happen in two situations and I've experienced both in Ubuntu 12.04:
You have clicked Deny once and then the browser saves that setting, always returning error when asked for media access in that page. (This does not seem to be your case as you get the question from browser, but you just have to go to the address bar, click in the camera icon and change the option to ask again).
Your browser is not having access to the media devices and as in any computer without cameras nor microphones, even if you press Allow, you will get an error event as it cannot give you any streams. Try to check the browser settings to see if you can choose the selected camera. I've experienced this and the list was empty. To solve this I had to reboot the machine and Chrome started showing the list of devices again.
NavigatorUserMediaError {code: 1, PERMISSION_DENIED: 1}
This means your browser settings are not allowing you to access the camera. Go into your browser settings -> under website settings you'll find a list of webpages that you have blocked from accessing your device.
getUserMedia only works on https; no exception for localhost (i.e http://localhost). Safari also does not ever seem to allow getUserMedia from within an iFrame. I always get a “Trying to call getUserMedia from a document with a different security origin than its top-level frame” error. This makes using sites like codepen and jsfiddle impossible.
More detials https://webrtchacks.com/safari-webrtc/
I'm going through firefox extension writing bootcamp and somewhere along the way the video's author is speaking about switching browser.dom.window.dump.enabled in about:config to true. This option is no longer present in firefox 5.0. From what I read during my google searches, in ff 4.0 you had to create this preference yourself, and it seems like in firefox 5.0 it doesn't work anymore - I can't seem to dump information to firefox error console any more (regardless of whether console2 is enabled or not).
Relevant code:
Here's how I'm launching the browser:
/usr/bin/iceweasel -profile /some/path -no-remote -jsconsole
And here's the code that only shows the alert, without writing anything to the error console:
onCommand: function(event) {
toJavaScriptConsole("toJavaScriptConsole: hello world");
dump("Hello world!\n");
alert("Hello world!\n");
}
Any idea what I can do to have working dump() called from the ff extension I'm working on in firefox 5.0?
You confused the error console with plain linux console - if you run firefox from terminal you should see the dumps right there.
in-depth explanation
This preference was never present by default - you always had to create it and set to true. Also, the output doesn't go to Error Console, it is rather visible in the terminal you start Firefox from. If you happen to test on Windows you should specify -console command line flag to open a terminal window for the output, on Linux simply starting Firefox from a terminal window will do.