我有这个广播流播放器代码。它在 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/