Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript

Having issues with audio tag in firefox with autoplay

I am having issues with this site. At first, when I open it on Firefox on a Mac, the audio autoplays in the player as intended, but seems to play more than one file or something and cannot be stopped, it just keeps looping onto itself. So I fixed that by using JS to say on load, play the file instead of the autoplay HTML attribute.

Everything worked great, but you would have to click on the play button twice to pause the song. So I added in some more JS to add the class of playing to the element which makes it now display the pause on load properly, but it still requires two clicks to actually pause the audio. I am wondering what JS I would use to make that button do the pause function on first click.

I am using the audio.js and audio HTML 5 tag as you can see. Any light shed would be greatly appreciated, thanks!

http://dev.greggawhite.com/test/