网络音频API:德codeAudioData不会去code巨著在Chrome [英] Web Audio API: decodeAudioData doesn't decode opus in Chrome

查看:172
本文介绍了网络音频API:德codeAudioData不会去code巨著在Chrome的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在试图使作品与数据包网络音频API工作。但问题是,而应该由Firefox和Chrome可以原生支持,只有火狐可以去code。使用从网络音频API德codeAudioData OPUS样本流。 Chrome并承认该文件时,我拖OPUS文件到浏览器中,它也确实起到了!所以我不知道,我可能是错的做一些在这里的Chrome造成故障。

然后我用一些示例code从 http://awm.jp /~yoya/js/audio/meow.html 只是装载OPUS文件,并尝试去code吧。火狐再做,和Chrome不会。所以,我想知道,如果有人可以证实我的发现或者告诉我我在做什么错在这里。下面是从前面的链接的修改后的版本。谢谢!

 <!DOCTYPE HTML PUBLIC -  // W3C // DTD HTML 4.01过渡// ENhttp://www.w3.org/TR/html4/loose。 DTD>
< HTML和GT;
< HEAD>
< META HTTP-EQUIV =Content-Type的CONTENT =text / html的;字符集= ISO-8859-15>
<标题>德codeAudioData样品< /标题>
< /头>&所述; SCRIPT SRC =HTTP://$c$c.jquery.com/jquery-1.9.1.min.js>&下; /脚本>
<脚本类型=文/ JavaScript的>
// $(文件)。就绪(函数(){
    VAR catMeowingBuffer = NULL;
    window.AudioContext = window.AudioContext || window.webkitAudioContext;
    VAR语境=新AudioContext();    功能的onError(ERR){
       的console.log(无法取消code);
    }    功能loadCatSound(URL){
      VAR要求=新XMLHtt prequest();
      request.open(GET,网址,真实);
      request.responseType ='arraybuffer';      //德code异步
      request.onload =功能(){
          context.de codeAudioData(request.response,函数(缓冲){
          catMeowingBuffer =缓冲;
           变种SRC = context.createBufferSource();
           src.buffer = catMeowingBuffer
           src.connect(context.destination);
           src.start(0);
        },onerror的);
      }
      request.send();
    }    loadCatSound(opus.opus);    功能playCatSound(){
        如果(catMeowingBuffer!== NULL){
           变种SRC = context.createBufferSource();
           src.buffer = catMeowingBuffer
           src.connect(context.destination);
           src.start(0);
        }
    }
//});
< / SCRIPT><身体GT;
< H1>德codeAudioData样品< / H1>
<按钮的onclick =playCatSound();> playCatSound< /按钮><小时>
<地址>< /地址>
< /身体GT; < / HTML>


解决方案

这是在Chrome中的错误。请参见的https://$c$c.google.com/ p /铬/问题/细节?ID = 409402

I'm currently trying to make Opus packets work with Web Audio API. The problem is however, while it should be natively supported by FireFox and Chrome, only FireFox can decode a stream of OPUS samples using decodeAudioData from the Web Audio API. Chrome does recognize the file when I drag the opus file into the browser and it also does play it! So I'm wondering that I may be doing something wrong here causing failure in Chrome.

Then I used some sample code from http://awm.jp/~yoya/js/audio/meow.html just load an opus file and try to decode it. Again Firefox does, and Chrome doesn't. So I'm wondering if someone can confirm my finding or tell me what I'm doing wrong here. Below is the modified version from the earlier link. Thanks!

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-15">
<title> decodeAudioData sample </title>
</head>

<script src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
<script type="text/javascript">
//$(document).ready(function() {
    var catMeowingBuffer = null;
    window.AudioContext = window.AudioContext||window.webkitAudioContext;
    var context = new AudioContext();

    function onError(err) {
       console.log("unable to decode");
    }

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

      // Decode asynchronously
      request.onload = function() {
          context.decodeAudioData(request.response, function(buffer) {
          catMeowingBuffer = buffer;
           var src = context.createBufferSource();
           src.buffer = catMeowingBuffer
           src.connect(context.destination);
           src.start(0);
        }, onError);
      }
      request.send();
    }

    loadCatSound("opus.opus");

    function playCatSound() {
        if (catMeowingBuffer !== null) {
           var src = context.createBufferSource();
           src.buffer = catMeowingBuffer
           src.connect(context.destination);
           src.start(0);
        }
    }
//});
</script>

<body>
<h1> decodeAudioData sample </h1>


<button onclick="playCatSound();"> playCatSound </button>

<hr>
<address></address>
</body> </html>

解决方案

This is a bug in Chrome. See https://code.google.com/p/chromium/issues/detail?id=409402.

这篇关于网络音频API:德codeAudioData不会去code巨著在Chrome的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆