add player

This commit is contained in:
j 2012-09-06 13:08:51 +02:00
parent 7f62cc0b07
commit a31e2bd546

View file

@ -121,6 +121,7 @@ Ox.load('UI', function() {
app.loaded = true;
app.$ui.appPanel.replaceElement(1, app.$ui.list = app.ui.list());
});
app.$ui.player = app.ui.player();
}
app.ui.appPanel = function() {
var $element = Ox.SplitPanel({
@ -175,6 +176,24 @@ Ox.load('UI', function() {
});
return $element;
};
app.ui.player = function() {
var that = {},
player = document.createElement('audio');
that.play = function(id) {
if(id) {
player.src = '/track/' + id + '.mp3';
$(player).one('loadedmetadata', function() {
player.play();
});
} else {
player.play();
}
}
that.pause = function() {
player.pause();
}
return that;
}
app.ui.statusbar = function() {
var $status = $('<div>').attr({id: 'status'}),
$element = Ox.Bar({size: 24})
@ -270,7 +289,9 @@ Ox.load('UI', function() {
if (id != app.user.playing) {
app.user.playing = id;
app.$ui.list.value(app.user.playing, 'playing', true);
app.$ui.player.play(id);
}
};
app.load();
window.app = app;
});