Note that there are some explanatory texts on larger screens.

plurals
  1. POIs Web Audio API source.start(0) supported on Safari (it works just fine on Chrome)?
    text
    copied!<p>I'm trying to implement Web Audio API. The code works on Chrome 29.0.1547.76 but not on Safari 6.0.5 (8536.30.1). The key is whether I use noteOn(0) or start(0).</p> <p>I want to use start() so that I can play part of a sound: </p> <pre><code>asource.start(0, 2, 1); </code></pre> <p>works fine in Chrome (plays immediately, starts at the 2 s mark, plays for 1 s) but results in </p> <pre><code>TypeError: 'undefined' is not a function (evaluating 'asource.start(0, 2, 1)') </code></pre> <p>on Safari. Replacing that one line with</p> <pre><code>asource.noteOn(0); </code></pre> <p>works. [Well, I need to call noteOff(0) instead of stop(0).] I get the same error with start(0). So, I'm assuming that Safari does not implement start(0)? But if so, why do some of the examples at <a href="http://www.html5rocks.com/en/tutorials/webaudio/intro/#toc-context" rel="nofollow">HTML5 Rocks</a> that use start(0) work?</p> <p>For reference, here's the complete web page. I've tried many different sounds/formats; all result in the same error.</p> <pre><code>&lt;!DOCTYPE html&gt; &lt;html lang=en&gt; &lt;head&gt; &lt;meta charset="utf-8"&gt; &lt;title&gt;Web Audio API Issue&lt;/title&gt; &lt;/head&gt; &lt;body&gt; &lt;p&gt;Example working on Chrome but not Safari when using start()&lt;/p&gt; &lt;button id="Load" onclick="init()" &gt;Load&lt;/button&gt; &lt;button id="Play" onclick="playSound()" disabled&gt;Play&lt;/button&gt; &lt;button id="Stop" onclick="stopSound()" disabled&gt;Stop&lt;/button&gt; &lt;script&gt; var web_audio_context; var abuffer; var asource; function init() { contextClass = (window.AudioContext || window.webkitAudioContext || window.mozAudioContext || window.msAudioContext); web_audio_context = new contextClass(); var theURL = './digits.mp3'; var xhr = new XMLHttpRequest(); xhr.open('GET', theURL, true); xhr.responseType = 'arraybuffer'; xhr.onload = function(e) { finishedLoading(this.response); }; xhr.send(); } function finishedLoading(arrayBuffer) { web_audio_context.decodeAudioData(arrayBuffer, function(buffer) { abuffer = buffer; document.getElementById('Load').disabled = true; document.getElementById('Play').disabled = false; document.getElementById('Stop').disabled = false; }, function(e) { console.log('Error decoding file', e); }); } function playSound() { asource = web_audio_context.createBufferSource(); asource.buffer = abuffer; asource.connect(web_audio_context.destination); asource.start(0, 2, 1); } function stopSound() { asource.stop(0); } &lt;/script&gt; &lt;/body&gt; &lt;/html&gt; </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload