Commit 60758c03 authored by Mark Hassman's avatar Mark Hassman Committed by Jean-Baptiste Kempf

WebUI: Update Playlist improvement

Close #5583

Playlist is cached/updated locally within browser instead of
refreshing after each function call.
Signed-off-by: default avatarJean-Baptiste Kempf <jb@videolan.org>
parent d12a67f4
...@@ -122,7 +122,10 @@ ...@@ -122,7 +122,10 @@
sendCommand({'command':'pl_random'}); sendCommand({'command':'pl_random'});
return false; return false;
}) })
$('#buttonRefresh').click(updatePlayList); $('#buttonRefresh').click(function(){
updatePlayList(true);
return false;
});
$('#buttonPlPlay').click(function(){ $('#buttonPlPlay').click(function(){
sendCommand({ sendCommand({
'command': 'pl_play', 'command': 'pl_play',
......
var current_id = 1; var current_id = 1;
var currentArt = null; var currentArt = null;
var current_que = 'main'; var current_que = 'main';
var previous_title = null;
var current_title = null;
function updateArt(url) { function updateArt(url) {
$('#albumArt').fadeOut(500, function () { $('#albumArt').fadeOut(500, function () {
...@@ -72,6 +74,13 @@ function updateStatus() { ...@@ -72,6 +74,13 @@ function updateStatus() {
currentArt = 'images/vlc-48.png'; currentArt = 'images/vlc-48.png';
updateArt(currentArt); updateArt(currentArt);
} }
current_title = $('[name="filename"]', data).text();
if (previous_title != current_title) {
updatePlayList();
}
previous_title = current_title;
if (pollStatus) { if (pollStatus) {
setTimeout(updateStatus, 1000); setTimeout(updateStatus, 1000);
} }
...@@ -119,8 +128,30 @@ function updateStatus() { ...@@ -119,8 +128,30 @@ function updateStatus() {
}); });
} }
function updatePlayList() { function updatePlayList(force_refresh) {
$('#libraryTree').jstree('refresh', -1); if (force_refresh) {
//refresh playlist..
$('#libraryTree').jstree('refresh', -1);
} else {
//iterate through playlist..
$('.jstree-leaf').each(function(){
var id = $(this).attr('id');
if (id != null && id.substr(0,5) == 'plid_') {
var name = $(this).attr('name');
if (name != null && name == current_title) {
$(this).addClass('ui-state-highlight');
$(this).attr('current', 'current');
this.scrollIntoView(true);
} else {
$(this).removeClass('ui-state-highlight');
$(this).removeAttr('current');
}
if ($(this).children('a').size() > 0) {
$($(this).children('a')[0]).removeClass('ui-state-active');
}
}
});
}
} }
function sendCommand(params, append) { function sendCommand(params, append) {
...@@ -133,7 +164,6 @@ function sendCommand(params, append) { ...@@ -133,7 +164,6 @@ function sendCommand(params, append) {
eval(append); eval(append);
} }
updateStatus(); updateStatus();
updatePlayList();
} }
}); });
} else { } else {
...@@ -155,7 +185,6 @@ function sendCommand(params, append) { ...@@ -155,7 +185,6 @@ function sendCommand(params, append) {
if (append != undefined) { if (append != undefined) {
eval(append); eval(append);
} }
updatePlayList();
} }
}); });
} }
...@@ -490,7 +519,6 @@ $(function () { ...@@ -490,7 +519,6 @@ $(function () {
event.preventDefault(); event.preventDefault();
current_id = $(this).parent().attr('id').substr(5); current_id = $(this).parent().attr('id').substr(5);
sendCommand('command=pl_play&id=' + current_id); sendCommand('command=pl_play&id=' + current_id);
updatePlayList();
}); });
updateStatus(); updateStatus();
updateStreams(); updateStreams();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment