summaryrefslogtreecommitdiff
path: root/static
diff options
context:
space:
mode:
authorJon Bergli Heier <snakebite@jvnv.net>2011-08-09 11:51:42 +0200
committerJon Bergli Heier <snakebite@jvnv.net>2011-08-09 11:51:42 +0200
commitc016ab19ace023d1fde977e6e6b7fae6e1f20261 (patch)
tree1648a7bc9b68b394bc6acc8d16641cf0c2220d95 /static
parent6ee205018af2f5d13f2606f16d82564d5877b589 (diff)
Recoding controlled by server, some cleanup.
Diffstat (limited to 'static')
-rw-r--r--static/index.html17
-rw-r--r--static/player.js36
2 files changed, 19 insertions, 34 deletions
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 @@
<link rel="stylesheet" href="/static/style.css" type="text/css" />
</head>
<body>
- <div id="transcode-div">
- <label for="trans_enabled"><input type="checkbox" id="trans_enabled" /> Transcode</label>
- from
- <select id="trans_from">
- <option value="ffmpeg">FFmpeg</option>
- </select>
- to
- <select id="trans_to">
- <option value="ffmpeg">FFmpeg</option>
- </select>
- </div>
<textarea id="logbox" readonly="readonly" rows="10" cols="50"></textarea>
- <div><input type="button" value="Close event source" onclick="source.close()" /></div>
+ <div>
+ <input type="button" value="Close event source" onclick="source.close()" />
+ <input type="button" value="Open event source" onclick="event_open()" />
+ <input type="button" value="Refresh directory" onclick="list(document.getElementById('current-dir').innerHTML.split(': ', 2)[1])" />
+ </div>
<div id="current-dir"></div>
<ul id="song-links"></ul>
<div id="audio-src-url">none</div>
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('/');