Detecting Device Changes
Great. You have built a few solid mechanisms to act on what devices are available when your app loads, and you’ll save your application from throwing TypeErrors by ensuring getUserMedia() is never called with a ham-fisted set of constraints when there’s no mic or camera available. You’re now also only adding tracks to $self.mediaStream when an available device has returned them.
But there are other cases of device ability to think about: external mics and cameras can have their cords unplugged by feral toddlers or vengeful cats, or be plugged back in if they were unplugged previously. Wireless media inputs can have their connections drop and reconnect, too.
Enter the devicechange event, which fires whenever a device ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access