/* * Audio To Player * http://www.mattvarone.com * * By Matt Varone * @sksmatt * */ // WP Variable var mv_audio_to_player_js_params; (function ($, js_params) { // Get audio links var $audio = $('a[href$=".mp3"], a[href$=".m4a"], a[href$=".mp4"]'); // Check if there's any link and jPlayer is active if ($audio.length > 0 && $.isFunction($.fn.jPlayer)) { // set the template var template = '
', c = 0; // player's counter // loop trough the audio links $audio.each(function (index, player) { var $player = $(player), // asign element to a variable id = 'jquery_jplayer_' + c++, // generate an ID bef = $('').attr('id', id).addClass('audio-file jp-jplayer'), // generate before element aft = $(template).find('.jp-interface').attr('id', id).end(); // generate player template // run jPlayer $player.before(bef).after(aft).hide().prev().jPlayer({ ready: function () { $(this).jPlayer("setMedia", { mp3: player.href }); }, cssSelectorAncestor: '#' + id, // element ID swfPath: js_params.uri + '/js', // path to swf fallback supplied: "mp3" // type supplied (mp3 seems to work for all) }); }); } })(jQuery, mv_audio_to_player_js_params);