简体   繁体   English

Firefox中的HTML5音频标记错误

[英]HTML5 audio tag bug in Firefox

I'm building a website with a music player, using an <audio> tag. 我正在使用<audio>标签构建一个带音乐播放器的网站。

I'm using jQuery to make some basic operation like "pause" and "play": 我正在使用jQuery来做一些像“暂停”和“播放”这样的基本操作:

$("#music_player")[0].pause();

$("#music_player")[0].play();

In Chrome everything seems to be fine, but in Firefox it isn't working. 在Chrome中,一切似乎都很好,但在Firefox中它不起作用。

Does somebody know what is the problem? 有人知道这是什么问题吗? Or what other commands in JavaScript can control the audio tag? 或者JavaScript中的其他命令可以控制音频标签?

You cannot play mp3 files in Opera and Firefox. 你不能在Opera和Firefox中播放mp3文件。 Use both .ogg and .mp3 format to play audio in all browsers. 使用.ogg和.mp3格式在所有浏览器中播放音频。

<audio id="music_player">
    <source src="sound.mp3"></source>
    <source src="sound.ogg"></source>
</audio> 

First of all I would suggest to follow this link: http://www.position-absolute.com/articles/introduction-to-the-html5-audio-tag-javascript-manipulation/ 首先,我建议关注此链接: http//www.position-absolute.com/articles/introduction-to-the-html5-audio-tag-javascript-manipulation/

It give an example on how to use audio tag in html and manipulate it in javascript. 它给出了一个如何在html中使用音频标签并在javascript中操作它的示例。 If you see Your browser does not support the audio tag. 如果您看到Your browser does not support the audio tag. instead of an audio widget, thats because your firefox version doesn't support HTML5 audio tag. 而不是音频小部件,这是因为你的firefox版本不支持HTML5音频标签。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM