2011-05-21 98 views
1

我只是有最基本的(我認爲)實現Chrome的Web音頻。Chrome網絡音頻不播放我的音頻

我在Chrome 13上啓用了網絡音頻,但我的聲音無法播放。我看到它被加載(http://pieterhordijk.com/sandbox/html5-audio-api/webkit-audiocontext-interface),但它只是不玩。

window.onload = init; 

var context; 
var source; 

function loadSample(url) { 
    var request = new XMLHttpRequest(); 
    request.open("GET", url, true); 
    request.responseType = "arraybuffer"; 

    request.onload = function() { 
     source.buffer = context.createBuffer(request.response, false); 
     source.looping = true; 
     source.noteOn(0); 
    } 

    request.send(); 
} 

function init() 
{ 
    context = new webkitAudioContext(); 
    source = context.createBufferSource(); 

    loadSample("/sandbox/test.oga"); 
} 

回答

3

好吧,我自己找到答案我不得不將它連接到輸出。

source.connect(context.destination);