javascript - HTML5 <audio> 标签在 Firefox 和 Internet Explorer 上不起作用

标签 javascript html internet-explorer firefox html5-audio

我有这个广播流播放器代码。它在 Chrome 和 iOS Safari 上完美运行,但在 Firefox 和 Internet Explorer 11 上无法运行。

这是我的 index.php 文件的一部分:

<script type="text/javascript"
src="http://code.jquery.com/jquery-1.10.1.min.js"></script>

    <script>
function changeImage() {
    var image = document.getElementById('myImage');
    if (image.src.match("pause")) {
        image.src = "play.png";
       document.getElementById('sound1').pause();
    } else {
        image.src = "pause.png";
       document.getElementById('sound1').play();
    }
}
</script>

进入页面时,图片默认为“play.png”。当您按下它时,它会变为“pause.png”并且音乐开始播放。

这是 html 格式的脚本:

<audio id="sound1" src="http://radiostation.com:8000/stream" type="audio/mpeg"></audio>
    <img id="myImage" onclick="changeImage();" src="play.png" style="position: absolute; top: 130px; left: 23px;">

问题仅在于播放流,图像在所有浏览器上都会发生变化。将不胜感激任何帮助。谢谢:)

最佳答案

Firefox 和 Internet Explorer 不支持音频/aacp 内容,这是该流的格式

对于此流,您可以使用/stream2,它是在浏览器中得到更广泛支持的音频/mpeg

NOTE - developer version of firefox DOES support audio/aacp - so things may change in about 6 to 12 weeks

关于javascript - HTML5 <audio> 标签在 Firefox 和 Internet Explorer 上不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34667926/

相关文章:

javascript - Firefox - 记录 ionmonkey 编译和救助

javascript - 播放/暂停切换 onclick - Ajax

javascript - 使用 next 选择特定 html 标签的多个子标签

javascript - 添加/删除按钮不适用于重复的表单字段 - jquery

Jquery Draggable 不适用于 chrome 和 opera

javascript - 使用 Canvas 动画化 JS 中的排序算法

javascript - html 表单从网页传递到子 iframe 时不保留其元素的属性?

html - 如何使用 IE 在 Selenium RC 上使用 HTML TestSuite 和测试用例

html - IE下拉截止

css - 停止跨越 2 行的导航菜单