How can I detect that a device change as unplugged headphones from laptop - chrome - google-chrome

I am using navigator.mediaDevices.enumerateDevices() to list the available devices for a call (implemented using webRTC).
I need to be able to detect when headphones are unpluged/pluged.
Any ideas how can I fix this?

Using MediaDevices.ondevicechange and enable "Experimental Web Platform features" as seen on similar answered questions.

If the currently used devices gets unplugged, the MediaStreamTrack's onended callback should fire. If that happens call enumerateDevices again.

Related

Chrome/Selenium: use-file-for-fake-video-capture not working anymore

I have automated ui-tests that test a web application in chrome using https://theintern.io/
The application offers a barcode scanner using the device camera (https://github.com/zxing/zxing).
To test this feature, a fake barcode is shown to the application, this has worked until chrome version 90/91 (not quite sure anymore).
Since this version I can not access the fake video anymore.
Chrome-options I have set:
use-fake-device-for-media-stream
use-fake-ui-for-media-stream
`use-file-for-fake-video-capture=${fakeVideoFilePath}`
I can reproduce this outside of the application if I use the chrome window configured with selenium and go to
https://webcamtests.com/
This loads forever - same thing happens inside the application.
The webcam name is the path to the video the camera is supposed to show.
Any hints on what is causing this problem or how it can be solved?
Thanks!
Fixed with Chrome 93.
After the update it is just working again.

Re-enable WebGL without restarting Chrome

When Chrome stops WebGL and gives you the following error (in a yellow banner on top of the screen): "Rats! WebGL hit a snag...", and reloading does not work (WebGL is still not re-enabled), is it possible to re-enable WebGL without restarting Chrome?
Context:
Chrome disables WebGL probably because it requires too many resources: I ask it to display 400,000 billboards on Cesium, for those who know what this is.
I know how I could reduce the resources my app asks for, but actually I am exploring its limits for testing purposes. So I am going to make Chrome disable WebGL a lot of times, and I do not want to restart it everytime it disables WebGL.
My configuration:
Chrome 35.0.1916.114 m
Windows 7 Pro 64 bit.
Solutions explored:
I already tried to open a new Chrome window, it does not work. For the moment all I can do is close all Chrome windows and restart it.
I already tried to put --ignore-gpu-blacklist in the Chrome shortcut (even if I understood this is for Windows XP, right?).
Hope I was clear enough.
Thank you for your help.
I was having the same problem and I just found a solution. It sounds like this didn't work back when this question was posted but, it works now!
Refreshing the page doesn't work. If you clicked a link from a different tab to open the tab the crashed, clicking that link again doesn't work. You have to open a new tab and paste in the URL of the page that you want to reload.
I'm guessing this is due to chrome threading... by opening a brand new tab, you create a new thread instead of using the existing one.
In your application you should properly handle webglcontextlost and webglcontextrestored events. In particular, you should prevent default event action in webglcontextlost handler thus telling the browser that you can restore proper functioning of your app when webglcontextrestored will be fired.

Simulating an iPhone browser using HTML/CSS/JS

There are several websites that offer an "iPhone browser emulator". I'm just wondering if there's a way for me to get the same functionality for viewing local html files on my machine.
It seems like basically you would mainly just have to spoof the css "media type". Is that possible using HTML/JS/CSS?
And is there anything other functionality I'm forgetting that would be required for a basic iPhone browser simulator? Obviously discounting all the mobile-only hardware like deviceorientation and gps etc.
You don't need a third party website! you can easily do that with Chrome browser:
F12 to open the developer tools panel
click the setting gear in the bottom right corner
in the left panel select Overrides
"check" the Enable checkbox
select the desired User Agent
you might want to change the Device metrics / orientation and enable touch events
I'm using ripple. Developed by blackberry.
It's a chrome extension. And you can work with your localfiles

Flash object is not working after update of google chrome

Today google chrome updated to last version, before that update the website was working without any problem. It's working on firefox and internet explorer without any problem though.
What's wrong with google chrome ?
http://www.mersin-mezitli-satilik-daire.com/3-boyutlu-sanal-tur-mersin-mezitli-satilik-daire.php?iframe=3&anasayfa=1
This issue may be caused by the dreaded 'Pepper' Flash Player, which has also been breaking Flash content for me in Chrome.
I don't know what the solution is for your broader audience of Chrome visitors, but to fix the problem locally:
In a new tab, go to the URL: chrome://plugins/
Find the entry for 'Flash' and expand [+] Details if not already expanded
Look for the entry where the location of the plugin ends: ...PepperFlash\pepflashplayer.dll and click 'Disable'
You will hopefully have at least one other instance of Flash Player installed (if not, try installing a debug player from Adobe's website), and enable one of these.
I should mention, the Pepper Flash Player seems to regularly re-enable itself, possibly whenever Chome auto-updates itself, and I find myself having to repeat this process every couple of days.

How can I get notification of page load events in Chrome?

I need to be able to monitor navigation events (such as page loads or switching between active tabs) in browsers running on a Windows PC. So far, I can get this to work in IE and Firefox by loading a DLL into all running apps via a call to SetWindowsHookEx, then asking for either the IHTMLDocument2 (in IE) or nsIWebProgress (in Firefox) interface from the application. I can use the appropriate interface to request a callback from the application when an event of interest happens.
Is there a way to do this in Chrome? I have read a little about Chrome extensions, but I have not found any documentation on an API exposed by Chrome that is analogous to COM in IE or XPCOM in Firefox. Will a similar approach work or will I need to do something completely different? (I am working in C++.)
I would appreciate it if someone could at least point me in the right direction.
Thanks.
With Chrome extensions API you can register some events handlers for changing state of tab like when document state is changed (loading or loaded), when new tab is added/removed from window or when user switch between tabs.
More about tabs events You find on http://code.google.com/chrome/extensions/tabs.html#event-onActiveChanged