久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

    • <bdo id='P6Saf'></bdo><ul id='P6Saf'></ul>
  • <legend id='P6Saf'><style id='P6Saf'><dir id='P6Saf'><q id='P6Saf'></q></dir></style></legend>

    <small id='P6Saf'></small><noframes id='P6Saf'>

      <i id='P6Saf'><tr id='P6Saf'><dt id='P6Saf'><q id='P6Saf'><span id='P6Saf'><b id='P6Saf'><form id='P6Saf'><ins id='P6Saf'></ins><ul id='P6Saf'></ul><sub id='P6Saf'></sub></form><legend id='P6Saf'></legend><bdo id='P6Saf'><pre id='P6Saf'><center id='P6Saf'></center></pre></bdo></b><th id='P6Saf'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='P6Saf'><tfoot id='P6Saf'></tfoot><dl id='P6Saf'><fieldset id='P6Saf'></fieldset></dl></div>
    1. <tfoot id='P6Saf'></tfoot>

        由于 CORS 訪問限制本地 mp3 文件,MediaElementAudio

        MediaElementAudioSource outputs zeros due to CORS access restrictions local mp3 file(由于 CORS 訪問限制本地 mp3 文件,MediaElementAudioSource 輸出零)

        • <i id='8KdcA'><tr id='8KdcA'><dt id='8KdcA'><q id='8KdcA'><span id='8KdcA'><b id='8KdcA'><form id='8KdcA'><ins id='8KdcA'></ins><ul id='8KdcA'></ul><sub id='8KdcA'></sub></form><legend id='8KdcA'></legend><bdo id='8KdcA'><pre id='8KdcA'><center id='8KdcA'></center></pre></bdo></b><th id='8KdcA'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='8KdcA'><tfoot id='8KdcA'></tfoot><dl id='8KdcA'><fieldset id='8KdcA'></fieldset></dl></div>
            <legend id='8KdcA'><style id='8KdcA'><dir id='8KdcA'><q id='8KdcA'></q></dir></style></legend>

              <small id='8KdcA'></small><noframes id='8KdcA'>

              • <bdo id='8KdcA'></bdo><ul id='8KdcA'></ul>
                <tfoot id='8KdcA'></tfoot>

                  <tbody id='8KdcA'></tbody>

                  本文介紹了由于 CORS 訪問限制本地 mp3 文件,MediaElementAudioSource 輸出零的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  我有以下 html 頁面,我正在嘗試展示一個用于演示具有本地存儲的 mp3 的音頻可視化器的類:

                  I have the following html page that I'm trying to show a class for demonstrating an audio visualizer with an mp3 stored locally:

                  <!doctype html>
                  <html>
                  <head>
                      <header name = "Access-Control-Allow-Origin" value = "*" /> 
                      <style type = "text/css">
                              div#mp3_player{ width: 500px; height: 60px; background: #000; padding: 5px; margin: 50px auto;}
                          div#mp3_player > div > audio{ width: 500px; background: #000; float: left; }
                          div#mp3_player > canvas { width: 500px; height: 30px; background: #002D3C; float: left;}
                      </style>
                      <script>
                      //create new instance of audio 
                      var audio = new Audio();
                      audio.src = 'C:/Users/Adam/Desktop/1901.m4a';
                      audio.controls = true;
                      audio.loop = true;
                      audio.autoplay = true;
                  
                      var canvas, ctx, source, context, analyser, fbc_array, bars, bar_x, bar_width, bar_height;
                  
                      window.addEventListener("load", initMp3Player, false);
                  
                  
                      function frameLooper(){
                          window.webkitRequestAnimationFrame(frameLooper);
                          fbc_array = new Uint8Array(analyser.frequencyBinCount);
                          analyser.getByteFrequencyData(fbc_array);
                          ctx.clearRect(0, 0, canvas.width, canvas.height);
                          ctx.fillStyle = "#00CCFF";
                          bars = 100;
                          for (var i = 0; i < bars; i++){
                              bar_x = i * 3;
                              bar_width = 2;
                              bar_height = -(fbc_array[i]/2);
                              ctx.fillRect(bar_x, canvas.height, bar_width, bar_height);
                          }
                      }
                  
                      function initMp3Player(){
                          document.getElementById('audio_box').appendChild(audio);
                          context = new AudioContext();
                          analyser = context.createAnalyser();
                          canvas = document.getElementById('analyser_render');
                          ctx = canvas.getContext('2d');
                          source = context.createMediaElementSource(audio);
                          source.connect(analyser);
                          analyser.connect(context.destination);
                          frameLooper();
                      }
                  
                      </script>
                  
                  </head>
                  
                  <body>
                      <div id = "mp3_player">
                          <div id = "audio_box"></div>
                          <canvas id = "analyser_render"></canvas>
                      </div>
                  
                  </body>
                  

                  在使用腳本標簽中的所有代碼之前,我已經(jīng)讓 mp3 文件自動播放,不包括行下的代碼

                  I've gotten the mp3 file to play automatically before using all of the code in the script tag excluding what's below the line

                  audio.autoplay = true;
                  

                  但是當我包含 frameLooper 函數(shù)時,我收到消息MediaElementAudioSource 由于 CORS 訪問限制而輸出零."既然是本地文件,有沒有辦法規(guī)避這個問題?

                  but when I include the frameLooper function I get the message "MediaElementAudioSource outputs zeros due to CORS access restrictions." Is there anyway to circumvent this since it's a local file?

                  推薦答案

                  在初始化Audio對象后,添加如下內(nèi)容:

                  Just after initializing the Audio object, add the following:

                  audio.crossOrigin = "anonymous";
                  

                  這應(yīng)該可以防止 CORS 訪問限制.

                  This should prevent the CORS access restriction.

                  這篇關(guān)于由于 CORS 訪問限制本地 mp3 文件,MediaElementAudioSource 輸出零的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

                  【網(wǎng)站聲明】本站部分內(nèi)容來源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請聯(lián)系我們刪除處理,感謝您的支持!

                  相關(guān)文檔推薦

                  Browser waits for ajax call to complete even after abort has been called (jQuery)(即使在調(diào)用 abort (jQuery) 之后,瀏覽器也會等待 ajax 調(diào)用完成)
                  JavaScript innerHTML is not working for IE?(JavaScript innerHTML 不適用于 IE?)
                  XMLHttpRequest cannot load, No #39;Access-Control-Allow-Origin#39; header is present on the requested resource(XMLHttpRequest 無法加載,請求的資源上不存在“Access-Control-Allow-Origin標頭) - IT屋-程序員軟件開發(fā)技術(shù)分
                  Is it possible for XHR HEAD requests to not follow redirects (301 302)(XHR HEAD 請求是否有可能不遵循重定向 (301 302))
                  XMLHttpRequest 206 Partial Content(XMLHttpRequest 206 部分內(nèi)容)
                  Restrictions of XMLHttpRequest#39;s getResponseHeader()?(XMLHttpRequest 的 getResponseHeader() 的限制?)

                  1. <tfoot id='sVw3B'></tfoot>

                      <tbody id='sVw3B'></tbody>
                      <bdo id='sVw3B'></bdo><ul id='sVw3B'></ul>

                      <small id='sVw3B'></small><noframes id='sVw3B'>

                          <legend id='sVw3B'><style id='sVw3B'><dir id='sVw3B'><q id='sVw3B'></q></dir></style></legend>

                        1. <i id='sVw3B'><tr id='sVw3B'><dt id='sVw3B'><q id='sVw3B'><span id='sVw3B'><b id='sVw3B'><form id='sVw3B'><ins id='sVw3B'></ins><ul id='sVw3B'></ul><sub id='sVw3B'></sub></form><legend id='sVw3B'></legend><bdo id='sVw3B'><pre id='sVw3B'><center id='sVw3B'></center></pre></bdo></b><th id='sVw3B'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='sVw3B'><tfoot id='sVw3B'></tfoot><dl id='sVw3B'><fieldset id='sVw3B'></fieldset></dl></div>

                          • 主站蜘蛛池模板: 亚洲交性 | av日韩一区 | 国产精品久久久久久久一区二区 | 99久久婷婷国产综合精品电影 | 国产成人精品一区二区三 | 日韩精品视频在线播放 | 在线欧美视频 | 亚洲夜夜爽 | 国产一区二区黑人欧美xxxx | 久久r免费视频 | 男女免费在线观看视频 | 日韩欧美一区二区三区免费观看 | 午夜精品久久久久久不卡欧美一级 | 日韩成人精品在线 | 成人福利影院 | 九九伊人sl水蜜桃色推荐 | 亚洲区一区二区 | 成人高清视频在线观看 | 碰碰视频 | 久久久久九九九女人毛片 | 亚洲一区二区三区高清 | 久久久毛片| 欧美中文字幕一区二区三区亚洲 | 春色av| 色综合99| 欧美成人自拍视频 | 成年视频在线观看福利资源 | 韩国理论电影在线 | 中文精品视频 | 久久福利电影 | 毛片免费看 | 国产高清视频 | 一区二区三区国产精品 | 午夜精品久久久久久不卡欧美一级 | 97国产一区二区精品久久呦 | 波多野结衣中文字幕一区二区三区 | 日韩在线视频一区二区三区 | 91精品国产一区二区三区香蕉 | 国产专区在线 | 老头搡老女人毛片视频在线看 | 中文字幕av一区二区三区 |