javascript - In Firefox and Safari no way to add device change event listener? - Stack Overflow

admin2025-05-01  1

Trying to listen for device change using devicechange event listener. In Edge & Chrome the following code works:

 navigator.mediaDevices.ondevicechange = () => {
      console.log('device changed');
    };

However in Safari & Firefox that doesn't work, but if I look into caniuse, it says that it's supported:

Anybody have an idea what am I doing wrong ? Tried executing code in console and still device change event not detected in Safari & Firefox.

Thank you!

转载请注明原文地址:http://www.anycun.com/QandA/1746096058a91608.html