Trang web này sẽ có chức năng hạn chế trong khi chúng tôi trải qua bảo trì để cải thiện trải nghiệm của bạn. Nếu một bài viết không giải quyết được vấn đề của bạn và bạn muốn đặt câu hỏi, chúng tôi có cộng đồng hỗ trợ của chúng tôi đang chờ để giúp bạn tại @FirefoxSupport trên Twitter và /r/firefox trên Reddit.

Tìm kiếm hỗ trợ

Tránh các lừa đảo về hỗ trợ. Chúng tôi sẽ không bao giờ yêu cầu bạn gọi hoặc nhắn tin đến số điện thoại hoặc chia sẻ thông tin cá nhân. Vui lòng báo cáo hoạt động đáng ngờ bằng cách sử dụng tùy chọn "Báo cáo lạm dụng".

Tìm hiểu thêm

How to get Audio html5 tag to work in Firefox

  • 3 trả lời
  • 1 gặp vấn đề này
  • 22 lượt xem
  • Trả lời mới nhất được viết bởi cor-el

more options

Hi guys, I'm having a really annoying problem, in which HTML5 audio tags either do not work at all in Firefox; they have a huge delay before playing, or they play (but with many errors and inconsistencies).

I'm using Firefox 35.0

I'm using ONLY .ogg files

Here is an example of my code:

<audio autoplay="autoplay" controls="controls" id="audio" style="display:none;">
 <source src="Music.ogg"
         type='audio/ogg'>
</audio>

<script>
  myAudio=document.getElementById('audio');
  myAudio.addEventListener('canplaythrough', function() {
    this.currentTime = 1;
    this.play();
  });
</script>

The code is working on both Internet Explorer and Chrome.

When I remove the display:none attribute, the audio player is visible.

Hi guys, I'm having a really annoying problem, in which HTML5 audio tags either do not work at all in Firefox; they have a huge delay before playing, or they play (but with many errors and inconsistencies). I'm using Firefox 35.0 I'm using ONLY .ogg files Here is an example of my code: <pre><nowiki><audio autoplay="autoplay" controls="controls" id="audio" style="display:none;"> <source src="Music.ogg" type='audio/ogg'> </audio> <script> myAudio=document.getElementById('audio'); myAudio.addEventListener('canplaythrough', function() { this.currentTime = 1; this.play(); }); </script></nowiki></pre> The code is working on both Internet Explorer and Chrome. When I remove the display:none attribute, the audio player is visible.

Được chỉnh sửa bởi cor-el vào

Tất cả các câu trả lời (3)

more options

I've called the big guys to help you. Good luck.

more options

Hi there, I appreciate the response. Fortunately, I just figured out what the cause of the problem was!

For some reason, the Javascript I was using broke the sound in Firefox. Without the script part, the sound works fine.

This creates a couple of new functionality problems, but they don't have anything to do with Firefox.

Thanks for helping me, hopefully I'll be able to find some way to keep the functionality but have it work in FF.

more options

You can also try to set the width:0px and height:0px and instead of using display:none