Skip to content

Instantly share code, notes, and snippets.

@snorpey
Created April 2, 2012 02:13
Show Gist options
  • Save snorpey/2280020 to your computer and use it in GitHub Desktop.
Save snorpey/2280020 to your computer and use it in GitHub Desktop.
Queue audio files.
var jq = document.createElement('script');
jq.src = 'http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js';
jq.onload = snorpey_getPaths;
document.body.appendChild(jq);
var snorpey_paths = [];
var snorpey_index = 0;
var snorpey_player;
function snorpey_getPaths()
{
jQuery( '[data="player_mp3_maxi.swf"] param[name="FlashVars"]' )
.each(
function()
{
var path = jQuery( this )
.attr( 'value' )
.replace( 'mp3=', '' )
.replace( '&width=25&height=20&buttonwidth=25&showslider=0&showloading=never', '' )
snorpey_paths.push( path );
}
);
snorpey_playNext();
}
function snorpey_playNext()
{
if ( ! jQuery( '#snorpey-audio' ).length )
{
jQuery( 'body' ).append( '<audio id="snorpey-audio" preload="auto" controls="true"></audio>' );
jQuery( '#snorpey-audio' ).css( { position: 'fixed', top: 0, left: 0 } );
jQuery( '#snorpey-audio' ).bind( 'ended', snorpey_playNext );
}
if ( snorpey_index < snorpey_paths.length -1 )
{
jQuery( '#snorpey-audio' )[0].src = snorpey_paths[ snorpey_index ];
jQuery( '#snorpey-audio' )[0].play();
snorpey_index++;
}
}
@snorpey
Copy link
Author

snorpey commented Apr 2, 2012

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment