Cites: sticky and custom backgrounds.
[wolnelektury.git] / apps / catalogue / static / player / player.js
1 (function($) {
2     $(function() {
3
4       $("#jplayer").each(function() {
5         var $self = $(this);
6         $self.jPlayer({
7             swfPath: "/static/jplayer/",
8             solution: "html,flash",
9             supplied: $self.attr('data-supplied'),
10     
11             ready: function() {
12                 var player = $(this);
13                 var setMedia = function(elem) {
14                     var li = $(elem).parent();
15                     $('.jp-playlist-current').removeClass('jp-playlist-current');
16                     $(li).addClass('jp-playlist-current');
17                     var media = {}
18     
19                     $('.mp3', li).each(function() {media['mp3'] = $(this).attr('href')});
20                     $('.ogg', li).each(function() {media['oga'] = $(this).attr('href')});
21     
22                     return player.jPlayer("setMedia", media);
23                 };
24                 setMedia($('.play').first()).jPlayer("play");
25     
26                 $('.play').click(function() {
27                     setMedia(this).jPlayer("play");
28                 });
29             }
30         });
31       });
32
33     });
34 })(jQuery)