3 var current_que = 'main';
4 function updateArt(url)
6 $('#albumArt').fadeOut(500, function(){
7 $(this).addClass('hidden')
13 function updateStatus(){
15 url: 'requests/status.xml',
16 success: function(data,status,jqXHR){
17 if(current_que=='main'){
18 $('.dynamic').empty();
19 $('#mediaTitle').append($('[name="filename"]',data).text());
20 $('#totalTime').append(format_time($('length',data).text()));
21 $('#currentTime').append(format_time($('time',data).text()));
22 $('#seekSlider').slider({value: toFloat($('position',data).text()) * 100 });
23 $('#currentVolume').append(Math.round($('volume',data).text()/2.56)+'%');
24 $('#volumeSlider').slider({value: ($('volume',data).text()/5.12) });
25 $('#rateSlider').slider({value: ($('rate',data).text()) });
26 $('#currentRate').append(Math.round($('rate',data).text()*100)/100+'x');
27 $('#audioSlider').slider({value: ($('audiodelay',data).text()) });
28 $('#currentAudioDelay').append(Math.round($('audiodelay',data).text()*100)/100+'s');
29 $('#subtitleSlider').slider({value: ($('subtitledelay',data).text()) });
30 $('#currentSubtitleDelay').append(Math.round($('subtitledelay',data).text()*100)/100+'s');
31 $('#seekSlider').attr('totalLength',$('length',data).text());
33 .attr('state',$('state',data).text())
34 .attr('mrl',$('[name="filename"]',data).text());
35 if($('state',data).text()=='playing'){
36 $('#buttonPlay').removeClass('paused').addClass('playing');
38 $('#buttonPlay').removeClass('playing').addClass('paused');
40 if($('random',data).text()=='true'){
42 .removeClass('ui-state-default')
43 .addClass('ui-state-active');
46 .addClass('ui-state-default')
47 .removeClass('ui-state-active');
49 if($('loop',data).text()=='true'){
51 .removeClass('ui-state-default')
52 .addClass('ui-state-active');
55 .addClass('ui-state-default')
56 .removeClass('ui-state-active');
58 if($('repeat',data).text()=='true'){
60 .removeClass('ui-state-default')
61 .addClass('ui-state-active');
64 .addClass('ui-state-default')
65 .removeClass('ui-state-active');
68 if($('[name="artwork_url"]',data).text()!=currentArt
69 && $('[name="artwork_url"]',data).text()!="")
72 currentArt = $('[name="artwork_url"]',data).text();
73 updateArt('/art?'+tmp.getTime());
74 }else if($('[name="artwork_url"]',data).text()==""
75 && currentArt!='images/vlc-48.png')
77 currentArt='images/vlc-48.png';
78 updateArt(currentArt);
81 setTimeout( updateStatus, 1000 );
85 $('band',data).each(function(){
86 var id = $(this).attr('id');
87 var freq = convertHz($(this).attr('freqency'));
88 var value = $(this).text() ? $(this).text() : 0;
89 if(!$('#eq_container'+id).length){
90 $('#window_equalizer').append('<div style="float:left;width:44px;" align="center" id="eq_container'+id+'"><div id="eq'+id+'_txt">'+value+'dB</div><div class="eqBand" id="eq'+id+'" style="font-size: 18px;"></div><div>'+freq+'</div></div>');
98 orientation: "vertical",
99 stop: function(event,ui){
100 $('#'+$(this).attr('id')+'_txt').empty().append(ui.value+'dB');
104 band: $(this).attr('id').substr(2)
107 slide: function(event,ui){
108 $('#'+$(this).attr('id')+'_txt').empty().append(ui.value+'dB');
112 $('#eq'+id).slider({value:value});
113 $('#eq'+id+'_txt').empty().append(Math.round(value*100)/100+'dB');
116 $('#preamp').slider('value',$('preamp',data).text());
117 $('#preamp_txt').empty().append(Math.round($('preamp',data).text()*100)/100+'dB');
119 error: function(jqXHR,status,error){
120 setTimeout( updateStatus, 500 );
124 function updatePlayList(){
125 $('#libraryTree').jstree('refresh',-1);
127 function sendCommand(params,append){
128 if(current_que=='stream'){
130 url: 'requests/status.xml',
132 success:function(data,status,jqXHR){
133 if(append!=undefined){
141 if(params.plreload===false){
143 url: 'requests/status.xml',
145 success:function(data,status,jqXHR){
146 if(append!=undefined){
153 url: 'requests/status.xml',
155 success:function(data,status,jqXHR){
156 if(append!=undefined){
165 function browse(dir){
166 dir = dir==undefined ? '~' : dir;
168 url: 'requests/browse.xml',
169 data:'dir='+encodeURIComponent(dir),
170 success: function(data,status,jqXHR){
171 var tgt = browse_target.indexOf('__')==-1 ? browse_target : browse_target.substr(0,browse_target.indexOf('__'));
172 $('#browse_elements').empty();
173 $('element',data).each(function(){
174 if($(this).attr('type')=='dir' || $.inArray($(this).attr('name').substr(-3),video_types)!=-1 || $.inArray($(this).attr('name').substr(-3),audio_types)!=-1){
175 $('#browse_elements').append(createElementLi($(this).attr('name'),$(this).attr('type'),$(this).attr('path'),$(this).attr('name').substr(-3)));
178 $('[opendir]').dblclick(function(){
179 browse($(this).attr('opendir'));
181 $('[openfile]').dblclick(function(){
183 case '#stream_input':
184 $(browse_target).val($(this).attr('openfile'));
187 $('li',browse_target).remove();
188 $(browse_target).append(this);
198 sendCommand('command=in_play&input=file://'+encodeURIComponent($(this).attr('openfile')));
201 $('#window_browse').dialog('close');
203 $('[opendir]').click(function(){
206 browse($(this).attr('opendir'));
212 $('[openfile]').click(function(){
215 sendCommand('command=in_play&input=file://'+encodeURIComponent($(this).attr('openfile')),"window.location='mobile.html'");
225 $('[selectable]').selectable();
229 error: function(jqXHR,status,error){
230 setTimeout('browse("'+dir+'")',1041);
234 function updateStreams(){
236 url: 'requests/vlm.xml',
237 success:function(data,status,jqXHR){
238 $('#stream_info').accordion("destroy");
239 $('#stream_info').empty();
240 $('broadcast',data).each(function(){
241 var stream_div = $('#stream_status_').clone();
242 var name = $(this).attr('name');
243 var loop = $(this).attr('loop')=='yes';
244 var playing = $('instance',$(this)).attr('state')=='playing';
245 var file = $('input',$(this)).text();
246 var output = $('output',$(this)).text();
247 var time = isNaN(Math.round($('instance',$(this)).attr('time')/1000000)) ? 0 : Math.round($('instance',$(this)).attr('time')/1000000);
248 var length = isNaN(Math.round($('instance',$(this)).attr('length')/1000000)) ? 0 : Math.round($('instance',$(this)).attr('length')/1000000);
249 $('[id]',stream_div).each(function(){
250 $(this).attr('id',$(this).attr('id')+name);
252 $(stream_div).attr('id',$(stream_div).attr('id')+name);
253 $('#stream_title_'+name,stream_div).append(name);
254 $('#stream_file_'+name,stream_div).append(file);
255 $('#stream_pos_'+name,stream_div).slider({
259 slide: function( event, ui ) {
260 $( "#stream_current_time_"+name,stream_div ).empty();
261 $( "#stream_current_time_"+name,stream_div ).append( format_time(ui.value) );
262 $( "#stream_total_time_"+name,stream_div ).empty();
263 $( "#stream_total_time_"+name,stream_div ).append( format_time($('#stream_pos_'+name,stream_div).slider('option','max')) );
264 sendVLMCmd('control '+name+' seek '+Math.round(ui.value/$('#stream_pos_'+name,stream_div).slider('option','max')*100));
266 change: function(event, ui){
267 $( "#stream_current_time_"+name,stream_div ).empty();
268 $( "#stream_current_time_"+name,stream_div ).append( format_time(ui.value) );
269 $( "#stream_total_time_"+name,stream_div ).empty();
270 $( "#stream_total_time_"+name,stream_div ).append( format_time($('#stream_pos_'+name,stream_div).slider('option','max')) );
273 $('#button_stream_stop_'+name,stream_div).click(function(){
274 sendVLMCmd('control '+name+' stop');
277 $('#button_stream_play_'+name,stream_div).click(function(){
278 if($('span',this).hasClass('ui-icon-pause')){
279 sendVLMCmd('control '+name+' pause');
281 sendVLMCmd('control '+name+' play');
284 $('#button_stream_loop_'+name,stream_div).click(function(){
286 sendVLMCmd('setup '+name+' unloop');
288 sendVLMCmd('setup '+name+' loop');
291 $('#button_stream_delete_'+name,stream_div).click(function(){
292 sendVLMCmd('del '+name);
294 $('#stream_pos_'+name,stream_div).slider({
299 $('span',$('#button_stream_play_'+name,stream_div)).removeClass('ui-icon-play');
300 $('span',$('#button_stream_play_'+name,stream_div)).addClass('ui-icon-pause');
303 $('#button_stream_loop_'+name,stream_div).addClass('ui-state-active');
309 $('#stream_info').append(stream_div);
313 function() { $(this).addClass('ui-state-hover'); },
314 function() { $(this).removeClass('ui-state-hover'); }
316 $('#stream_info').accordion({
321 if(current_que=='stream'){
322 $('.dynamic').empty();
323 $('#mediaTitle').append($('[name="Current"] input',data).text());
324 $('#totalTime').append(format_time(isNaN($('[name="Current"] instance',data).attr('length')) ? 0 : $('[name="Current"] instance',data).attr('length')/1000000));
325 $('#currentTime').append(format_time(isNaN($('[name="Current"] instance',data).attr('time')) ? 0 : $('[name="Current"] instance',data).attr('time')/1000000));
326 $('#seekSlider').slider({value: (($('[name="Current"] instance',data).attr('time')/1000000)/($('[name="Current"] instance',data).attr('length')/1000000)*100) });
327 $('#seekSlider').attr('totalLength',$('[name="Current"] instance',data).attr('length')/1000000);
328 $('#buttonPlay').attr('state',$('[name="Current"] instance',data).length>0 ? $('[name="Current"] instance',data).attr('state') : 'stopped');
329 if($('[name="Current"] instance',data).attr('state')=='playing'){
330 $('#buttonPlay').removeClass('paused');
331 $('#buttonPlay').addClass('playing');
333 $('#buttonPlay').removeClass('playing');
334 $('#buttonPlay').addClass('paused');
336 setTimeout( updateStreams, 1000 );
343 url: 'requests/equalizer.xml',
344 success: function(data,status,jqXHR){
345 $('band',data).each(function(){
346 var id = $(this).attr('id');
347 var freq = convertHz($(this).attr('freqency'));
348 var value = $(this).text() ? $(this).text() : 0;
349 if(!$('#eq_container'+id).length){
350 $('#window_equalizer').append('<div style="float:left;width:44px;" align="center" id="eq_container'+id+'"><div id="eq'+id+'_txt">'+value+'dB</div><div class="eqBand" id="eq'+id+'" style="font-size: 18px;"></div><div>'+freq+'</div></div>');
358 orientation: "vertical",
359 stop: function(event,ui){
360 $('#'+$(this).attr('id')+'_txt').empty().append(ui.value+'dB');
364 band: $(this).attr('id').substr(2)
367 slide: function(event,ui){
368 $('#'+$(this).attr('id')+'_txt').empty().append(ui.value+'dB');
372 $('#eq'+id).slider({value:value});
373 $('#eq'+id+'_txt').empty().append(Math.round(value*100)/100+'dB');
376 $('#preamp').slider('value',$('preamp',data).text());
377 $('#preamp_txt').empty().append(Math.round($('preamp',data).text()*100)/100+'dB');
381 function sendVLMCmd(command,append){
382 var commands = command.split(';');
383 if(commands.length>1){
384 sendBatchVLMCmd(command,append);
386 if(current_que=='main'){
388 url: 'requests/vlm_cmd.xml',
389 data: 'command='+encodeURIComponent(command),
390 success: function(data,status,jqXHR){
391 if($('error',data).text()){
392 $('#error_container').append('<div>'+$('error',data).text()+'</div>');
393 $('#window_error').dialog('open');
395 if(append!=undefined){
403 url: 'requests/vlm_cmd.xml',
404 data: 'command='+encodeURIComponent(command),
405 success: function(data,status,jqXHR){
406 if($('error',data).text()){
407 $('#error_container').append('<div>'+$('error',data).text()+'</div>');
408 $('#window_error').dialog('open');
416 function sendBatchVLMCmd(command,append){
417 var commands = command.split(';');
419 url: 'requests/vlm_cmd.xml',
420 data: 'command='+encodeURIComponent(commands.shift()),
421 success:function(data,status,jqXHR){
422 if($('error',data).text()){
423 $('#error_container').append('<div>'+$('error',data).text()+'</div>');
424 $('#window_error').dialog('open');
426 sendVLMCmd(commands.join(';'),append);
430 function sendEQCmd(params){
432 url: 'requests/equalizer.xml',
434 success: function(data,status,jqXHR){
441 $('#albumArt').load(function(){
442 var width=$(this).width();
443 var height=$(this).height();
444 var max=Math.max(width,height);
448 width=Math.floor(width*ratio);
449 height=Math.floor(height*ratio);
451 $(this).attr('width',width)
452 .attr('height',height)
453 .css('margin-left', Math.floor((150 - width)/2))
454 .css('margin-top', Math.floor((150 - height)/2))
455 .removeClass('hidden')
458 $('#libraryTree').jstree({
461 "url" : "requests/playlist_jstree.xml"
466 "item_leaf":"ui-icon-video"
469 "initially_open": ["plid_1","plid_2","plid_3"]
471 "plugins" : ["xml_data","ui","themeroller"]
472 }).bind("loaded.jstree", function (event, data) {
473 $('[current]','[id^="plid_"]').each(function(){
474 $(this).addClass('ui-state-highlight');
475 current_id = $(this).attr('id').substr(5);
477 }).bind("refresh.jstree",function(event,data){
478 $('[current]','[id^="plid_"]').each(function(){
479 $(this).addClass('ui-state-highlight');
480 current_id = $(this).attr('id').substr(5);
482 }).delegate("#plid_2 li.jstree-leaf a", "click",function(event, data){
483 event.preventDefault();
484 current_id = $(this).parent().attr('id').substr(5);
485 sendCommand('command=pl_play&id=' + current_id);