菜鸟教程小白 发表于 2022-12-12 22:56:47

ios - 在 PhoneGap 应用程序中检测 iPhone 和其他 iOS 设备上的静音事件和状态?


                                            <p><p>似乎有一些话题围绕这个主题展开,但没有明确的答案:如果用户在加载应用程序时启用了声音,但后来将他/她的 iPhone 静音,我们如何在 PhoneGap 中检测到这一点?这个事件有回调吗?文档似乎没有列出任何内容。</p>

<p>第二个相关问题:如何检测静音按钮的状态?如果有人启用了静音,您如何检测到这一点以避免播放音频? media.play() 方法好像只有锁屏时是否播放音频的选项。</p>

<p>谢谢!</p></p>
                                    <br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
                                            <p><p>我希望我们的应用程序在 iPhone 静音时不播放声音。
经过几个小时的搜索,我决定尝试使用以下参数并按预期工作:</p>

<pre><code>myMedia.play({ playAudioWhenScreenIsLocked : false });
</code></pre>

<p><a href="http://docs.phonegap.com/en/2.6.0/cordova_media_media.md.html#media.play_ios_quirk" rel="noreferrer noopener nofollow">documentation doesn&#39;t say</a>当 iPhone 静音时,此参数将使声音不播放的任何内容,但它的行为就像那样。</p>

<p>我使用的是 PhoneGap 2.6.0,文档说:</p>

<blockquote>
<p>Pass in this option to the play method to specify whether you want to
play the audio of the media file when the screen is locked (this
defaults to true if not set). If this is set to true, it will ignore
the state of the hardware mute button.</p>
</blockquote>

<p>记录不当?</p></p>
                                   
                                                <p style="font-size: 20px;">关于ios - 在 PhoneGap 应用程序中检测 iPhone 和其他 iOS 设备上的静音事件和状态?,我们在Stack Overflow上找到一个类似的问题:
                                                        <a href="https://stackoverflow.com/questions/12686180/" rel="noreferrer noopener nofollow" style="color: red;">
                                                                https://stackoverflow.com/questions/12686180/
                                                        </a>
                                                </p>
                                       
页: [1]
查看完整版本: ios - 在 PhoneGap 应用程序中检测 iPhone 和其他 iOS 设备上的静音事件和状态?