From 125679b35e66f32cc4d7a1878222de4ebb3f69cd Mon Sep 17 00:00:00 2001 From: Jon Bergli Heier Date: Sat, 13 Aug 2011 12:46:26 +0200 Subject: Recode next track, handled on client-side. --- static/player.js | 4 +--- static/playlist.js | 15 ++++++++++++++- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/static/player.js b/static/player.js index 2fa8793..d10080b 100644 --- a/static/player.js +++ b/static/player.js @@ -27,9 +27,7 @@ function MusicListing(type, path, name, cached) { } this.recode = function() { - var path = '/recode?path=' + encodeURIComponent(this.path) + - '&decoder=' + document.getElementById('trans_from').value + - '&encoder=' + document.getElementById('trans_to').value; + var path = '/recode?path=' + encodeURIComponent(this.path); var a = this.a; var ml = this; var xmlhttp = new XMLHttpRequest(); diff --git a/static/playlist.js b/static/playlist.js index 5e41de5..38db463 100644 --- a/static/playlist.js +++ b/static/playlist.js @@ -4,7 +4,7 @@ function Playlist(pl, audio) { this.current = null; this.get = function(path) { - var li = this.current; + var li = this.pl.getElementsByTagName('li')[0]; while(li) { var a = li.getElementsByTagName('a')[0]; if(a.ml.path == path) @@ -27,12 +27,25 @@ function Playlist(pl, audio) { a.setAttribute('class', 'playing'); pl.current = li; ml.play(); + + var nextsong = li.nextElementSibling; + log('nextsong: ' + nextsong); + if(nextsong) { + var nexta = nextsong.getElementsByTagName('a')[0]; + log('nexta: ' + nexta); + log('next ml: ' + nexta.ml); + nexta.ml.recode(); + } + return false; } log(a.click); li.appendChild(a); this.pl.appendChild(li); + + if(this.pl.firstChild == li || (this.current && this.current.nextElementSibling == li)) + ml.recode(); } this.next = function() { -- cgit v1.2.3