Javascript可以检测移动设备是否静音? [英] Can Javascript detect if a mobile device is muted?

查看:574
本文介绍了Javascript可以检测移动设备是否静音?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

My website is currently playing sounds when the user answers a question right/wrong. But I notice that on my tablet (iPad) and mobile (iPhone) it plays the sounds even though I put it in silence mode. And I don't want the phone/tablet to play sounds when the user has clearly set their device in silent mode (the Ringer). So, can I detect whether a device is muted/silenced and then not play any sounds? I tested on Safari and Chrome, and it always plays the sound, irrespective of the Ringer's state.

编辑:如果不可能阅读这些信息,那么我的问题是,是否有一种方法可以播放尊重用户静音偏好的声音?我正在使用jQuery的 $(#correctsound)。触发器('play'),显然这并不尊重这些设置。我们是否有不同的方式来播放将这些设置考虑在内的声音?

If it is not possible to read this information, then my question would be if there is a way to play sounds that DOES respect the user's muting preferences? I am using jQuery's $("#correctsound").trigger('play'), and clearly this doesn't respect those settings. Do we have a different way to play sounds that takes these settings into account?

推荐答案

您问题的简单答案是没有即可。网页无法访问有关客户端的此类信息。更多信息: Javascript:您能阅读系统卷吗?此外,重要的是要注意iOS对于铃声和媒体有不同的音量设置,根据 Macworld

The simple answer to your question is no. Web pages don't have access to that kind of information about the client. More info here: 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:


掌握音量调节的关键是理解大多数
,你设备上的声音分为两类。 一般
audio
包括音乐和其他媒体,以及
iPhone和所有设备上FaceTime的语音音量。 铃声和警报
类别
不仅包括iPhone铃声,还包括:FaceTime
响铃;时钟应用报警;通知和个人应用警报;键盘点击
;和杂项应用听起来像
发送邮件的嗖嗖

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.

换句话说,如果如果用户想要静音来自网页的音频,则应将媒体音量设为静音。 铃声音量与网页无关,因此将手机置于静音模式只会影响铃声音量。如果您需要帮助更改设备的音量设置,请查看如何降低我的iPhone上的媒体音量? Apple Stack Exchange。

In other words, if a user wants to mute audio coming from web pages, they should mute the media volume. Ringer volume has nothing to do with web pages, so putting your phone in "silent" mode is only meant to affect the ringer volume. If you need help changing your device's volume settings, check out How can I lower the media volume on my iPhone when no media are playing? on the Apple Stack Exchange.

这篇关于Javascript可以检测移动设备是否静音?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆