From c016ab19ace023d1fde977e6e6b7fae6e1f20261 Mon Sep 17 00:00:00 2001 From: Jon Bergli Heier Date: Tue, 9 Aug 2011 11:51:42 +0200 Subject: Recoding controlled by server, some cleanup. --- static/index.html | 17 +++++------------ static/player.js | 36 ++++++++++++++---------------------- 2 files changed, 19 insertions(+), 34 deletions(-) (limited to 'static') diff --git a/static/index.html b/static/index.html index ea20792..15384aa 100644 --- a/static/index.html +++ b/static/index.html @@ -7,19 +7,12 @@ -
- - from - - to - -
-
+
+ + + +
none
diff --git a/static/player.js b/static/player.js index ce75249..c0cf6ff 100644 --- a/static/player.js +++ b/static/player.js @@ -19,19 +19,14 @@ function MusicListing(type, path, name, cached) { this.a.tag = path; this.play = function() { - var transcode = document.getElementById('trans_enabled').checked; - var trans_from = document.getElementById('trans_from').value; - var trans_to = document.getElementById('trans_to').value; - var p = path; - if(transcode) - p += '?decoder=' + trans_from + '&encoder=' + trans_to; - log('playing ' + p); - change_url('/files/' + p); - audio.play(); + log('playing ' + path); + xmlhttp = new XMLHttpRequest(); + xmlhttp.open('GET', '/play?path=' + encodeURIComponent(path)); + xmlhttp.send(null); } - this.cache = function() { - var path = '/cache?path=' + encodeURIComponent(this.path) + + this.recode = function() { + var path = '/recode?path=' + encodeURIComponent(this.path) + '&decoder=' + document.getElementById('trans_from').value + '&encoder=' + document.getElementById('trans_to').value; var a = this.a; @@ -56,16 +51,7 @@ function MusicListing(type, path, name, cached) { if(type == 'dir') { list(path); } else if(type == 'file') { - var transcode = document.getElementById('trans_enabled').checked; - var trans_from = document.getElementById('trans_from').value; - var trans_to = document.getElementById('trans_to').value; - - var p = path; - if(transcode) { - ml.cache(p); - } else { - ml.play(); - } + ml.play(); } return false; } @@ -163,12 +149,18 @@ function event_handler(event) { } } -window.onload = function() { +function event_open() { + if(source) + source.close(); source = new EventSource('/events'); source.onopen = function() { log('event source opened'); } source.onmessage = event_handler; source.onerror = function(event) { log('event source error'); } log('event source status: ' + source.readyState); +} + +window.onload = function() { + event_open(); audio = new Audio(); list('/'); -- cgit v1.2.3