gpt4 book ai didi

javascript - Javascript 可以检测移动设备是否静音吗?

转载 作者:行者123 更新时间:2023-11-30 09:36:16 27 4
gpt4 key购买 nike

当用户回答正确/错误的问题时,我的网站当前正在播放声音。但我注意到,即使我将其置于静音模式,它也会在我的平板电脑 (iPad) 和手机 (iPhone) 上播放声音。当用户明确将他们的设备设置为静音模式(铃声)时,我不希望手机/平板电脑播放声音。那么,我可以检测设备是否静音/静音然后不播放任何声音吗?我在 Safari 和 Chrome 上进行了测试,无论铃声的状态如何,它始终会播放声音。

编辑:如果无法阅读此信息,那么我的问题是是否有一种播放声音的方式尊重用户的静音偏好?我正在使用 jQuery 的 $("#correctsound").trigger('play'),显然这不符合这些设置。我们是否有考虑这些设置的不同方式来播放声音?

最佳答案

您问题的简单答案是。网页无法访问有关客户端的此类信息。更多信息在这里:Javascript: Can you read the systems volume?此外,重要的是要注意,根据 Macworld,iOS 对铃声和媒体有不同的音量设置。 :

The key to mastering volume adjustment is understanding that most of the sounds on your device fall into one of two categories. General audio includes music and other media, and the voice volume on the iPhone and for FaceTime on all devices. The “ringers and alerts” category includes not only the iPhone ringer, but also: FaceTime rings; Clock app alarms; notifications and individual app alerts; keyboard clicks; and miscellaneous app sounds like the whoosh of sending Mail.

换句话说,如果用户想要将来自网页的音频静音,他们应该将媒体音量静音。 铃声音量与网页无关,因此将手机设置为“静音”模式只是为了影响铃声音量。如果您在更改设备的音量设置方面需要帮助,请查看 How can I lower the media volume on my iPhone when no media are playing?在 Apple Stack Exchange 上。

关于javascript - Javascript 可以检测移动设备是否静音吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43440882/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com