久久国产亚洲日韩一本,欧美日韩专区国产精品,久久精品成人欧美大片,久久久久久久岛国免费AV,亚洲欧洲精品一区二区

新聞建站cms系統、政府cms系統定制開發

廣州網站建設公司-閱速公司

asp.net新聞發布系統、報紙數字報系統方案
/
http://www.ainiby.com/
廣州網站建設公司
您當前位置:首頁>網站技術

網站技術

Uncaught (in promise) DOMException: play() failed

發布時間:2018/11/6 22:49:22  作者:Admin  閱讀:1459  

廣告:

Uncaught (in promise) DOMException: play() failed because the user didn't interact with the document first. https://goo.gl/xX8pDD

function playOrPaused() {

console.log(typeof audio);

console.log(typeof audio.paused);

if (audio.paused) {

audio.play(); //ERROR:Uncaught (in promise) DOMException: The element has no supported sources.

}

}

原來的插入audio的源碼如下, 播放音頻的時候在瀏覽器和調試器的debug環境會報如上錯誤,但是不影響iPhone等手機的使用

查閱相關資料發現audio可以支持兩種方式設置src,如下:

1. Permitted content: If the element has a src attribute: zero or more <track> elements, followed by transparent content that contains no media elements — that is, no <audio> or <video> elements.

2. Else: zero or more <source> elements, followed by zero or more <track> elements, followed by transparent content that contains no media elements, that is no <audio> or <video> elements.

并且:src嵌入的音頻的URL。 該URL應遵從 HTTP access controls. 這是一個可選屬性;你可以在audio元素中使用 元素來替代該屬性指定嵌入的音頻。

于是改成第二種方案,解決問題,如下:

<audio id="audio">

<source src="http://ossweb-img.qq.com/images/lol/m/act/a20160315live/shake_sound_male.mp3" type="audio/mpeg">

Your browser does not support the audio tag.

</audio>

廣告:

相關文章
DOMException
cms新聞系統購買咨詢
掃描關注 廣州閱速軟件科技有限公司
掃描關注 廣州閱速科技
主站蜘蛛池模板: 大埔区| 鸡西市| 潍坊市| 丰顺县| 涞水县| 江安县| 禄劝| 涞水县| 广东省| 辽阳市| 仪陇县| 南雄市| 聂荣县| 淮北市| 微山县| 天门市| 西乌珠穆沁旗| 墨脱县| 雅江县| 鄂温| 庆阳市| 临泽县| 田阳县| 鄂尔多斯市| 庆城县| 永寿县| 宿松县| 吐鲁番市| 鄂托克前旗| 苗栗市| 和田市| 炉霍县| 芒康县| 申扎县| 明星| 呼伦贝尔市| 晋州市| 吴忠市| 遵化市| 平南县| 永嘉县|