pbootcms网站模板|日韩1区2区|织梦模板||网站源码|日韩1区2区|jquery建站特效-html5模板网

    • <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="8xdfpz3" 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="cqoym8i" 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 輸出零的處理方法,對(duì)大家解決問題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!

                  問題描述

                  我有以下 html 頁面,我正在嘗試展示一個(gè)用于演示具有本地存儲(chǔ)的 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>
                  

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

                  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;
                  

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

                  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對(duì)象后,添加如下內(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 輸出零的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

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

                  相關(guān)文檔推薦

                  Browser waits for ajax call to complete even after abort has been called (jQuery)(即使在調(diào)用 abort (jQuery) 之后,瀏覽器也會(huì)等待 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 無法加載,請(qǐng)求的資源上不存在“Access-Control-Allow-Origin標(biāo)頭) - IT屋-程序員軟件開發(fā)技術(shù)分
                  Is it possible for XHR HEAD requests to not follow redirects (301 302)(XHR HEAD 請(qǐng)求是否有可能不遵循重定向 (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="8d8nwgq" id='sVw3B'><tfoot id='sVw3B'></tfoot><dl id='sVw3B'><fieldset id='sVw3B'></fieldset></dl></div>

                          • 主站蜘蛛池模板: 苏商学院官网 - 江苏地区唯一一家企业家自办的前瞻型、实操型商学院 | 学习虾-免费的学习资料下载平台 雪花制冰机(实验室雪花制冰机)百科 | 同步带轮_同步带_同步轮_iHF合发齿轮厂家-深圳市合发齿轮机械有限公司 | 钢结构-钢结构厂房-钢结构工程[江苏海逵钢构厂] | 大鼠骨髓内皮祖细胞-小鼠神经元-无锡欣润生物科技有限公司 | SDG吸附剂,SDG酸气吸附剂,干式酸性气体吸收剂生产厂家,超过20年生产使用经验。 - 富莱尔环保设备公司(原名天津市武清县环保设备厂) | 游戏版号转让_游戏资质出售_游戏公司转让-【八九买卖网】 | 生鲜配送系统-蔬菜食材配送管理系统-连锁餐饮订货配送软件-挪挪生鲜供应链管理软件 | 阳光模拟试验箱_高低温试验箱_高低温冲击试验箱_快速温变试验箱|东莞市赛思检测设备有限公司 | 焊管生产线_焊管机组_轧辊模具_焊管设备_焊管设备厂家_石家庄翔昱机械 | 动物解剖台-成蚊接触筒-标本工具箱-负压实验台-北京哲成科技有限公司 | 马尔表面粗糙度仪-MAHR-T500Hommel-Mitutoyo粗糙度仪-笃挚仪器 | 振动台-振动试验台-振动冲击台-广东剑乔试验设备有限公司 | 杰恒蠕动泵-蠕动泵专业厂家-19年专注蠕动泵 | 常州减速机_减速机厂家_常州市减速机厂有限公司| 附着力促进剂-尼龙处理剂-PP处理剂-金属附着力处理剂-东莞市炅盛塑胶科技有限公司 | 数控走心机-走心机价格-双主轴走心机-宝宇百科 | 汽车润滑油厂家-机油/润滑油代理-高性能机油-领驰慧润滑科技(河北)有限公司 | 高低温万能试验机_拉力试验机_拉伸试验机-馥勒仪器科技(上海)有限公司 | 氮化镓芯片-碳化硅二极管 - 华燊泰半导体 | 跨境物流_美国卡派_中大件运输_尾程派送_海外仓一件代发 - 广州环至美供应链平台 | 深圳离婚律师咨询「在线免费」华荣深圳婚姻律师事务所专办离婚纠纷案件 | 地磅-地秤-江阴/无锡地磅-江阴天亿计量设备有限公司_ | 桂林腻子粉_内墙外墙抗裂砂浆腻子粉推荐广西鑫达涂料厂家供应 | 生物制药洁净车间-GMP车间净化工程-食品净化厂房-杭州波涛净化设备工程有限公司 | 信阳网站建设专家-信阳时代网联-【信阳网站建设百度推广优质服务提供商】信阳网站建设|信阳网络公司|信阳网络营销推广 | 地图标注-手机导航电子地图如何标注-房地产商场地图标记【DiTuBiaoZhu.net】 | 抖音短视频运营_企业网站建设_网络推广_全网自媒体营销-东莞市凌天信息科技有限公司 | 自动气象站_气象站监测设备_全自动气象站设备_雨量监测站-山东风途物联网 | 紧急泄压人孔_防爆阻火器_阻火呼吸阀[河北宏泽石化] | 四川成人高考_四川成考报名网 | 苗木价格-苗木批发-沭阳苗木基地-沭阳花木-长之鸿园林苗木场 | 湖南印刷厂|长沙印刷公司|画册印刷|挂历印刷|台历印刷|杂志印刷-乐成印刷 | 校服厂家,英伦校服定做工厂,园服生产定制厂商-东莞市艾咪天使校服 | 耐力板-PC阳光板-PC板-PC耐力板 - 嘉兴赢创实业有限公司 | 植筋胶-粘钢胶-碳纤维布-碳纤维板-环氧砂浆-加固材料生产厂家-上海巧力建筑科技有限公司 | 杭州标识标牌|文化墙|展厅|导视|户内外广告|发光字|灯箱|铭阳制作公司 - 杭州标识标牌|文化墙|展厅|导视|户内外广告|发光字|灯箱|铭阳制作公司 | 钢结构厂房造价_钢结构厂房预算_轻钢结构厂房_山东三维钢结构公司 | 北京软件开发_软件开发公司_北京软件公司-北京宜天信达软件开发公司 | 东莞爱加真空科技有限公司-进口真空镀膜机|真空镀膜设备|Polycold维修厂家 | 右手官网|右手工业设计|外观设计公司|工业设计公司|产品创新设计|医疗产品结构设计|EMC产品结构设计 |