简体   繁体   English

Meteor DOMException:无法解码音频数据

[英]Meteor DOMException: Unable to decode audio data

EDIT : I just created a new Meteor Project and it worked :D wow.But it still doesnt work on my core project..looks like i have different settings. 编辑:我刚刚创建了一个新的流星项目,它工作:D哇。但它仍然无法在我的核心项目上工作..看起来像我有不同的设置。

In my Meteor.js project i have 4 .mp3 -files located in public/sounds/xyz.mp3 . 在我的Meteor.js项目中,我有4个.mp3文件位于public/sounds/xyz.mp3 I load these .mp3 with : 我加载这些.mp3

 let soundRequest = new XMLHttpRequest();
    soundRequest.open('GET', this._soundPath, true);
    soundRequest.responseType = 'arraybuffer';
    let $this = this;
    soundRequest.onload = function () {
        Core.getAudioContext().decodeAudioData(soundRequest.response, function (buffer) {
            $this.source.buffer = buffer;
            $this.source.loop = true;
            $this.source.connect($this.panner);
        });
    };
soundRequest.send();

This WORKS on google Chrome , but when i build the app via meteor run android-device , i get the following error message : DOMException: Unable to decode audio data I wonder if this is a bug because loading .png or .jpg works just fine in the mobile version. 这个在google Chrome ,但当我通过meteor run android-device构建应用程序时,我收到以下错误消息: DOMException: Unable to decode audio data我不知道这是一个错误,因为加载.png.jpg工作得很好在移动版中。 I have not installed any packages beside meteor add crosswalk but deinstalling this doesnt help either. 我没有在meteor add crosswalk旁边安装任何软件包,但卸载这个也没有帮助。

You shouldn't need to do a http request to get a local resource. 您不需要执行http请求来获取本地资源。 You can just refer to a local url. 您可以参考本地网址。 On the Android device the path is different. 在Android设备上,路径是不同的。 See this code: 看到这段代码:

  function getSound(file) {
    var sound = "/sounds/"+file;
    if (Meteor.isCordova) {
      var s;
      if (device.platform.toLowerCase() === "android") {
        sfile = cordova.file.applicationDirectory.replace('file://', '') + 'www/application/app' + sound;
      }
      else {
        sfile = cordova.file.applicationDirectory.replace('file://', '') + sound;
      }
      var s = new Media(
        sfile,
        function (success) {
          console.log("Got sound "+file+" ok ("+sfile+")");
          s.play();
        },
        function (err) {
          console.log("Get sound "+file+" ("+sfile+") failed: "+err);
        }
      );
    } else {
      var a = new Audio(sound);
      a.play();
    }
  }

On a device it loads the sound file asynchronously and then plays it. 在设备上,它以异步方式加载声音文件,然后播放它。 In the browser it just loads and plays it synchronously. 在浏览器中,它只是加载并同步播放它。

This web API is not supported on android device but works on chrome browser of android Android设备不支持此Web API,但适用于Android的chrome浏览器

Check browser specification in this link https://developer.mozilla.org/en-US/docs/Web/API/AudioContext/decodeAudioData 检查此链接中的浏览器规范https://developer.mozilla.org/en-US/docs/Web/API/AudioContext/decodeAudioData

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 未捕获(承诺)DOMException:无法解码音频数据 - Uncaught (in promise) DOMException: Unable to decode audio data Web Audio API 不一致无法解码音频数据 DOMException - Web Audio API Inconsistent Unable to decode audio data DOMException 未捕获(承诺)DOMException:无法将音频数据从 pyAudio 解码到 JavaScript - Uncaught (in promise) DOMException: Unable to decode audio data from pyAudio to JavaScript 如何解决 Web 音频 API 的问题:DOMException:无法解码音频数据 - How to fix issue with Web Audio API: DOMException: Unable to decode audio data 浏览器无法处理JS调用的mp3资源,而是将其下载(DOMException:无法解码音频数据) - browser cant process mp3 resources called by JS , instead it will download them (DOMException: Unable to decode audio data) encodeAudioData-无法解码音频数据 - decodeAudioData - Unable to decode audio data JavaScript 将 arraybuffer 作为音频播放。 需要帮助解决“decodeaudiodata无法解码音频数据” - JavaScript play arraybuffer as audio. Need help to solve "decodeaudiodata unable to decode audio data" 如何解码二进制音频数据? - How to decode binary audio data? 错误:在A帧环境中播放声音时,无法解码音频数据 - Error: Unable to decode audio data when playing sound onclick within A-frame Environment JavaScript Web Audio:无法正确解码音频数据? - JavaScript Web Audio: cannot properly decode audio data?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM