前端 - html5 audio不能播放
問題描述
問題解答
回答1:代碼沒問題,請自行查看:1、瀏覽器是否支持HTML52、音頻文件路徑是否正確,音頻文件格式是否正確3、變量是否沖突等
回答2:應該是你的資源的問題, 我在本地調(diào)試沒問題
<!DOCTYPE html><html lang='en'><head> <meta charset='UTF-8'> <title>Document</title></head><body> <script> var audio = document.createElement(’audio’); var source = document.createElement(’source’); audio.setAttribute(’controls’, ’controls’); audio.innerHTML = '您的瀏覽器不支持 audio 標簽。'; source.src = ’./hello.mp3’; source.setAttribute(’type’,’audio/mpeg’); audio.appendChild(source); document.body.appendChild(audio); window.addEventListener(’click’, function(){audio.play(); }); </script></body></html>
運行結(jié)果:(注意紅框中不是0:00)
相關(guān)文章:
1. python - pymysql建立連接出錯2. 默認輸出類型為json,如何輸出html3. mysql 遠程連接出錯10060,我已經(jīng)設(shè)置了任意主機了。。。4. python的正則怎么同時匹配兩個不同結(jié)果?5. 數(shù)組排序,并把排序后的值存入到新數(shù)組中6. php多任務倒計時求助7. MySQL的聯(lián)合查詢[union]有什么實際的用處8. PHP訂單派單系統(tǒng)9. html5 - css3scale和rotate同時使用轉(zhuǎn)換成matrix寫法該如何轉(zhuǎn)換?10. win10 python3.5 matplotlib使用報錯
