Is there any possibility to control HTML5 audio volume on IOS?
我使用html5音频库Buzz将声音添加到浏览器游戏中。 有一个切换按钮可以静音和取消静音,在台式机和Android设备上效果很好。 不幸的是,似乎IOS上的音频标签非常有限,因此我无法在Mobile Safari中使音频静音(请参阅https://developer.apple.com/library/archive/documentation/AudioVideo/Conceptual/Using_HTML5_Audio_Video/Introduction/Introduction。 html):
On iOS devices, the audio level is always under the user’s physical control. The volume property is not settable in JavaScript. Reading the volume property always returns 1.
您知道在Mobile Safari中控制html5音频标签音量的任何解决方法吗?
要为iOS添加音量更改支持,而不是将整个应用程序从html5音频重写为Web音频,可以通过
请在Mozilla网站https://developer.mozilla.org/en-US/docs/Web/API/AudioContext/createMediaElementSource中查看更多详细信息
我一直认为动态音量控制和交叉淡入淡出(众所周知)是不可能的。 苹果公司决定是这样。 除了....显然,Kodo Games的员工(特别是Nicola Hibbert?)已经将其发布并提供给任何人使用。 我刚刚在iOS 8上进行了检查。淡入淡出和交叉淡入淡出似乎可以工作!
签出(适用的新站点):Web Audio API入门
通过简单地停止所有声音并将变量
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | // set the variable var isMuted = false; // toggle audio function toggleMute() { var toggleAudioBtn = $(".toggleAudio"); if (isMuted == false) { sounds.stop(); isMuted = true; toggleAudioBtn.css("background-image","url('images/ui/btn_audio_mute.png')"); } else { isMuted = false; toggleAudioBtn.css("background-image","url('images/ui/btn_audio.png')"); } }; // for every sound check if sound is muted if(isMuted == false) { sound.play(); } |