admin管理员组文章数量:1277271
Here is a super simple example that I am trying to run on an iphone in chrome. Other web audio API examples like this one / work, but not mine :(
<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body>
<script>
var audioContext, osc
audioContext = new (window.AudioContext || window.webkitAudioContext);
osc = audioContext.createOscillator()
osc.connect(audioContext.destination)
if (osc.noteOn) osc.start = osc.noteOn
osc.start(0)
osc.frequency.value = 440
</script>
</body>
</html>
Any idea what's wrong?
EDIT
To summarize the answer :
- start the audio in response to user interaction
- check that mute switch is off
Here is a super simple example that I am trying to run on an iphone in chrome. Other web audio API examples like this one http://alxgbsn.co.uk/wavepad/ work, but not mine :(
<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body>
<script>
var audioContext, osc
audioContext = new (window.AudioContext || window.webkitAudioContext);
osc = audioContext.createOscillator()
osc.connect(audioContext.destination)
if (osc.noteOn) osc.start = osc.noteOn
osc.start(0)
osc.frequency.value = 440
</script>
</body>
</html>
Any idea what's wrong?
EDIT
To summarize the answer :
- start the audio in response to user interaction
- check that mute switch is off
1 Answer
Reset to default 12iOS will only let you start playing sound with the Web Audio API as a result of a user action.
Try putting that code inside of some kind of event handler.
var elem = document.getElementById('play'),
audioContext = new (window.AudioContext || window.webkitAudioContext),
osc = audioContext.createOscillator();
osc.connect(audioContext.destination);
if (osc.noteOn) osc.start = osc.noteOn
osc.frequency.value = 440;
play.addEventListener('click', function() {
osc.start(0);
}, false);
本文标签: javascriptSimple oscillatorbut no sound with web audio API on IOSStack Overflow
版权声明:本文标题:javascript - Simple oscillator, but no sound with web audio API on IOS - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741220961a2360961.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论