Advertisement
Err0r_500

Jplayer for bandcamp JS code

Nov 14th, 2011
259
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
jQuery 0.96 KB | None | 0 0
  1. $(document).ready(function(){
  2.     $.getJSON('http://api.bandcamp.com/api/band/3/discography?key=[your_API_key]&band_id=1484946095&callback=?', function(albums) {
  3.         $.post('./player.php', {disco_size: albums.discography.length },
  4.             function(data){
  5.                 $('.players').append(data);
  6.                 if (check('.jp-jplayer')){
  7.                 $('.jp-jplayer').each(
  8.                     function(index) {
  9.                         $.post('./playlist.php', { album: albums.discography[index].album_id },
  10.                             function(playlist){
  11.                                 new jPlayerPlaylist({
  12.                                     jPlayer: "#jquery_jplayer_" + index,
  13.                                     cssSelectorAncestor: "#jp_container_" + index
  14.                                     }, playlist, {
  15.                                     swfPath: "./js",
  16.                                     supplied: "mp3",
  17.                                     wmode: "window"
  18.                                     }
  19.                                 );
  20.                                 $('.players').css("display","block");
  21.                             }, "json"
  22.                         );
  23.                     }
  24.                 )};
  25.             }
  26.         );
  27.     });
  28.    
  29. function check(element){
  30.     if ( $(element).length > 0 ) {
  31.         return true;
  32.     }
  33.     else{
  34.         setTimeout(check(element), 100);
  35.     }      
  36. }
  37.    
  38. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement