summaryrefslogtreecommitdiff
path: root/static
diff options
context:
space:
mode:
Diffstat (limited to 'static')
-rw-r--r--static/player.js30
-rw-r--r--static/playlist.js4
2 files changed, 26 insertions, 8 deletions
diff --git a/static/player.js b/static/player.js
index b358eb5..330938b 100644
--- a/static/player.js
+++ b/static/player.js
@@ -12,14 +12,32 @@ for(var i = 0; i < cache_images.length; i++) {
img.src = '/static/icons/' + cache_images[i];
}
-function MusicListing(type, path, name, track, cached) {
+function MusicListing(type, path, name, track, metadata, cached) {
this.type = type;
this.path = path;
this.name = name ? name : path.split('/').pop();
this.track = track;
+ this.metadata = metadata;
this.a = document.createElement('a');
this.a.ml = this;
+ this.get_text = function() {
+ if(!metadata)
+ return name;
+ var s = '';
+ if('artist' in metadata)
+ s = metadata['artist'] + ' - ';
+ if('album' in metadata)
+ s += metadata['album'] + ' - ';
+ if('title' in metadata)
+ s += metadata['title'];
+ if(s.length > 0 && track)
+ s = track + ' ' + s;
+ if(s.length == 0)
+ s = name;
+ return s;
+ }
+
this.play = function() {
var path = '/play?path=' + encodeURIComponent(this.path);
if(this.track)
@@ -49,9 +67,7 @@ function MusicListing(type, path, name, track, cached) {
className += ' file-cached'
a.setAttribute('class', className);
a.setAttribute('href', '#');
- var name = this.name;
- if(this.track)
- name += ' (track ' + this.track + ')';
+ var name = this.get_text();
a.appendChild(document.createTextNode(name));
var ml = this;
@@ -116,7 +132,11 @@ function list(root) {
var track = json[i]["track"];
var name = path.substring(path.lastIndexOf('/')+1);
var cached = type == "file" ? json[i]["cached"] : false;
- var l = new MusicListing(type, path, name, track, cached);
+ var metadata = json[i]["metadata"];
+ log(metadata.artist);
+ if('artist' in json[i]["metadata"])
+ log('got artist');
+ var l = new MusicListing(type, path, name, track, metadata, cached);
output_link(l);
}
}
diff --git a/static/playlist.js b/static/playlist.js
index d2ac424..92758b0 100644
--- a/static/playlist.js
+++ b/static/playlist.js
@@ -20,9 +20,7 @@ function Playlist(pl, audio) {
this.add = function(ml) {
var a = document.createElement('a');
a.setAttribute('href', '#');
- var name = ml.name;
- if(ml.track)
- name += ' (track ' + ml.track + ')';
+ var name = ml.get_text();
a.appendChild(document.createTextNode(name));
a.ml = ml;
var li = document.createElement('li');