In preparation for explaining how to podcast with Blogger, this tutorial explains how to easily add an HTML5 mp3/audio player to your blog posts or layout. No JavaScript, Flash or plugins are required, and with a fallback for older browsers which don't support the player.
I've even created a simple form to generate basic tags for you! Adding music to your Blogspot site has never been so easy!
The <audio> tag is a new feature of HTML5 which we can use to natively embed audio playback in our sites.
It is supported in Internet Explorer 9, Firefox, Opera, Chrome, and Safari, and can be set to play the linked audio file automatically (autoplay) or loop if required.
Here's a basic example using the <audio> element:
The audio player above is produced using the following HTML code:
<audio controls>In the example above, all code related to the audio player is wrapped in <audio> tags. By including controls in the audio element, a simple player is displayed, enabling the user to begin playback when (or if) they want, and to adjust the volume.
<source src="url-of-audio-file" />
If you cannot see the audio controls, your browser does not support the audio element
</audio>
Any text between the audio tags (which is not enclosed in the <source> tags) is displayed in browsers which do not support the audio element (IE8 and below).
If you would like the audio to begin playback as soon as it is ready, you can enable autoplay as in the following example:
<audio controls autoplay>
<source src="url-of-audio-file" />
If you cannot see the audio controls, your browser does not support the audio element
</audio>
By retaining the controls attribute, you give visitors the option to stop or resume audio playback if they choose.
To loop audio (specify that the audio will start over again, every time it is finished), include the loop element in the <audio> tag, like this:
<audio controls loop>
<source src="url-of-audio-file" />
If you cannot see the audio controls, your browser does not support the audio element
</audio>
Hosting files for your audio player
Blogger does not allow us to upload or host audio files, so in order to add an audio player you will need to find a host for your mp3/ogg files.While Blogger Help suggests hosting providers which offer free and premium packages, I anticipate most of you would prefer a simple free solution, so here are a few suggestions:
- Link to public domain audio files which allow hotlinking, such as this collection of classical music on Wikipedia
- Upload files to your Public folder on Dropbox
- Host files on Google sites
Once you have uploaded your audio files, make a note of the direct link to the file which you'll need to add in the code for your audio player.
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation.
0 comments:
Post a Comment