<audio> elements not working on WordPress
I have a small WordPress site. I do a lot of audio work and I'm trying to post HTML5 audio clips in blog entries on WordPress. For some reason it isn't working. It might have something to do with the style I'm using on my WordPress site but I haven't been able to nail it down. I know my audio tags are valid, as they work elsewhere.
Here's an 开发者_Python百科example audio tag:
<audio src="http://files.dannystewart.com/dom2008.mp3"></audio>
And here's a page demonstrating it not working:
http://www.dannystewart.com/html5-audio-test/
I'm quite sure this is something very simple that I've just missed, but any pointers would be appreciated.
Thanks!
You seem to be missing the controls
attribute. This made it all work in Chrome for me:
<audio src="http://files.dannystewart.com/dom2008.mp3" controls></audio>
Note it won't work in Firefox - it doesn't support MP3 files. See http://adactio.com/journal/1669/ for a possible solution. As of December 2013, Firefox supports MP3 on Windows (XP+), Linux, Android, FirefoxOS, but not MacOS (bug). See https://developer.mozilla.org/en-US/docs/HTML/Supported_media_formats#Browser_compatibility.
Cool sound!
The problem is your doctype: html5 allows <!DOCTYPE html>
only. Which is not to say that browsers won't support html5 elements with other doctypes...but YMMV.
精彩评论