Example code (link with a sm2_button CSS class):
<p> <a href="/path/to/coins.mp3" title="Play "coins"" class="sm2_button">coins.mp3</a>
Spare change</p>
Renders as:
coins.mp3 Spare change
Note that the text inside the link is hidden and replaced with an image, but should be descriptive - or at least should say something generic, like "play".
Code:
<a href="../_mp3/office_lobby.mp3" title="Play "Office Lobby"" class="sm2_button">Office Lobby</a>
Renders as:
SoundManager 2 intercepts clicks to MP3 links and plays them inline. The script assigns additional CSS classes to the links to indicate their state (playing/paused, etc.)
CSS classes are dynamically applied as follows:
If you want to make your own UI from scratch, here is the base:
Default + hover state, "click to play":a.sm2_button {} a.sm2_button:hover {}
Playing + hover state, "click to pause":a.sm2_button.sm2_playing {} a.sm2_button.sm2_playing:hover {}
Paused + hover state, "click to resume":a.sm2_button.sm2_paused {} a.sm2_button.sm2_paused:hover {}
By default, one sound will be played at a time; you can easily change a "config" object value to turn on playlist-like behaviour (i.e., play the next MP3 when the current one finishes.)
// (within mp3-player-button.js)
this.config = {
playNext: false // stop after one sound, or play through list until end
}
See this basic demo for reference.
SoundManager 2 project page (not an MP3 link)