Working example for MediaElementAudioSourceNode with Chrome Canary?

拟墨画扇 提交于 2019-12-19 10:48:14

问题


I'm experimenting with the W3C Web Audio API implemented and enabled in Google Chrome Canary builds. (i have 15.0.865.0 canary on Windows 7 x64 at the moment) Demo applications work just fine.

I like to use MediaElementAudioSourceNode because i like to play a larger OGG music. For such audio files the API says that i should use this instead of AudioBufferSourceNode.

I've written a very simple example:

  <script type="text/javascript">
      var audioElement = document.createElement('audio');
      audioElement.setAttribute('src', 'dubfx.ogg');

      var audioContext = new webkitAudioContext();
      var streamingAudioSource = audioContext.createMediaElementSource(audioElement);
      streamingAudioSource.connect(audioContext.destination);
  </script>

However i just hear clicks instead of actual audio. I see no errors in the JavaScript console so i guess the code is okay, maybe some initialization is missing. If i call audioElement.play() instead of the routing through the Web Audio API, the music plays just fine. Did i miss something or maybe the current WebKit implementation is broken?


回答1:


Just talked to Chris Rogers (the spec editor) about this today. The MediaElementAudioSourceNode is exposed in Canary/Chromium builds but the internals are not hooked up yet. It'll be a while longer before you can use the <audio> tag with the Web Audio API.



来源:https://stackoverflow.com/questions/7233973/working-example-for-mediaelementaudiosourcenode-with-chrome-canary

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!