Skip to content

Instantly share code, notes, and snippets.

@johnholdun
Created December 18, 2009 02:18
Show Gist options
  • Save johnholdun/259232 to your computer and use it in GitHub Desktop.
Save johnholdun/259232 to your computer and use it in GitHub Desktop.
A simple bit of code that automatically prepends an AudioPlayer instance (http://wpaudioplayer.com) before the paragraph of any link to an MP3.
/* * *
A simple bit of code that automatically prepends an AudioPlayer instance
(http://wpaudioplayer.com) before the paragraph of any link to an MP3.
Depends on jQuery and AudioPlayer.
* * */
$(function() {
var audio_count = 1;
$("a[href$=.mp3]").each(function() {
var $anchor = $(this),
$player = $anchor.parent("p").before('<div id="audio-player-' + audio_count + '"></div>');
AudioPlayer.embed("audio-player-" + audio_count, { soundFile:$anchor.attr("href") });
audio_count++;
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment