去年在Chrome上碰见过Audio 的CORS问题
怎么都绕不过去
最后在自己的服务器上写了个代理才算完事
直观地觉得你这个也跟CORS有关系
【 在 singforyou (为你歌唱) 的大作中提到: 】
: 标 题: chrome对html5的兼容问题
: 发信站: 水木社区 (Thu Aug 11 20:17:54 2016), 站内
:
: 下面这段JS代码在MS edge和firefox上都工作正常,就在chrome下报unsupported source。运行环境是win10,请帮看一下是代码问题还是chrome对html5和web audio api支持的问题。谢谢。
: -------------------------------------------------------------------
: <!doctype html>
: <html lang="en">
: <head>
: <meta charset="UTF-8" />
: <title>Document</title>
: <style type="text/css">
: #cas{
: position: absolute;
: left:0;top:0;bottom: 0;right: 0;
: margin: auto;
: border: 1px solid;
: }
: </style>
: </head>
: <body>
: <input type="file" name="" id="music" />
: <canvas id="cas" width="1000" height="540"></canvas>
: <script type="text/javascript" charset="utf-8">
: var music = document.getElementById("music"),canvas = document.getElementById("cas"),ctx=canvas.getContext("2d");
:
: window.AudioContext= window.AudioContext||window.webkitAudioContext||window.mozAudioContext;
: window.RAF = (function(){
: return window.requestAnimationFrame || window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame || window.oRequestAnimationFrame || window.msRequestAnimationFrame || function (callback) {window.setTimeout(callback, 1000 / 60); };
: })();
:
: var AC = new AudioContext();
:
: music.onchange = function(){
: if(music.files.length!==0){
: var audioElement = document.createElement('audio');
: audioElement.loop = true;
: audioElement.crossOrigin = 'anonymous';
: audioElement.src = music.files[0];
:
: audioElementSource = AC.createMediaElementSource(audioElement);
:
: audioElementSource.connect(AC.destination);
:
: //audioElement.load();
: audioElement.play();
: }
: }
:
: </script>
: </body>
: </html>
: --
:
: ※ 来源:·水木社区
http://www.newsmth.net·[FROM: 111.204.125.*]
--
FROM 114.149.158.*