Javascript 可以检测移动设备是否静音吗?
Can Javascript detect if a mobile device is muted?
当用户回答问题时,我的网站当前正在播放声音 right/wrong。但我注意到在我的平板电脑 (iPad) 和手机 (iPhone) 上它会播放声音,即使我将其置于静音模式。而且我不希望 phone/tablet 在用户明确将他们的设备设置为静音模式(铃声)时播放声音。那么,我是否可以检测设备是否为 muted/silenced 然后不播放任何声音?我在 Safari 和 Chrome 上进行了测试,无论铃声的状态如何,它始终会播放声音。
编辑: 如果无法阅读此信息,那么我的问题是是否有一种播放声音的方法确实尊重用户的静音偏好?我正在使用 jQuery 的 $("#correctsound").trigger('play')
,显然这不符合这些设置。我们是否有考虑这些设置的不同方式来播放声音?
您问题的简单答案是否。网页无法访问有关客户端的此类信息。更多信息在这里:Javascript: Can you read the systems volume? Furthermore, it is important to note that iOS has different volume settings for ringers and for media, according to Macworld:
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.
换句话说,如果用户想要将来自网页的音频静音,他们应该将 media 音量静音。 铃声音量与网页无关,所以将您的phone设置为"silent"模式只是为了影响铃声音量。如果您在更改设备的音量设置方面需要帮助,请查看 Apple Stack Exchange 上的 How can I lower the media volume on my iPhone when no media are playing?。
当用户回答问题时,我的网站当前正在播放声音 right/wrong。但我注意到在我的平板电脑 (iPad) 和手机 (iPhone) 上它会播放声音,即使我将其置于静音模式。而且我不希望 phone/tablet 在用户明确将他们的设备设置为静音模式(铃声)时播放声音。那么,我是否可以检测设备是否为 muted/silenced 然后不播放任何声音?我在 Safari 和 Chrome 上进行了测试,无论铃声的状态如何,它始终会播放声音。
编辑: 如果无法阅读此信息,那么我的问题是是否有一种播放声音的方法确实尊重用户的静音偏好?我正在使用 jQuery 的 $("#correctsound").trigger('play')
,显然这不符合这些设置。我们是否有考虑这些设置的不同方式来播放声音?
您问题的简单答案是否。网页无法访问有关客户端的此类信息。更多信息在这里:Javascript: Can you read the systems volume? Furthermore, it is important to note that iOS has different volume settings for ringers and for media, according to Macworld:
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.
换句话说,如果用户想要将来自网页的音频静音,他们应该将 media 音量静音。 铃声音量与网页无关,所以将您的phone设置为"silent"模式只是为了影响铃声音量。如果您在更改设备的音量设置方面需要帮助,请查看 Apple Stack Exchange 上的 How can I lower the media volume on my iPhone when no media are playing?。