3 var current_que = 'main';
4 function updateStatus(){
6 url: 'requests/status.xml',
7 success: function(data,status,jqXHR){
8 if(current_que=='main'){
10 $('#mediaTitle').append($('[name="filename"]',data).text());
11 $('#totalTime').append(format_time($('length',data).text()));
12 $('#currentTime').append(format_time($('time',data).text()));
13 $('#seekSlider').slider({value: ($('position',data).text()*100) });
14 $('#currentVolume').append(Math.round($('volume',data).text()/5.12)+'%');
15 $('#volumeSlider').slider({value: ($('volume',data).text()/5.12) });
16 $('#rateSlider').slider({value: ($('rate',data).text()) });
17 $('#currentRate').append(Math.round($('rate',data).text()*100)/100+'x');
18 $('#audioSlider').slider({value: ($('audiodelay',data).text()) });
19 $('#currentAudioDelay').append(Math.round($('audiodelay',data).text()*100)/100+'s');
20 $('#subtitleSlider').slider({value: ($('subtitledelay',data).text()) });
21 $('#currentSubtitleDelay').append(Math.round($('subtitledelay',data).text()*100)/100+'s');
22 $('#seekSlider').attr('totalLength',$('length',data).text());
23 $('#buttonPlay').attr('state',$('state',data).text());
24 $('#buttonPlay').attr('mrl',$('[name="filename"]',data).text());
25 if($('state',data).text()=='playing'){
26 $('#buttonPlay').removeClass('paused');
27 $('#buttonPlay').addClass('playing');
29 $('#buttonPlay').removeClass('playing');
30 $('#buttonPlay').addClass('paused');
32 if($('random',data).text()=='true'){
33 $('#buttonShuffle').removeClass('ui-state-default');
34 $('#buttonShuffle').addClass('ui-state-active');
36 $('#buttonShuffle').addClass('ui-state-default');
37 $('#buttonShuffle').removeClass('ui-state-active');
39 if($('loop',data).text()=='true'){
40 $('#buttonLoop').removeClass('ui-state-default');
41 $('#buttonLoop').addClass('ui-state-active');
43 $('#buttonLoop').addClass('ui-state-default');
44 $('#buttonLoop').removeClass('ui-state-active');
46 if($('repeat',data).text()=='true'){
47 $('#buttonRepeat').removeClass('ui-state-default');
48 $('#buttonRepeat').addClass('ui-state-active');
50 $('#buttonRepeat').addClass('ui-state-default');
51 $('#buttonRepeat').removeClass('ui-state-active');
53 if($('[name="artwork_url"]',data).text()!=currentArt){
55 $('#albumArt').attr('src','/art?'+tmp.getTime());
56 currentArt = $('[name="artwork_url"]',data).text();
58 'visibility':'visible',
61 }else if($('[name="artwork_url"]',data).text()==""){
62 $('#albumArt').attr('src','images/vlc-48.png');
65 setTimeout( updateStatus, 1000 );
69 $('band',data).each(function(){
70 var id = $(this).attr('id');
71 var freq = convertHz($(this).attr('freqency'));
72 var value = $(this).text() ? $(this).text() : 0;
73 if(!$('#eq_container'+id).length){
74 $('#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>');
82 orientation: "vertical",
83 stop: function(event,ui){
84 $('#'+$(this).attr('id')+'_txt').empty().append(ui.value+'dB');
88 band: $(this).attr('id').substr(2)
91 slide: function(event,ui){
92 $('#'+$(this).attr('id')+'_txt').empty().append(ui.value+'dB');
96 $('#eq'+id).slider({value:value});
97 $('#eq'+id+'_txt').empty().append(Math.round(value*100)/100+'dB');
100 $('#preamp').slider('value',$('preamp',data).text());
101 $('#preamp_txt').empty().append(Math.round($('preamp',data).text()*100)/100+'dB');
103 error: function(jqXHR,status,error){
104 setTimeout( updateStatus, 500 );
108 function updatePlayList(){
109 $('#libraryTree').jstree('refresh',-1);
111 function sendCommand(params,append){
112 if(current_que=='stream'){
114 url: 'requests/status.xml',
116 success:function(data,status,jqXHR){
117 if(append!=undefined){
125 if(params.plreload===false){
127 url: 'requests/status.xml',
129 success:function(data,status,jqXHR){
130 if(append!=undefined){
137 url: 'requests/status.xml',
139 success:function(data,status,jqXHR){
140 if(append!=undefined){
149 function browse(dir){
150 dir = dir==undefined ? '~' : dir;
152 url: 'requests/browse.xml',
153 data:'dir='+encodeURIComponent(dir),
154 success: function(data,status,jqXHR){
155 var tgt = browse_target.indexOf('__')==-1 ? browse_target : browse_target.substr(0,browse_target.indexOf('__'));
156 $('#browse_elements').empty();
157 $('element',data).each(function(){
158 if($(this).attr('type')=='dir' || $.inArray($(this).attr('name').substr(-3),video_types)!=-1 || $.inArray($(this).attr('name').substr(-3),audio_types)!=-1){
159 $('#browse_elements').append(createElementLi($(this).attr('name'),$(this).attr('type'),$(this).attr('path'),$(this).attr('name').substr(-3)));
162 $('[opendir]').dblclick(function(){
163 browse($(this).attr('opendir'));
165 $('[openfile]').dblclick(function(){
167 case '#stream_input':
168 $(browse_target).val($(this).attr('openfile'));
171 $('li',browse_target).remove();
172 $(browse_target).append(this);
182 sendCommand('command=in_play&input=file://'+encodeURIComponent($(this).attr('openfile')));
185 $('#window_browse').dialog('close');
187 $('[opendir]').click(function(){
190 browse($(this).attr('opendir'));
196 $('[openfile]').click(function(){
199 sendCommand('command=in_play&input=file://'+encodeURIComponent($(this).attr('openfile')),"window.location='mobile.html'");
209 $('[selectable]').selectable();
213 error: function(jqXHR,status,error){
214 setTimeout('browse("'+dir+'")',1041);
218 function updateStreams(){
220 url: 'requests/vlm.xml',
221 success:function(data,status,jqXHR){
222 $('#stream_info').accordion("destroy");
223 $('#stream_info').empty();
224 $('broadcast',data).each(function(){
225 var stream_div = $('#stream_status_').clone();
226 var name = $(this).attr('name');
227 var loop = $(this).attr('loop')=='yes';
228 var playing = $('instance',$(this)).attr('state')=='playing';
229 var file = $('input',$(this)).text();
230 var output = $('output',$(this)).text();
231 var time = isNaN(Math.round($('instance',$(this)).attr('time')/1000000)) ? 0 : Math.round($('instance',$(this)).attr('time')/1000000);
232 var length = isNaN(Math.round($('instance',$(this)).attr('length')/1000000)) ? 0 : Math.round($('instance',$(this)).attr('length')/1000000);
233 $('[id]',stream_div).each(function(){
234 $(this).attr('id',$(this).attr('id')+name);
236 $(stream_div).attr('id',$(stream_div).attr('id')+name);
237 $('#stream_title_'+name,stream_div).append(name);
238 $('#stream_file_'+name,stream_div).append(file);
239 $('#stream_pos_'+name,stream_div).slider({
243 slide: function( event, ui ) {
244 $( "#stream_current_time_"+name,stream_div ).empty();
245 $( "#stream_current_time_"+name,stream_div ).append( format_time(ui.value) );
246 $( "#stream_total_time_"+name,stream_div ).empty();
247 $( "#stream_total_time_"+name,stream_div ).append( format_time($('#stream_pos_'+name,stream_div).slider('option','max')) );
248 sendVLMCmd('control '+name+' seek '+Math.round(ui.value/$('#stream_pos_'+name,stream_div).slider('option','max')*100));
250 change: function(event, ui){
251 $( "#stream_current_time_"+name,stream_div ).empty();
252 $( "#stream_current_time_"+name,stream_div ).append( format_time(ui.value) );
253 $( "#stream_total_time_"+name,stream_div ).empty();
254 $( "#stream_total_time_"+name,stream_div ).append( format_time($('#stream_pos_'+name,stream_div).slider('option','max')) );
257 $('#button_stream_stop_'+name,stream_div).click(function(){
258 sendVLMCmd('control '+name+' stop');
261 $('#button_stream_play_'+name,stream_div).click(function(){
262 if($('span',this).hasClass('ui-icon-pause')){
263 sendVLMCmd('control '+name+' pause');
265 sendVLMCmd('control '+name+' play');
268 $('#button_stream_loop_'+name,stream_div).click(function(){
270 sendVLMCmd('setup '+name+' unloop');
272 sendVLMCmd('setup '+name+' loop');
275 $('#button_stream_delete_'+name,stream_div).click(function(){
276 sendVLMCmd('del '+name);
278 $('#stream_pos_'+name,stream_div).slider({
283 $('span',$('#button_stream_play_'+name,stream_div)).removeClass('ui-icon-play');
284 $('span',$('#button_stream_play_'+name,stream_div)).addClass('ui-icon-pause');
287 $('#button_stream_loop_'+name,stream_div).addClass('ui-state-active');
293 $('#stream_info').append(stream_div);
297 function() { $(this).addClass('ui-state-hover'); },
298 function() { $(this).removeClass('ui-state-hover'); }
300 $('#stream_info').accordion({
305 if(current_que=='stream'){
306 $('.dynamic').empty();
307 $('#mediaTitle').append($('[name="Current"] input',data).text());
308 $('#totalTime').append(format_time(isNaN($('[name="Current"] instance',data).attr('length')) ? 0 : $('[name="Current"] instance',data).attr('length')/1000000));
309 $('#currentTime').append(format_time(isNaN($('[name="Current"] instance',data).attr('time')) ? 0 : $('[name="Current"] instance',data).attr('time')/1000000));
310 $('#seekSlider').slider({value: (($('[name="Current"] instance',data).attr('time')/1000000)/($('[name="Current"] instance',data).attr('length')/1000000)*100) });
311 $('#seekSlider').attr('totalLength',$('[name="Current"] instance',data).attr('length')/1000000);
312 $('#buttonPlay').attr('state',$('[name="Current"] instance',data).length>0 ? $('[name="Current"] instance',data).attr('state') : 'stopped');
313 if($('[name="Current"] instance',data).attr('state')=='playing'){
314 $('#buttonPlay').removeClass('paused');
315 $('#buttonPlay').addClass('playing');
317 $('#buttonPlay').removeClass('playing');
318 $('#buttonPlay').addClass('paused');
320 setTimeout( updateStreams, 1000 );
327 url: 'requests/equalizer.xml',
328 success: function(data,status,jqXHR){
329 $('band',data).each(function(){
330 var id = $(this).attr('id');
331 var freq = convertHz($(this).attr('freqency'));
332 var value = $(this).text() ? $(this).text() : 0;
333 if(!$('#eq_container'+id).length){
334 $('#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>');
342 orientation: "vertical",
343 stop: function(event,ui){
344 $('#'+$(this).attr('id')+'_txt').empty().append(ui.value+'dB');
348 band: $(this).attr('id').substr(2)
351 slide: function(event,ui){
352 $('#'+$(this).attr('id')+'_txt').empty().append(ui.value+'dB');
356 $('#eq'+id).slider({value:value});
357 $('#eq'+id+'_txt').empty().append(Math.round(value*100)/100+'dB');
360 $('#preamp').slider('value',$('preamp',data).text());
361 $('#preamp_txt').empty().append(Math.round($('preamp',data).text()*100)/100+'dB');
365 function sendVLMCmd(command,append){
366 var commands = command.split(';');
367 if(commands.length>1){
368 sendBatchVLMCmd(command,append);
370 if(current_que=='main'){
372 url: 'requests/vlm_cmd.xml',
373 data: 'command='+encodeURIComponent(command),
374 success: function(data,status,jqXHR){
375 if($('error',data).text()){
376 $('#error_container').append('<div>'+$('error',data).text()+'</div>');
377 $('#window_error').dialog('open');
379 if(append!=undefined){
387 url: 'requests/vlm_cmd.xml',
388 data: 'command='+encodeURIComponent(command),
389 success: function(data,status,jqXHR){
390 if($('error',data).text()){
391 $('#error_container').append('<div>'+$('error',data).text()+'</div>');
392 $('#window_error').dialog('open');
400 function sendBatchVLMCmd(command,append){
401 var commands = command.split(';');
403 url: 'requests/vlm_cmd.xml',
404 data: 'command='+encodeURIComponent(commands.shift()),
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');
410 sendVLMCmd(commands.join(';'),append);
414 function sendEQCmd(params){
416 url: 'requests/equalizer.xml',
418 success: function(data,status,jqXHR){
425 $('#libraryTree').jstree({
428 "url" : "requests/playlist_jstree.xml"
433 "item_leaf":"ui-icon-video"
435 "plugins" : ["xml_data","ui","themeroller"]
436 }).bind("loaded.jstree", function (event, data) {
437 $('[current]','[id^="plid_"]').each(function(){
438 $(this).addClass('ui-state-highlight');
439 current_id = $(this).attr('id').substr(5);
441 }).bind("refresh.jstree",function(event,data){
442 $('[current]','[id^="plid_"]').each(function(){
443 $(this).addClass('ui-state-highlight');
444 current_id = $(this).attr('id').substr(5);