我想动态创建一个 html5 音频并播放它,代码如下:
function playAnotherMusic(playUrl){
var audioElement = document.createElement('audio');
audioElement.setAttribute('src', playUrl);
audioElement.setAttribute('controls', true);
audioElement.setAttribute('preload', true);
audioElement.setAttribute('type', 'audio/mpeg');
audioElement.addEventListener("load", function() {
audioElement.play();
}, true);
console.log(playUrl);
audioElement.load();
}
然而它不起作用,萤火虫攻击我”HTTP "Content-Type" of "audio/mpeg" is not supported.
"
我怎么解决这个问题?
您不能在 Firefox 中播放 mp3 文件,它不支持它们,您需要 Firefox 的 ogg 版本。除非情况发生变化,否则最好记住。
为什么 Firefox 不支持 中的 MP3 文件格式 https://stackoverflow.com/questions/4923136/why-doesnt-firefox-support-mp3-file-format-in-audio
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)