diff options
Diffstat (limited to 'static/player.js')
-rw-r--r-- | static/player.js | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/static/player.js b/static/player.js index c0cf6ff..2fa8793 100644 --- a/static/player.js +++ b/static/player.js @@ -1,4 +1,5 @@ audio = null; +playlist = null; // pre-load some icons cache_images = new Array( @@ -51,7 +52,7 @@ function MusicListing(type, path, name, cached) { if(type == 'dir') { list(path); } else if(type == 'file') { - ml.play(); + playlist.add(ml); } return false; } @@ -135,9 +136,24 @@ function event_handler(event) { case 'cached': case 'recoding': log('[' + data['type'] + '] ' + data['path']); + // update directory browser var a = get_a(data['path']); if(a) a.setAttribute('class', 'file file-' + data['type']); + // update song queue + var li = playlist.get(data['path']); + if(li) { + a = li.getElementsByTagName('a')[0]; + if(data['type'] == 'cached') { + // play the current song if we were waiting for it + if(li == playlist.current) + a.onclick(); + else + a.setAttribute('class', ''); + } else { + a.setAttribute('class', 'file-recoding'); + } + } break; case 'play': log('[play] ' + data['path']); @@ -163,5 +179,7 @@ window.onload = function() { event_open(); audio = new Audio(); + playlist = new Playlist(document.getElementById('playlist'), audio); + audio.audio.addEventListener('ended', function() { playlist.next(); }); list('/'); } |