Skip to content

Instantly share code, notes, and snippets.

@aaronmcadam
Created June 22, 2010 19:31
Show Gist options
  • Save aaronmcadam/448943 to your computer and use it in GitHub Desktop.
Save aaronmcadam/448943 to your computer and use it in GitHub Desktop.
old_nm.js
$(document).ready(function() {
// Calling the Bubble Up plugin on the social icons in the header
$('#icon_container ul li img').bubbleup({tooltip: true, scale:66});
// Create an array of URLS to mp3s which are stored in links with a class of 'audio'
var mp3s = $('.audio').map( function() { return this.href; } ).toArray();
var clipIndex = 0; // setting Clip index variable
// install flowplayer into container
$f("player", "/assets/js/flowplayer/flowplayer-3.2.2.swf", {
playlist: mp3s,
plugins: {
controls: null,
audio: {
url: '/assets/js/flowplayer/flowplayer.audio-3.2.0.swf'
}
},
clip: {
autoPlay: false,
onFinish : function(clip) {
$('#volume').slideUp('fast');
$('.play a').filter('.active').removeClass('active'); // Remove any active class
$('.play a').filter('.pause').removeClass('pause'); // Replace the Pause icon with a Play one
}
}
});
// cache the Flow Player object
var audioPlayer = $f("player");
// Grab the playlist
var playlist = audioPlayer.getPlaylist();
var play = $('.play a');
play.click (function(e) {
$("#volume").slideDown('fast');
var index = $('div.podcast').index($(this).closest('.podcast'));
if (audioPlayer.getState() == 3 && $(this).is('.active') )
{
// pause
$(this).removeClass('pause'); // Replace the Pause icon with a Play one
audioPlayer.pause();
}
else if (audioPlayer.getState() == 4 && $(this).is('.active') )
{
// resume
$(this).removeClass('pause'); // Replace the Play icon with a Pause one
audioPlayer.resume();
}
else
{
// play
play.filter('.pause').removeClass('pause'); // Replace the Pause icon with a Play one
$(this).addClass('pause'); // Replace the Play icon with a Pause one
audioPlayer.play (playlist[index]);
play.filter('.active').removeClass('active');
$(this).addClass ('active');
}
e.preventDefault();
});
$('.stop a').click(function(e) {
if ( ( audioPlayer.getState() == 3 ) || ( audioPlayer.getState() == 4 ) ) { // If the player is playing or is paused
audioPlayer.stop();
play.filter('.active').removeClass('active');
play.filter('.pause').removeClass('pause'); // Replace the Pause icon with a Play one
$("#volume").slideUp('fast');
}
e.preventDefault();
});
$("#slider-horizontal").empty().slider({
orientation: "horizontal",
range: "min",
min: 0,
max: 100,
value: 50,
slide: function(event, ui) {
audioPlayer.setVolume(ui.value);
}
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment