语言

Menu
Sites
Language
Web Audio API and MediaElementSource not connecting

Hello!

I have one terrible problem while developing app to the Russian App Challenge.

I need to connect <audio> element as source to Web Audio API.

But if i connect it like this:

<!DOCTYPE HTML>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0">
<meta name="description" content="bug"/>
</head>
<body>    
<script>

var context, audio, source, destination, analiser, loop, frecData, outputElementDOM;

context = new webkitAudioContext();
audio = new Audio();
audio.src = '/path/to/audio/file';

outputElementDOM = document.createElement('pre');

source = context.createMediaElementSource(audio);
analiser = context.createAnalyser();
destination = context.destination;
frecData = new Uint8Array(analiser.frequencyBinCount);

loop = function(){
	analiser.getByteFrequencyData(frecData);
  	var temp = '';
  	for (var i = 0; i < frecData.length; i++) {
  		temp += frecData[i] + '\n';
  	};

  	outputElementDOM.textContent = temp;
	window.webkitRequestAnimationFrame(loop);
}

source.connect(analiser);
analiser.connect(destination);

audio.play();
loop();

document.body.appendChild(outputElementDOM)

</script>
</body>
</html>

in RD-PQ i hear the music but see only zeros. i think MediaElementAudioSourceNode outputs silence, but i dont know why

in Chrome in my laptop it works fine and i get the needed data.

if i load big mp3 via XMLHTTPRequest to buffer, Tizen craches while decoding audio data.

please help

编辑者为: Roman Pekarskiy 28 8月, 2014

响应

1 回复
Roman Pekarskiy

I have read the dev-guide for web-developers and find this:

W3C Web Audio API describes a high-level JavaScript API for processing and synthesizing audio in Web Applications. The interfaces and attribute currently not supported are: MediaElementAudioSourceNode and MediaStreamAudioSourceNode interfaces.

Close