Reputation: 433
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?
Upvotes: 0
Views: 872
Reputation: 17360
If the currently used devices gets unplugged, the MediaStreamTrack's onended callback should fire. If that happens call enumerateDevices again.
Upvotes: 1
Reputation: 433
Using MediaDevices.ondevicechange and enable "Experimental Web Platform features" as seen on similar answered questions.
Upvotes: 1