1
0
Fork 0
mirror of https://github.com/Yetangitu/ampache synced 2025-10-03 17:59:21 +02:00

the important part of the previous queue-commit...

This commit is contained in:
Holger Brunn 2013-01-31 23:31:04 +01:00 committed by Paul Arthur
parent f618f74db5
commit 81ff3c5d81

View file

@ -76,6 +76,7 @@ function play(event)
$('artist').update(current_playlist_item.author);
//$('artist').select('a')[0].writeAttribute('target', '_new');
$('albumart').update(new Element('img', {src: current_playlist_item.albumart_url}));
dequeue(current_playlist_item.element);
current_playlist_item.player.writeAttribute('preload', 'auto');
current_playlist_item.player.play();
if(current_playlist_item.element.offsetTop - $('playlist').offsetTop - $('playlist').scrollTop > $('playlist').measure('height') || current_playlist_item.element.offsetTop - $('playlist').offsetTop - $('playlist').scrollTop < 0)
@ -91,7 +92,9 @@ function next(event)
if(current_playlist_item && current_playlist_item.next)
{
stop();
current_playlist_item = current_playlist_item.next;
var next = current_playlist_item.next;
$$('[data-queue-id=1]').each(function(e) { next=e.getStorage().get('playlist_item') });
current_playlist_item = next;
play();
}
}
@ -129,12 +132,7 @@ function timeupdate(event)
}
function ended(event)
{
if(current_playlist_item && current_playlist_item.next)
{
stop();
current_playlist_item = current_playlist_item.next;
play();
}
next(event);
}
function search(event)
{
@ -156,6 +154,48 @@ function clear_search(event)
event.findElement().value = "";
search(event);
}
function queue(event)
{
var queue_id=0;
if(event.findElement().getAttribute('data-queue-id'))
{
return dequeue(event.findElement());
}
$$('[data-queue-id]').each(
function(e)
{
if(parseInt(e.getAttribute('data-queue-id')) > queue_id)
{
queue_id = parseInt(e.getAttribute('data-queue-id'));
}
});
event.findElement().setAttribute('data-queue-id', queue_id+1);
}
function dequeue(element)
{
var queue_id=0;
$$('[data-queue-id]').sort(
function(x, y)
{
return parseInt(x.getAttribute('data-queue-id'))-parseInt(y.getAttribute('data-queue-id'));
})
.each(
function(e)
{
if(queue_id)
{
e.setAttribute('data-queue-id', queue_id++);
}
if(e==element)
{
queue_id=parseInt(e.getAttribute('data-queue-id'));
e.removeAttribute('data-queue-id');
}
});
}
document.observe("dom:loaded", function()
{
var last_item = null, first_item = null;
@ -169,6 +209,8 @@ playlist_items[id].player = new Element("audio", {preload: Prototype.Browser.IE
li.insert(playlist_items[id].player);
li.getStorage().set('playlist_item', playlist_items[id]);
li.observe('click', play_item);
li.observe('mousedown', function(event) {if(event.which==2 || event.which==3) queue(event)});
li.setAttribute('data-tooltip', playlist_items[id].album + ' - ' + playlist_items[id].author);
playlist_items[id].player.observe('ended', ended);
playlist_items[id].player.observe('timeupdate', timeupdate);
playlist_items[id].element = li;