Mercurial > hg > dml-open-cliopatria
comparison cpack/dml/web/js/playlist.js @ 0:718306e29690 tip
commiting public release
author | Daniel Wolff |
---|---|
date | Tue, 09 Feb 2016 21:05:06 +0100 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:718306e29690 |
---|---|
1 /* Part of DML (Digital Music Laboratory) | |
2 Copyright 2014-2015 Samer Abdallah, University College London | |
3 Distributed under GPL v3 | |
4 */ | |
5 | |
6 function init_playlist(id){ | |
7 var audio=$('#'+id+'-audio'); | |
8 var tracks=$('#'+id+'-list').find('li a.audio'); | |
9 var current=0; | |
10 | |
11 console.log('Initialising playlist '+id+' with '+tracks.length+' tracks.'); | |
12 last=tracks.length - 1; | |
13 audio[0].volume= .50; | |
14 tracks.click(function(e){ | |
15 e.preventDefault(); | |
16 link=$(this); | |
17 current=link.parent().parent().index(); | |
18 pl_run(link, audio[0]); | |
19 }); | |
20 audio[0].addEventListener('ended',function(e){ | |
21 current++; | |
22 if(current==last){current=0; link=tracks[0];} | |
23 else{link=tracks[current];} | |
24 pl_run($(link),audio[0]); | |
25 }); | |
26 } | |
27 function pl_run(link, player){ | |
28 player.src=link.attr('href'); | |
29 par=link.parent().parent(); | |
30 par.addClass('active').siblings().removeClass('active'); | |
31 player.load(); | |
32 player.play(); | |
33 } |